<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">G'day Puneet,<div><br></div><div>I've attached a picture of what I see - 280.shp is in fact two polygons - the top one is 280 and the bottom one 531. The numbers in black are the shapefile, those in red the postgis connection.</div><div><br></div><div><img height="399" width="640" apple-width="yes" apple-height="yes" id="6f550739-4cb1-4c17-85e8-c2753c21d43d" src="cid:8A762215-EC1D-428A-8656-3AAEF0AF907C"></div><div>I ran shp2pgsql (RCSID: $Id: shp2pgsql-core.h 5983 2010-09-19 11:27:05Z mcayland $ RELEASE: 1.5 USE_GEOS=1 USE_PROJ=1 USE_STATS=1) :</div><div><br></div><div><div><font class="Apple-style-span" face="'Courier New'">warrambat:~$ shp2pgsql 280/280.shp public.pun | psql gms</font></div><div><font class="Apple-style-span" face="'Courier New'">Shapefile type: Polygon</font></div><div><font class="Apple-style-span" face="'Courier New'">Postgis type: MULTIPOLYGON[2]</font></div><div><font class="Apple-style-span" face="'Courier New'">SET</font></div><div><font class="Apple-style-span" face="'Courier New'">SET</font></div><div><font class="Apple-style-span" face="'Courier New'">BEGIN</font></div><div><font class="Apple-style-span" face="'Courier New'">NOTICE:  CREATE TABLE will create implicit sequence "pun_gid_seq" for serial column "pun.gid"</font></div><div><font class="Apple-style-span" face="'Courier New'">NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "pun_pkey" for table "pun"</font></div><div><font class="Apple-style-span" face="'Courier New'">CREATE TABLE</font></div><div><font class="Apple-style-span" face="'Courier New'">                   addgeometrycolumn                   </font></div><div><font class="Apple-style-span" face="'Courier New'">-------------------------------------------------------</font></div><div><font class="Apple-style-span" face="'Courier New'"> public.pun.the_geom SRID:-1 TYPE:MULTIPOLYGON DIMS:2 </font></div><div><font class="Apple-style-span" face="'Courier New'">(1 row)</font></div><div><font class="Apple-style-span" face="'Courier New'"><br></font></div><div><font class="Apple-style-span" face="'Courier New'">INSERT 0 1</font></div><div><font class="Apple-style-span" face="'Courier New'">INSERT 0 1</font></div><div><font class="Apple-style-span" face="'Courier New'">COMMIT</font></div><div><br></div><div>and I then tried your other query:</div><div><br></div><div><div><div><font class="Apple-style-span" face="'Courier New'">gms=# select objectid, ST_NumPoints(ST_InteriorRingN(ST_GeometryN(the_geom, 1), 2)) from pun;</font></div><div><font class="Apple-style-span" face="'Courier New'"> objectid | st_numpoints </font></div><div><font class="Apple-style-span" face="'Courier New'">----------+--------------</font></div><div><font class="Apple-style-span" face="'Courier New'">      280 |           42</font></div><div><font class="Apple-style-span" face="'Courier New'">      531 |           52</font></div><div><font class="Apple-style-span" face="'Courier New'">(2 rows)</font></div><div><br></div><div>and for my own interest:</div><div><br></div><div><br></div><div><font class="Apple-style-span" face="'Courier New'">gms=# select objectid, st_summary(the_geom) from pun;</font></div><div><font class="Apple-style-span" face="'Courier New'"> objectid |           st_summary            </font></div><div><font class="Apple-style-span" face="'Courier New'">----------+---------------------------------</font></div><div><font class="Apple-style-span" face="'Courier New'">      280 |                                +</font></div><div><font class="Apple-style-span" face="'Courier New'">          | MultiPolygon[B] with 1 elements+</font></div><div><font class="Apple-style-span" face="'Courier New'">          |   Polygon[] with 4 rings       +</font></div><div><font class="Apple-style-span" face="'Courier New'">          |    ring 0 has 496 points       +</font></div><div><font class="Apple-style-span" face="'Courier New'">          |    ring 1 has 242 points       +</font></div><div><font class="Apple-style-span" face="'Courier New'">          |    ring 2 has 42 points        +</font></div><div><font class="Apple-style-span" face="'Courier New'">          |    ring 3 has 108 points       +</font></div><div><font class="Apple-style-span" face="'Courier New'">          | </font></div><div><font class="Apple-style-span" face="'Courier New'">      531 |                                +</font></div><div><font class="Apple-style-span" face="'Courier New'">          | MultiPolygon[B] with 1 elements+</font></div><div><font class="Apple-style-span" face="'Courier New'">          |   Polygon[] with 21 rings      +</font></div><div><font class="Apple-style-span" face="'Courier New'">          |    ring 0 has 706 points       +</font></div><div><font class="Apple-style-span" face="'Courier New'">          |    ring 1 has 42 points        +</font></div><div><font class="Apple-style-span" face="'Courier New'">          |    ring 2 has 52 points        +</font></div><div><font class="Apple-style-span" face="'Courier New'">          |    ring 3 has 47 points        +</font></div><div><font class="Apple-style-span" face="'Courier New'">          |    ring 4 has 38 points        +</font></div><div><font class="Apple-style-span" face="'Courier New'">          |    ring 5 has 106 points       +</font></div><div><font class="Apple-style-span" face="'Courier New'">          |    ring 6 has 47 points        +</font></div><div><font class="Apple-style-span" face="'Courier New'">          |    ring 7 has 60 points        +</font></div><div><font class="Apple-style-span" face="'Courier New'">          |    ring 8 has 65 points        +</font></div><div><font class="Apple-style-span" face="'Courier New'">          |    ring 9 has 45 points        +</font></div><div><font class="Apple-style-span" face="'Courier New'">          |    ring 10 has 42 points       +</font></div><div><font class="Apple-style-span" face="'Courier New'">          |    ring 11 has 43 points       +</font></div><div><font class="Apple-style-span" face="'Courier New'">          |    ring 12 has 51 points       +</font></div><div><font class="Apple-style-span" face="'Courier New'">          |    ring 13 has 81 points       +</font></div><div><font class="Apple-style-span" face="'Courier New'">          |    ring 14 has 84 points       +</font></div><div><font class="Apple-style-span" face="'Courier New'">          |    ring 15 has 53 points       +</font></div><div><font class="Apple-style-span" face="'Courier New'">          |    ring 16 has 70 points       +</font></div><div><font class="Apple-style-span" face="'Courier New'">          |    ring 17 has 59 points       +</font></div><div><font class="Apple-style-span" face="'Courier New'">          |    ring 18 has 165 points      +</font></div><div><font class="Apple-style-span" face="'Courier New'">          |    ring 19 has 51 points       +</font></div><div><font class="Apple-style-span" face="'Courier New'">          |    ring 20 has 52 points       +</font></div><div><font class="Apple-style-span" face="'Courier New'">          | </font></div><div><font class="Apple-style-span" face="'Courier New'">(2 rows)</font></div></div></div><div><br></div><div>I hope this helps somewhat. </div><div><br></div><div><div>On 27/07/2011, at 1:01 PM, Mr. Puneet Kishor wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div 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><span><280_error.png></span></div>_______________________________________________<br>postgis-users mailing list<br><a href="mailto:postgis-users@postgis.refractions.net">postgis-users@postgis.refractions.net</a><br>http://postgis.refractions.net/mailman/listinfo/postgis-users<br></blockquote></div><br></div></body></html>