ThinkGeo.com    |     Documentation    |     Premium Support

MULTIPOLYGON Help


I think this should create a hollowed out polygon. But it creates a solid polygon. How could I use Well-Known text tocreate a hollowed out shape? I know I can ceated 2 polygons and


.GetDifference which creates a MultiPolygonShape which is hollowed out but I am trying to use industry standard stuff.  Thanks

 


MULTIPOLYGON(((-21.875 10.625,21.875 10.625,21.875 -10.625,-21.875 -10.625,-21.875 10.625),(-20.625 9.375, 20.625 9.375,20.625 -9.375,-20.625 -9.375,-20.625 9.375)))




 



Bob,


Thanks for your post and question.
 
I think the reason for this is the Inner ring direction is not correct, try the following wkt, hope it is what we are expecting.
 
string wkt = "MULTIPOLYGON(((-21.875 10.625,21.875 10.625,21.875 -10.625,-21.875 -10.625,-21.875 10.625),(-20.625 9.375,-20.625 -9.375,20.625 -9.375,20.625 9.375,-20.625 9.375)))";
 
Any more questions just feel free to let me know.
 
Thanks.
 
Yale

So the outside has to go clockwise and the inner has to go counter clockwise?

Winding does not matter in a WKT, and that is not your issue in this example.  


To create a polygon with a hole, you just need to make a Polygon object... rather than a MultiPolygon object.   The object that you have created is two solid polygons, one overlying the other, and there is no hole defined.


A POLYGON is used to convey one exterior ring and zero or more holes, like:


POLYGON ( ( required exterior ring<exterior ring=""></exterior>) [ ,( optional interior ring<interior ring=""></interior>), (...) ] )


A MULTIPOLYGON is just a collection of polygons... so by having your final set of coordinates encased in double quotes, you were saying that they are the outer ring of a second polygon... rather than a hole in the first one.


To make your text work, just replace MULTIPOLYGON with POLYGON, and remove the opening and closing parentheses.


 



I'm sorry... I need glasses.   I misread your parentheses nesting.   I believe that what you have should have worked, except that it really should not be a MultiPolygon because you only have one polygon object.   I would still try switching to a Polygon and removing the outer set of parentheses.    I'm positive that Winding is not a requirement in WKT.   However, winding IS a requirement in things like Shapefiles, and some shapefile writers just assume an inbound WKT is wound correctly and pop it out.   But we display many polygons in ThinkGeo w/o regard to winding issues.


Sorry for the confusion.



Well FYI winding matters. I got the proper alignment by using a trick. I created two Polygons using OutterRing  and vertices then I got the difference which gave me a Multishape. Then I got the text which seems to indicate winding matters. Maybe their interpreter is based on the shapfiles? No matter it does work.

Bob and Ted, you are right. The winding ( ring order, clockwise or counter clockwise) does not matters in WKT according to the convention set by OGC to distinguish an outer ring from an inner ring. Yale got confused because of the winding requirements set by ESRI shapefiles. For a polygon with an inner ring, you simply use a Polygon, not a MultiPolygon. In addition, you have to be carefull about having invalid MultiPolygon and how to correct them as you can see in the following Code Community project Intersecting Multi Polygon.


code.thinkgeo.com/projects/show/intersectmultipoly