LZN's Blog CodePlayer

Mask region in the grid system according to shapefile


Here is a demand from YQ that the area of Shanghai need to be marked out from the WRF/CMAQ grid system. Previously, we have tried to mask out the whole region, e.g. the PRD. Now, we need to read the shapefile, and mask the region (closed polyline) by the given name.

A NCL Page talking about the shapefile in NCL. However, we do not need to know deep in the GIS architecture. The only thing we need to know is how to mask the region by named polylines.

Still, the shapefile_mask_data works for this. Just an optional attribute is enough.

  opt             = True
  opt@debug       = True
  opt@shape_var   = "NAME_1"
  opt@shape_names = "Shanghai"

ncl_filedump -v can be used to iterate all possible values for shape_var. Original script is available on the github.

Updated 2018-11-13

下一篇 Nuuk in the air