Re: Shapefile masking

From: Karin Meier-Fleischer <meier-fleischer_at_nyahnyahspammersnyahnyah>
Date: Wed Jul 09 2014 - 03:21:11 MDT

Hi Mattias,

the shapefile_mask_data.ncl uses the new reassign capability of NCL
version 6.1.2. To reassign a
variable the reassignment operator ':=' is used. If you set a variable
in the command line once
everything will be ok, but inside a loop with changing sizes of the
variable it won't work.

For older NCL versions: you have to delete the variables first before
reusing them again, e.g

          do ....
             ....
             lat_sub := lat(startPT:endPT) (since NCL version 6.1.2)
             lon_sub := lon(startPT:endPT)
             ....
          end do

-->

          do ....
             ....

             lat_sub = lat(startPT:endPT)
             lon_sub = lon(startPT:endPT)
             ....
             delete([/lat_sub,lon_sub]/) (before NCL version 6.1.2)
          end do


I would recommend to use the new version 6.2.0 of NCL to be able to use
the reassignment
operator and to take advantage of *'Significant improvements to the
speed of drawing
shapefile polylines or polygons*'.

Hope this helps,
Karin


Am 09.07.14 02:17, schrieb Mattias Cape:
> Shapefile masking Hi,
>
> I've been working on datasets using some of the examples available at
>
> http://www.ncl.ucar.edu/Applications/shapefiles.shtml
>
> In particular I've been trying to use shapefile_mask_data to create
> masks based on a shapefile (as in example mask_12.ncl). I've attached
> a portion of the code that is causing me problems (mask_test.ncl). One
> thing to note is that I created a new version of the
> shapefile_mask_data.ncl (
> http://www.ncl.ucar.edu/Applications/Scripts/shapefile_mask_data.ncl )
> file to get it to run, with := statements replaced with = as the
> original version did not run on my system (NCL 6.1.0)
>
> When I ran mask_test.ncl NCL returned the following error:
>
> ----------------------------------------------------------------------------------------------------------------------------------------
> Variable: f
> Type: file
> File path : moa_coastline_extend_polygon.shp
>
> Number of global attributes : 5
> Number of dimensions : 3
> Number of groups : 61
> Number of variables : 2
> (0) polygon
> ERROR 10: Pointer 'hFeat' is NULL in 'OGR_F_GetGeometryRef'.
>
> ERROR 10: Pointer 'hGeom' is NULL in 'OGR_G_GetGeometryCount'.
>
> ERROR 10: Pointer 'hGeom' is NULL in 'OGR_G_GetPointCount'.
>
> ERROR 10: Pointer 'hGeom' is NULL in 'OGR_G_Transform'.
>
> fatal:["Execute.c":5570]:variable (geometry) is not in file (f)
> fatal:["Execute.c":7556]:Execute: Error occurred at or near line 166
> in file $NCARG_ROOT/lib/ncarg/nclscripts/shapefile_mask_data_mrc.ncl
>
> fatal:["Execute.c":7556]:Execute: Error occurred at or near line 44 in
> file mask_test.ncl
> ----------------------------------------------------------------------------------------------------------------------------------------
>
> However when I ran commands line by line in NCL I was able to get
> geometry information from the shapefile:
>
> ----------------------------------------------------------------------------------------------------------------------------------------
> ncl 4> shpfile = "moa_coastline_extend_polygon.shp"
> ncl 5> f=addfile(shpfile,"r")
> ncl 6> segments=f->segments
> ncl 7> geometry=f->geometry
> ncl 8> printVarSummary(geometry)
>
> Variable: geometry
> Type: integer
> Total Size: 488 bytes
> 122 values
> Number of Dimensions: 2
> Dimensions and sizes: [num_features | 61] x [geometry | 2]
> Coordinates:
> Number Of Attributes: 0
> ----------------------------------------------------------------------------------------------------------------------------------------
>
> What might be the reason for the error above? Any advice on what
> specifically to check? And on a related note, what does := mean in
> shapefile_mask_data.ncl?
>
> I've put the datasets on google drive at
> https://drive.google.com/folderview?id=0B1DkMk0Gv63vTzlPcldHeGRSbVE&usp=drive_web
>
> Thank you for your time.
>
> Mattias
> --
> PhD Candidate
>
> University of California, San Diego
> Scripps Institution of Oceanography
> 9500 Gilman Drive MC 0208
> La Jolla, California 92093-0208
>
> Sverdrup Hall 2127
> Tel (office): (858) 534-9527
>
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk


_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk


Received on Wed Jul 09 09:21:28 2014

This archive was generated by hypermail 2.1.8 : Wed Jul 23 2014 - 15:33:46 MDT