[ncl-talk] segments in shape must be closed circle?
Sitan Heyl
heylsitan at gmail.com
Thu Dec 22 19:26:53 MST 2016
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20161223/67fef90e/attachment.html
More information about the ncl-talk
mailing list