[postgis-users] Noob request - using ST_SimplifyPreserveTopology() on Tiger Data

Ben Madin lists at remoteinformation.com.au
Tue Jun 28 08:41:57 PDT 2011


Christian,

My guess here is that because you've told the geometry to be a MULTIPOLYGON, but you may have returned a POLYGON, you have indeed violated the check constraint on the geometry type.

try using st_multi() to get around it, as in :

> update public.tl_2010_us_cd111 set simple_geom = ST_Multi(ST_SimplifyPreserveTopology(the_geom, 15));

cheers

Ben



On 28/06/2011, at 11:23 PM, Christian Guirreri wrote:

> I get the following error:
> ERROR: new row for relation "tl_2010_us_cd111" violates check constraint "enforce_geotype_simple_geom"
> SQL state: 23514
> 
> Here's my SQL:
> select addGeometryColumn('public', 'tl_2010_us_cd111', 'simple_geom', 4326, 'MULTIPOLYGON', 2);
> update public.tl_2010_us_cd111 set simple_geom = ST_SimplifyPreserveTopology(the_geom, 15);
> 
> 
> On Mon, Jun 27, 2011 at 2:07 PM, Stephen Woodbridge <woodbri at swoodbridge.com> wrote:
> On 6/27/2011 1:37 PM, Christian Guirreri wrote:
> I'm trying to do something fairly simple. I'd like to take the Tiger
> 2010 Data - tl_2010_us_cd111 and tl_2010_us_county10 - and create shape
> files that are considerably smaller and more simplified. In the past
> I've just used MapShaper and been OK with that, but I was having trouble
> uploading tl_2010_us_county10 into it and I've decided its time to learn
> some GIS basics anyway.
> 
> I've definitely successfully setup my environment - PostegreSQL 9 with
> PostGIS. I've used the shp2pgsql wizard included with pgadmin to import
> the data sets into their own databases, without the "Load Geography
> column" checked. I've been able to export this data back to shp
> using pgsql2shp and view the resulting shp in QuantumGIS and ACDSee Canvas.
> 
> But when it comes to simplification - I'm not sure where to even
> start. I'm no database expert beyond some simple mysql so GIS is
> especially overwhelming. I only know that I want to
> use ST_SimplifyPreserveTopology() as I'm fairly certain a number of
> things will disappear if I don't.
> 
> Would love if someone could provide me with the SQL to make this happen!
> 
> First you should understand that ST_SimplifyPreserveTopology() works on a single geometry at a time and not on multiple geometries in a coverage. The difference is in a coverage the the polygons that share a common edge that is simplified would continue to have a common simplified edge. When polygons are simplified individually with knowledge of the adjacent polygons it is possible for gaps and overlaps to occur along the simplified edge. ST_SimplifyPreserveTopology() is designed to try and minimize these effects but there are no guarantees.
> 
> You might try something like:
> 
> select addGeometryColum('myschema', 'mytable', 'simple_geom', 4326, 'MULTIPOLYGON', 2);
> update myschema.mytable set simple_geom = ST_SimplifyPreserveTopology(the_geom, <tolerance>);
> 
> where <tolerance> is replaces by an appropriate value. This will depend on the some trial and error. The above assume srid=4326 which is probably not a good projection for doing simplification so you might want to project your data into some other UTM or Mercator projection depending on your coverage area and tolerance needs to be set with respect to those units.
> 
> -Steve W
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
> 
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20110628/24bef2ea/attachment.html>


More information about the postgis-users mailing list