[postgis-users] Problem importing SHP polygons

Conrad Bielski conrad_bielski at yahoo.com
Fri Apr 3 03:36:34 PDT 2015


Hello Everyone,just wanted to thank you for your help. The issue was fixed and I just wanted to describe what actually was the problem.
Basically, this was the issue: 
This indeed returns one problem: The big polygon its outer shell apparently intersects at one place (which is allowed in shapefile, but not in OGC SFS geometries as implemented in PostGIS). So, the solution that I chose to apply was to buffer the geometries when ingesting them into PostGIS.
Happy Easter!Conrad
      From: Mark Wynter <mark at dimensionaledge.com>
 To: "postgis-users at lists.osgeo.org" <postgis-users at lists.osgeo.org> 
 Sent: Thursday, March 19, 2015 9:17 PM
 Subject: Re: [postgis-users] Problem importing SHP polygons
   
If Mark's suggestion doesn't fix it... 

sounds like the imported geometries in PostGIS are not valid - possibly due to self intersections and on occasions polygons with zero areas that appear like linestrings - something not uncommon when converting rasters to vectors.

run some checks on your imported geometries, like
st_isvalid, st_area, geometrytype.

Depending on what you find, you can develop a set of cleaning steps like

St_makevalid, st_buffer(,0),
where geometrytype in(multi polygon,polygon) etc.



> Message: 5
> Date: Thu, 19 Mar 2015 09:40:07 +0000
> From: Mark Cave-Ayland <mark.cave-ayland at ilande.co.uk>
> To: Conrad Bielski <conrad_bielski at yahoo.com>,    PostGIS Users
>    Discussion <postgis-users at lists.osgeo.org>
> Subject: Re: [postgis-users] Problem importing SHP polygons
> Message-ID: <550A9977.3000400 at ilande.co.uk>
> Content-Type: text/plain; charset=windows-1252
> 
>> On 10/03/15 14:48, Conrad Bielski wrote:
>> 
>> Hi,
>> I'm having a curious issue importing a polygon SHP file into PostGIS.
>> I'll describe the procedure that I'm using and the problem that I'm
>> having and hopefully somebody has had this issue in the past and fixed it.
>> 
>> So the procedure is that I use GRASS to produce a vector from a raster
>> output: (r.to.vect input=MASK output=vecMap feature=area)  and then
>> export to SHP file (v.out.ogr -c -e input=vecMap dsn=fname
>> format=ESRI_Shapefile type=area).
>> 
>> Now when this SHP file is imported into PostGIS, the type is changed to
>> multistring for some reason. Then when checking the topology, there is a
>> 'ring self-intersection' error. This PostGIS db is then imported into
>> GeoServer, where lines are connecting between different parts of the
>> largest polygon (this should not be happening). If I fix this typology
>> problem, then the largest polygon in the db disappears.
>> 
>> The strange thing is the following:
>> 1. Opening the SHP file in QGIS doesn't have this problem
>> 2. Importing the SHP file directly into GeoServer, doesn't generate this
>> problem either.
>> 
>> Why is PostGIS having an issue importing this file?
>> 
>> Any ideas how to fix this?
>> 
>> Thanks in advance for your help,
>> Conrad
> 
> Hi Conrad,
> 
> Have you tried disabling the MULTI conversion code in shp2pgsql (add -S
> option to the command line) to see if that helps
_______________________________________________
postgis-users mailing list
postgis-users at lists.osgeo.org
http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users


  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20150403/6c824ed0/attachment.html>


More information about the postgis-users mailing list