[ncl-talk] creating netcdf mask from shapefile
Mary Haley
haley at ucar.edu
Fri Nov 17 15:49:35 MST 2017
This is a resolution email to this question.
Amy and I took this conversation offline, and the main issue was that we
needed the "tresh_ease23.prj" file in order for the lat/lon values on the
shapefile to be calculated correctly.
Once we had this resolved, I modified the functions in the
shapefiles_21.ncl example to allow you to mask data using shapefile ids
(integers) as well as strings.
See the attached image, which was created by masking the original data
against all polygons on the shapefile where "tresh" was equal to 1.
The panel_plot.png image shows the original data and the masked data.
The shapefile areas are outlined in black, with the shapefile masking area
of interest outlined in a thicker purple line.
The mask_data_plot.png image shows the same masked data plot, but with the
location of the data's lat/lon grid drawn as red dots where it fell outside
the shapefile area of interest, and in black inside the area of interest.
--Mary
On Fri, Oct 27, 2017 at 6:10 PM, Mary Haley <haley at ucar.edu> wrote:
> Hi Amy,
>
> In order to properly read shapefiles, we need the tresh_ease23.shx and
> tresh_ease23.dbf files as well
> .
>
>
> Also, I didn't see the
>
> data_stats_2d_cmap.nc
>
> file attached to your email. Can you upload this file and the other
> tresh_eas23.xxx files to ftp.cgd.ucar.edu?
>
> Thanks,
>
> --Mary
>
>
> On Fri, Oct 27, 2017 at 4:58 PM, Amy Hendricks <ashendricks at alaska.edu>
> wrote:
> >
> > Hello again NCL magicians,
> >
> > As per requested, I have uploaded the shapefile "tresh_ease23.shp" to
> the incoming directory and attached the script. The script is basically
> example #21 modified with my inputs. The script recognizes the shapefile
> and data, but doesn't plot like the examples, or write the mask (the data
> are all missing values). I'm looking to create a netcdf mask of just the
> Treshnikov region 1 (East Bering). Please help!
> >
> > Thank you,
> >
> > Amy
> >
> >
> >
> > On Fri, Oct 27, 2017 at 2:56 PM, Amy Hendricks <ashendricks at alaska.edu>
> wrote:
> >>
> >> Hello again NCL magicians,
> >>
> >> As per requested, I have uploaded the shapefile "tresh_ease23.shp" to
> the incoming directory and attached the script and data file to be masked.
> The script is basically example #21 modified with my inputs. The script
> recognizes the shapefile and data, but doesn't plot like the examples, or
> write the mask (the data are all missing values). I'm looking to create a
> netcdf mask of just the Treshnikov region 1 (East Bering). Please help!
> >>
> >> Thank you,
> >>
> >> Amy
> >>
> >>
> >>
> >> On Thu, Oct 26, 2017 at 4:17 PM, Amy Hendricks <ashendricks at alaska.edu>
> wrote:
> >>>
> >>> Howdy NCL experts,
> >>>
> >>> I'm trying to create a netcdf mask from a shapefile, however, the
> shape names are integers. All of the examples on the shapefiles examples
> page show how to mask with string shape names -- how do I convert the
> integer shape names to strings for creating a mask?
> >>>
> >>> Cheers,
> >>>
> >>> Amy
> >>>
> >>
> >>
> >>
> >> --
> >> Amy Hendricks
> >> Graduate Research Assistant
> >> Department of Atmospheric Sciences
> >> University of Alaska Fairbanks
> >> IARC 343-R
> >> 907-388-9893 <(907)%20388-9893>
> >> ashendricks at alaska.edu
> >
> >
> >
> >
> > --
> > Amy Hendricks
> > Graduate Research Assistant
> > Department of Atmospheric Sciences
> > University of Alaska Fairbanks
> > IARC 343-R
> > 907-388-9893 <(907)%20388-9893>
> > ashendricks at alaska.edu
> >
> > _______________________________________________
> > ncl-talk mailing list
> > ncl-talk at ucar.edu
> > List instructions, subscriber options, unsubscribe:
> > http://mailman.ucar.edu/mailman/listinfo/ncl-talk
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20171117/d9922064/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: tresh21_mod.ncl
Type: application/octet-stream
Size: 7502 bytes
Desc: not available
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20171117/d9922064/attachment-0002.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: masked_data_plot.png
Type: image/png
Size: 341743 bytes
Desc: not available
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20171117/d9922064/attachment-0002.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: panel_plot.png
Type: image/png
Size: 126844 bytes
Desc: not available
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20171117/d9922064/attachment-0003.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: shapefile_utils.ncl
Type: application/octet-stream
Size: 19859 bytes
Desc: not available
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20171117/d9922064/attachment-0003.obj>
More information about the ncl-talk
mailing list