[ncl-talk] Writing shapefile to netcdf
JoshAB1995 at outlook.com
JoshAB1995 at outlook.com
Tue Jul 16 05:25:41 MDT 2019
Hi guys,
I’m brand new to NCL as I need to quickly use it to convert a shapefile to a netcdf file. The idea is to create a mask of marine protected areas included in the shapefile. I’ve tried using the following code but as I’ve highlighted in the code I run into some issues...
load "shapefile_utils.ncl"
shpname = "ospar_polygon_wdpa_simplified.shp"
maskname = "MPA_Mask.nc"
print_shapefile_info(shpname)
f = addfile("SST1.nc","r")
var = f->time(0)
var at lat2d = f->LAT
var at lon2d = f->LON
opt = True
opt at return_mask = True
mask_array = shapefile_mask_data(var, shpname, opt)
mask_array!0 = "y"
mask_array!1 = "x"
mask_array at coordinates = "LAT LON"
system("rm -f " + maskname)
fout = addfile(maskname,"c")
fout->mask_array = mask_array
fout->LAT = f->LAT
fout->LON = f->LON
Unfortunately I get the following error message halfway through:
mask_array = shapefile_mask_data(var, shpname, opt)
(0) shapefile_mask_data: Error: not a valid rectilinear, curvilinear, or uns
tructured grid
Does anyone have any ideas as to why this happens? I’ve attached the relevant data to this email (hoping that it will send through).
Many thanks,
Josh
Sent from Mail<https://go.microsoft.com/fwlink/?LinkId=550986> for Windows 10
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20190716/1eaf542f/attachment.html>
More information about the ncl-talk
mailing list