[postgis-users] exterior rings in multipolygons

Mr. Puneet Kishor punk.kish at gmail.com
Tue Jul 26 14:56:54 PDT 2011


On Jul 26, 2011, at 4:15 PM, Sandro Santilli wrote:

> On Tue, Jul 26, 2011 at 03:16:09PM -0500, Mr. Puneet Kishor wrote:
> 
>> So, as advised, I got a real pencil and paper, drew out all my options, scanned them in, and discovered that I had a poor understanding on the relationship of MULTIPOLYGONs and GEOMETRIES. Turns out, my MULTIPOLYGON has 1 GEOMETRY, 4 rings, one being exterior and three interior rings. Hence, an expression like the following works well
>> 
>> 	ST_NumPoints(ST_InteriorRingN(ST_GeometryN(the_geom, 1), 2))
> 
> Good job !
> 
>> Now, here is where it gets interesting. My test feature in reality is a lot more complicated, as can be seen in the attached image (see the blue bordered multipoly). I took the shapefile and shp2pgsql-ed it, and now I get only 4 rings in my query. My guess is that these four rings are the ones on the top of the image. So, I thought maybe I have another GEOMETRY that I am missing out on. But, no... ST_NumGeometries(the_geom) = 1.
>> 
>> Can anyone theorize what happened to the rest of the feature? How did it get lost in translation? Was it simply ignored, or was it made into a different feature? Or, is it there, but I still haven't understood the MULTIPOLYGON/GEOMETRY/POLYGON/LINERSTRING nexus really well.
> 
> Could be a bug in shp2pgsql ... did it tell you anything interesting
> at load time ?


Nope, not a single error. Went through like (as an ex-boss used to say) shit through goose.

I did try shp2pgsql with the -S (force simple geometries) switch, but it croaked saying it can't proceed because there are multipolygons, so I went with default.

The number of rows in the table are exactly the same as in the shapefile are exactly the same as in the Arc mxd (from where all this started). So, seems like everything came through at the feature level.


> Do you have the shapefile published somewhere to look at ?
> 

hmmm... not really. It is 200 MB, so I can't really post the file anywhere. Hey, perhaps I can export only this poly (although, I believe there are many more like this), and maybe I can post that. Let me see.

Puneet.


More information about the postgis-users mailing list