On Tue, Jun 28, 2011 at 03:00:47PM -0400, Christian Guirreri wrote: > OK works- thanks. > > So I'm learning now about the difference between what MapShaper does and > what ST_Stimplify does. Is there any way to make sure that simplified > boundary lines will match other boundary lines? i.e. even the smallest > simplifications (like 0.05) produces very visible gaps between adjacent > districts.
What you could do is convert your layer to a topological representation, simplify each edge of the topology and then convert back to simple features. I'm looking for a sponsor to make the first part easier. Second part is easy already. If you're unfamiliar with postgis topology, here's a presentation I gave in Paris last week: http://strk.keybit.net/projects/postgis/Paris2011_TopologyWithPostGIS_2_0.pdf And, there's info on the wiki too. Another approach could be using ST_Snap to snap each simplified geometry against the collected vertices of each previously simplified one falling within a slightly enlarged bounding box of the geometry you're simplifying. --strk; > On Tue, Jun 28, 2011 at 1:12 PM, Sandro Santilli <[email protected]> wrote: > > > Christian, > > I suggest you create a new geometry field w/out enforcing type constraints > > on it, write the simplified version in there and then see what you get. > > > > --strk; > > > > On Tue, Jun 28, 2011 at 12:15:13PM -0400, Christian Guirreri wrote: > > > Same error. Tried both Polygon and Multipolygon. I'm not sure which the > > > Tiger Data is. > > > > > > On Tue, Jun 28, 2011 at 11:41 AM, Ben Madin > > > <[email protected]>wrote: > > > > > > > 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 < > > > > [email protected]> 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@postgis.**refractions.net< > > [email protected]> > > > >> http://postgis.refractions.**net/mailman/listinfo/postgis-**users< > > http://postgis.refractions.net/mailman/listinfo/postgis-users> > > > >> > > > > > > > > _______________________________________________ > > > > postgis-users mailing list > > > > [email protected] > > > > http://postgis.refractions.net/mailman/listinfo/postgis-users > > > > > > > > > > > > > > > > _______________________________________________ > > > > postgis-users mailing list > > > > [email protected] > > > > http://postgis.refractions.net/mailman/listinfo/postgis-users > > > > > > > > > > > > > _______________________________________________ > > > postgis-users mailing list > > > [email protected] > > > http://postgis.refractions.net/mailman/listinfo/postgis-users > > > > > > -- > > > > () Free GIS & Flash consultant/developer > > /\ http://strk.keybit.net/services.html > > > _______________________________________________ > postgis-users mailing list > [email protected] > http://postgis.refractions.net/mailman/listinfo/postgis-users -- () Free GIS & Flash consultant/developer /\ http://strk.keybit.net/services.html _______________________________________________ postgis-users mailing list [email protected] http://postgis.refractions.net/mailman/listinfo/postgis-users
