[Shapelib] Handling polygon rings in shapefiles

Brian Peschel brianp at occinc.com
Mon Oct 10 13:40:13 PDT 2005


I was hoping someone could give me some insight into how to handle 
polygon rings in shapefiles.....

I have looked at the ERSI spec.  It says a polygon feature (made up of 1 
or more parts) can have inner and outer rings.  And the outer ring is 
clockwise while the inner ring is counter clockwise.  It also says the 
order of the parts irrelevant.  I guess then I would have to look at the 
read shape to see if it is clockwise or counter clockwise to see if it 
is an inner or an outer.  A pain, but it works.

But then I also see that a polygon feature (made up of 1 or more parts) 
can have multiple outer rings.  Again, I can look at the 
clockwise/counter-clockwise to figure out if is an inner or outer ring.

But if I have multiple outer rings and multiple inner rings and the 
order doesn't matter, how do I figure out which inner ring goes with 
which outer ring?  Do I need to determine containment?

What if I have an outer ring containing and outer ring containing an 
inner ring?  How do I know which outer ring the inner ring is for?  The 
spec tells me a ring can not intersect, but it doesn't say anything that 
an outer ring can not contain an outer ring.

Any insight into this would be extremely helpful.  Any pointers on using 
the shapelib library to help with this will also be helpful.  Thanks in 
advance.

-- 
Brian Peschel





More information about the Shapelib mailing list