[OSM-talk] Coastlines
Lars Aronsson
lars at aronsson.se
Mon Apr 30 05:31:48 BST 2007
Working in JOSM, I have now fixed up the previously imported
coastline for southern Sweden, from Båstad to Kalmar, and also for
Öland and Bornholm. You can view the maplint layer -- it's clean.
Parts of this were long straight lines, parts were archipelago[1].
It was a pain. I think it should be possible to improve the
import script, to automate a lot of the work that I did manually.
[1] http://informationfreeway.org/?lat=7588165.28936&lon=1715624.6542&zoom=10&layers=B00000
Once for every island, and at various places along the mainland
coast, there was a duplicate node that had to be merged. On
islands this is always the southern-most or south-east corner.
It must be possible for the import script to find these non-unique
coordinates and reuse one node instead of creating a duplicate.
All coastlines I have seen use too many, too short line segments.
Often you see a train of short line segments pointing in exactly
the same direction. They could (should! in my opinion) be merged
into one, by removing intermediate nodes, before import. Often
you see zig-zag patterns of short line segments, that don't
correspond to reality. They should be low-pass filtered before
import. Both merging and low-pass filtering can be covered by a
standard GIS algorithm. I think it's called "linear
generalization".
Line segments of the imported coastlines have a uniform direction,
always going the same way along the mainland or around an island.
But for islands, this is always the wrong direction. It must be
possible to determine before import what is an island, and to
reverse the direction before import.
I had a first look at the coastline import script, as documented
on the wiki [[Almien coastlines (PGS)]] and its source in SVN.
The API is unavailable right now, I guess because of the database
reconfiguration, so I haven't been able to run it.
The coast_upload.pl script directly uploads to the API. This
seems dangerous to me. How can one assure the right area was
picked and that this area wasn't already imported or manually
edited? Perhaps an alternative could be to output a local .osm
file, that can be opened in JOSM? Perhaps the coastline import
should be a JOSM plugin? That would provide a user interface for
the picking the right area and viewing the updates before
uploading. The current script is very short and simple, based on
Perl's Geo::Shapefile library. We'd need a Shapefile library in
Java, that's all.
The imported coastlines come from NGA, the U.S. National
Geospatial Agency, and their Digital Nautical Chart. Allegedly,
they were produced by edge-detecting the Landsat images. That
explains the zig-zaging around the pixels. Low-pass filtering is
what's missing. If you run edge detection, a standard image
processing operation, you know which side of the edge is green
(land) and which side is blue (water). That's exactly what you
need to know, to point our line segments in the right direction.
I would be surprised if that information is not included in the
Shapefiles provided by NGA.
The Mapnik layer apparently has coastlines at zoom=1...7 that are
different from the ones at zoom=8..17. Where do these come from?
Could that data be used to assist the coastline import into the
database?
--
Lars Aronsson (lars at aronsson.se)
Aronsson Datateknik - http://aronsson.se
More information about the talk
mailing list