4

I've been reading a number of related threads about ST_Union, ST_SnapToGrid and ST_Dump but I haven't been able to solve my problem.

The problem is I am trying to merge Tiger/line census tracts that have been simplified but I get gaps where the tracts aren't flush. I simplified the tracts with ST_SimplifyPreserveTopology(geom, .0003) and I'm running ST_Union(ST_SnapToGrid(geom, .00001)) but I still get gaps. I've also tried using ST_SnapToGrid around of the initial simplification but I don't see a difference. I've also tried wrapping ST_Dump around the Union but I don't see a difference there either.

I thought ST_ExteriorRing was promising but my GROUP BY creates three concentric polygons (doughnuts) and ST_ExteriorRing seems to create three overlapping circles. Unless I'm doing something wrong.

I'm outputting my query as geojson and putting that on a leaflet map. Here is what those gaps look like at different zoom levels.

enter image description here enter image description here enter image description here

If anyone has any ideas on making a gapless polygon of census tracts under 80mb I'm all ears.

mhkeller
  • 181
  • 5
  • 1
    You could use PostGIS topology (http://postgis.org/docs/Topology.html) . First create topology from your data, then simplify. I have not used it , but i theory i should work – simpleuser001 Sep 18 '13 at 06:46
  • Can you visualize those donuts/circles with something like OpenJUMP/QGIS? I'd be really helpful to see what's the actual problem. Also you can take a look at: http://gis.stackexchange.com/questions/60655/polygon-to-fill-gap/60672#60672 – Jakub Kania Sep 18 '13 at 12:24
  • Photos added. I'll follow this topology tutorial if this is the process you're referring to? http://strk.keybit.net/blog/2012/04/13/simplifying-a-map-layer-using-postgis-topology/ – mhkeller Sep 18 '13 at 14:33
  • I keep getting a relation "topology" does not exist error when trying to do topology.toTopoGeom() and my results shapefile has 0 rows. The other topology functions work, though. This is the starting shapefile http://www2.census.gov/geo/tiger/TIGER2010DP1/Tract_2010Census_DP1.zip – mhkeller Sep 19 '13 at 20:30
  • Topology support is added as a separate extension. You must have "base" PostGIS but not topology. Check the docs at http://postgis.org/docs/postgis_installation.html, but it could be as easy as CREATE EXTENSION postgis_topology; – Lee Hachadoorian Nov 23 '13 at 16:45

3 Answers3

2

I found a much easier way to simplify a shapefile while preserving its topology by using the node.js command-line library mapshaper https://github.com/mbloch/mapshaper. You could also use topojson on the command line https://github.com/mbostock/topojson/wiki/Command-Line-Reference, but that will output only in topojson. Mapshaper outputs to a variety of formats.

mhkeller
  • 181
  • 5
0

I know this can be done in ArcMap through the Align features tool...

http://resources.arcgis.com/en/help/main/10.1/index.html#//01m800000004000000

Not sure about PostGIS though.

Some other Arc alternatives which might have analogous functions in PostGIS

http://resources.arcgis.com/en/help/main/10.1/index.html#//01m600000012000000

Failing that if you get really desperate and if the final map will look something like the first, or even second picture you posted you might just make each concentric ring one colour, as opposed to two (eg shade of purple for a boundary, and another for the inside).

0

Have you tried converting your polygons to polylines? Select the outer edge and convert that back to a polygon. Presto, no gaps or slivers.

klewis
  • 7,475
  • 17
  • 19