<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Jul 26, 2011, at 7:53 PM, Ben Madin wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div>Maybe you could share the polygon - does it pass tests like st_isvalid()?<br></div></blockquote><div><br></div>it does pass the ST_IsValid() test with flying colors, but the truth is... the entire poly never got imported. So, from ArcMap, I exported poly id 280 to a shapefile. Then I opened that shapefile in QGIS, and overlaid the same poly from the Pg table. See the attached image. The orange line is the poly 280 from Pg, and the green solid is the same poly 280 from the shapefile. Most of the poly is missing in the Pg version.</div><div><br></div><div>The shapefile can be downloaded from <a href="http://dl.dropbox.com/u/3526821/280.zip">http://dl.dropbox.com/u/3526821/280.zip</a></div><div><br></div><div><blockquote type="cite"><div><br>cheers<br><br>Ben<br><br><br>On 27/07/2011, at 4:16 AM, Mr. Puneet Kishor wrote:<br><br><blockquote type="cite"><br></blockquote><blockquote type="cite">On Jul 26, 2011, at 9:56 AM, Sandro Santilli wrote:<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><blockquote type="cite">On Tue, Jul 26, 2011 at 09:47:23AM -0500, Mr. Puneet Kishor wrote:<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite">On Jul 26, 2011, at 9:34 AM, Sandro Santilli wrote:<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite">On Tue, Jul 26, 2011 at 09:31:50AM -0500, Mr. Puneet Kishor wrote:<br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span class="Apple-tab-span" style="white-space:pre">       </span>ERROR:  function st_interiorringn(geometry) does not exist<br></blockquote></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite">Check your parens, the call above is missing a parameter (ring number).<br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite">That is a bit embarrassing. Yes, I had missed out on giving the ring number. However, still no luck --<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite">SELECT objectid, <br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span class="Apple-tab-span" style="white-space:pre">        </span>ST_NRings(the_geom) num_of_rings, <br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span class="Apple-tab-span" style="white-space:pre">       </span>ST_NumInteriorRings(the_geom) num_of_int_rings, <br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span class="Apple-tab-span" style="white-space:pre"> </span>ST_NumPoints(ST_ExteriorRing(ST_GeometryN(the_geom,1))) num_of_points_ext_ring,<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span class="Apple-tab-span" style="white-space:pre">  </span>ST_AsText(the_geom) wkt_feature, <br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span class="Apple-tab-span" style="white-space:pre">        </span>ST_AsText(ST_MakePolygon(ST_ExteriorRing(ST_GeometryN(the_geom, 1)))) wkt_ext_ring,<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span class="Apple-tab-span" style="white-space:pre">      </span>ST_AsText(ST_MakePolygon(ST_InteriorRingN(ST_GeometryN(the_geom, 2), 2))) wkt_int_ring_a,<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span class="Apple-tab-span" style="white-space:pre">        </span>ST_AsText(ST_MakePolygon(ST_GeometryN(the_geom, 2))) wkt_int_ring_b<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite">FROM table <br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite">WHERE objectid = 280;<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite">objectid: 280;<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite">num_of_rings: 4;<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite">num_of_int_rings: 3;<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite">num_of_points_ext_ring: 496;<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite">wkt_feature: "MULTIPOLYGON(((<1>),(<2>),(<3>),(<4>))";<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite">wkt_ext_ring: "POLYGON((<1>))";<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite">wkt_int_ring_a: "";<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite">wkt_int_ring_b: ""<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite">As you see, I tried to get the interior ring "n" two different ways. Not getting anywhere.<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">Write down a matrix of all combinations you tried.<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">Use real paper, and pencil.<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">Publish a scanned version.<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">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<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><span class="Apple-tab-span" style="white-space:pre">       </span>ST_NumPoints(ST_InteriorRingN(ST_GeometryN(the_geom, 1), 2))<br></blockquote><blockquote type="cite"><span class="Apple-tab-span" style="white-space:pre">   </span><br></blockquote><blockquote type="cite">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.<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">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.<br></blockquote><blockquote type="cite"><br></blockquote></div></blockquote></div><img height="356" width="711" apple-width="yes" apple-height="yes" id="251af39f-cd37-418c-ae0a-227fee3e9713" src="cid:44D19BEC-286E-40DE-82F5-420AAB528815"></body></html>