[OSM-talk] Osmosis and large bounding polygons
Frederik Ramm
frederik at remote.org
Wed Jan 9 01:50:17 GMT 2008
Hi,
> Is there any easy way to edit these polygon files? They're basically just
> a list of lat and lon values I think, but it'll take forever to edit one
> of that size by hand.
I have just commited a simple utility that allows simplification of
polygon files, based on the perl module Math::Polygon:
/applications/utils/osm-extract/polygons/simplify-poly.pl
It takes a polygon file on stdin (or give name on cmdline) and writes
to stdout. There are three modes of simplification which may be
combined:
--percent=10
will simply drop 90% of nodes in the polygon, first those with the
biggest angles (i.e. those carrying least information).
--slope=0.01
will compute the partial polygon circumference between any three
consecutive nodes and drop the middle node if that reduces the
circumference by less than the given number.
--same=0.01
will drop any node that lies within 0.01 length units of a
neighbouring node.
Note that length units are just degrees, i.e. at the equator one unit
is 60 miles but that becomes distorted towards the poles. The angle
computation upon which the --percent operation is based doesn't take
the spherical earth into account either so it is all quite flawed but
it should be sufficient for boiling down the number of points in your
polygon a bit.
A better way to do this would be using the algorithms I nicked from
GPSBabel and implemented in the "simplify way" code for JOSM but I'm
not in a mood to perlify them atm.
Bye
Frederik
--
Frederik Ramm ## eMail frederik at remote.org ## N49°00.09' E008°23.33'
More information about the talk
mailing list