[ncl-talk] segments in shape must be closed circle?
Mary Haley
haley at ucar.edu
Tue Dec 27 08:29:25 MST 2016
Yongli,
gc_inout will automatically close the polygon for you, so there's no need
to do this yourself.
See the description under:
http://www.ncl.ucar.edu/Document/Functions/Built-in/gc_inout.shtml
--Mary
On Thu, Dec 22, 2016 at 7:26 PM, Sitan Heyl <heylsitan at gmail.com> wrote:
> Hi, All
>>
>> When I read the example 13 about shapefile (https://www.ncl.ucar.edu/
>> Applications/shapefiles.shtml), I found one confused code as follow. my
>> question is that if one geometry has two or more segments, need every
>> segments be closed circle or polygon, if not, how can this code directly
>> determine gc_inout in every segments?
>
> ;---Some Georgia counties have multiple segments
> startSegment = geometry(ga_counties(i), geom_segIndex)
> numSegments = geometry(ga_counties(i), geom_numSegs)
> do seg=startSegment, startSegment+numSegments-1
> startPT = segments(seg, segs_xyzIndex)
> endPT = startPT + segments(seg, segs_numPnts) - 1
>
> ;---Loop through each point on data grid and see if it's in this county.
> do n=0,nii_latlon-1
> nn = ii_latlon(n) ; Get index of point we're checking
> ;
> ; This "if" statement speeds up code, by making sure we don't
> ; needlessly check a lat/lon point if:
> ;
> ; - we've already found it in another county
> ; - it doesn't fall within the general lat/lon box that covers this county
> ;
> if(skip_check(nn).or.\
> lat1d(nn).lt.min(lat(startPT:endPT)).or.\
> lat1d(nn).gt.max(lat(startPT:endPT)).or.\
> lon1d(nn).lt.min(lon(startPT:endPT)).or.\
> lon1d(nn).gt.max(lon(startPT:endPT)))
> continue
> end if
>
> ;---Here's the check if the point is in the county.
> if(gc_inout(lat1d(nn),lon1d(nn),\
> lat(startPT:endPT),lon(startPT:endPT))) then
> data_mask_1d(nn) = 1 ; This point is inside this county
> skip_check(nn) = 1 ; Don't check this point again
> end if
> end do
>
> end do ; End of collecting points for this county
>
> Best,
> Yongli
>
> _______________________________________________
> 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/20161227/efa4eeda/attachment.html
More information about the ncl-talk
mailing list