[Talk-us] What to do with unnamed NHD streams
mike at teczno.com
Mon Oct 29 07:03:33 GMT 2012
On Oct 28, 2012, at 11:41 PM, Paul Norman wrote:
>> From: Michal Migurski [mailto:mike at teczno.com]
>> Subject: Re: [Talk-us] What to do with unnamed NHD streams
>> On Oct 28, 2012, at 10:29 PM, Paul Norman wrote:
>>> The problem is you need to convert to .osm and *then* simplify. If you
>>> do this in the other order you have problems where one object
>>> intersects another (e.g. because they share a geometry for a portion
>>> of them). You end up simplifying away the intersection points and your
>>> resulting ways won't end up correctly sharing nodes.
>> There are ways around this, by first de-duping the shared edges or
>> nodes. Topology preservation is not terribly difficult if you prepare
>> your data, for example by splitting lines and polygons at intersections
>> (as in your lake example), simplifying only the parts and then
>> reconstructing the original geometries.
> Do you have a link to an example of the PostGIS magic to do this? It's
> beyond what I could do.
I implemented a version of this here:
Without digging into the code too deeply, the short version is that you can use the intersection of two shapes to arrive at something like a topology. For a pair of polygons that share a border, the ST_Intersection() results in a linestring that forms the border, which you can ST_Difference from each border to get the remaining pieces. The expensive part is the gigantic pairwise comparison to come up with the full list of all feature pairs that touch each other or come really close.
> A slight complication I found is that you can't just go for intersections
> but you also have to go to near intersections - sometimes the NHD data is
> off by a couple cm. I don't know if this will pose a practical issue for the
Possible to round every node position to 1e-7 degrees?
>> Do you have any sample NHD extracts that might be usable for a test
> All of NHD can be found at on the USGS FTP site, but you need to compile
> gdal with 3rd-party toolkits to be able to use them. This is quite often a
> I clipped out a small part of Kansas I was testing with early, converted it
> to a set of shapefiles and posted it at
> I should note that some information is lost in the shapefile conversion
> (long field names).
> For space reasons I dropped the WBD_HU layers. The first step of my
> converting is to remove them anyways.
michal migurski- mike at stamen.com
More information about the Talk-us