[ncl-talk] problem with masking from shape file

Mary Haley haley at ucar.edu
Mon Jun 12 14:20:32 MDT 2017


Francesco,

If I understand your question, I think the issue is because the shapefile
you provided has just a single outline, which is the whole outline of the
Caspian Sea. There are no individual outlines for those little isles, so
there's no way for the shapefile masking routine to know that you don't
want data over those areas.

The "GSHHS_h_L1_mysect.shp" shapefile, however, does seem to have the
outlines for the isles, so you can use this to further mask your data.

What I suggest is to first mask your data based on the GSHHS_h_caspSea
shapefile, and then mask that masked data against the "mysect_L2" file, but
set the "keep" option to False so it throws away the values over the Isles.
​ Something like this:

  dir                = "caspSea/"
  caspian_shape_name = "GSHHS_h_caspSea.shp"     ; contains single outline
of Caspian Sea
  isles_shape_name   = "GSHHS_h_L1_mysect.shp"   ; contains several
outlines if isles inside Caspian Sea

  opt      = True
  opt at keep = True   ; Keep values inside this
​outline
  data_mask_casp = shapefile_mask_data(data,caspian_shape_name,opt)

  opt at keep = False
​  ; Throw away values inside these outlines​
  data_mask_isles = shapefile_mask_data(data_mask_casp,isles_shape_name,opt)
​

​I created an example for you using dummy data. See shapefiles_22.ncl at:

http://www.ncl.ucar.edu/Applications/shapefiles.shtml#ex22​

--Mary




On Mon, Jun 12, 2017 at 11:47 AM, Francesco Trotta <
francesco.trotta4 at unibo.it> wrote:

> Dear ncl-Team
>    I’m using the coastline of NOAA (GSHHS_h_caspSea.shp) (I've upload it
> in the ftp) and I would like to generate the meshmask from the costline and
> to mask the bathymetry datasets outside the coastline (landPoint) in the
> region of Caspian Sea.
>    I found the ncl Built-in functions 'create_mask_from_shapefile' and I
> tried to use it in this way:
>
> //=========================
>    mask2dtCoast_surf(0:ny(inest)-1,0:nx(inest)-1) = \
>              create_mask_from_shapefile(bathy(0:ny(inest)-1,0:nx(
> inest)-1),pathfile_regriddataCoastline)
>
>    ;--- Mashera bathy(dentro o fuori la costline)
>    do iy=0,ny(inest)-1
>       do ix=0,nx(inest)-1
>          ;if(mask2dtCoast_surf(iy,ix) .eq. 0) then
>          ;   bathy(iy,ix) = 0.
>          ;end if
>          if(mask2dtCoast_surf(iy,ix) .eq. 1) then
>             bathy(iy,ix) = 0.
>          end if
>       end do
>    end do
>    ;print(bathy)
> //============================
>
> but the bathymetry inside the caspian sea, where there are isle, are not
> masked (attachment).
> Why? Is this function a good choice in order to work with shapfile?
>
> thanks
> Francesco
>
>
>
> _______________________________________________
> 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/20170612/1f7497b9/attachment.html 


More information about the ncl-talk mailing list