[OSM-dev] Best way to select from a region
frederik at remote.org
Tue Sep 1 02:12:10 BST 2009
Stephan Knauss wrote:
> I'm trying to create lists of features inside a specific country.
> What would be the most convenient way to do this?
There is no convenient way I know of ;-)
> As source I could either use a planet file and use a SAX parser or
> PostgreSQL with the osm2pgsql mapnik schema.
I suggest using osmosis with the --bp option.
> As a boundary polygon I would prefer the borders already in the database
> as these are more accurate compared to the polygon files of cloudmade.
In 95% of cases you will find that the borders in the database are
unsuitable because they do not form a proper closed polygon. Plus,
PostGIS definitely sucks at point-in-polygon performance, especially if
your polygon has 30k points.
I suggest that you use Gary68's polygon tool (perl script in SVN) to
derive .poly files from a suitable OSM exctract (or use .poly files that
are already in SVN). Then simplify these files with the simplify-poly
script also in SVN unless you really, really want super-exact and
super-slow cutting. Then use Osmosis to cut out an area. Pay attention
to the various options (idTrackerType, clipIncompleteEntities,
completeWays, completeRelations - the latter two being perfect ways to
keep your server busy for a few days if you work with the full planet file).
More information about the dev