[OSM-newbies] SQL to extract bounding box from OSM Database
Graham Jones
grahamjones139 at gmail.com
Tue Mar 6 20:24:00 GMT 2012
Well, I use something like this in python:
sqlstr = "select id,name,operator,amenity,shop,landuse,"\
"ST_Y(centroid(way)),ST_X(centroid(way))"\
"from planet_osm_point,planet_osm_nodes where id=osm_id
and way
&& \
SetSRID('BOX3D(%f %f,%f %f)'::box3d,900913)" % \
(bbox.minx,bbox.miny,bbox.maxx,bbox.maxy)
The relevant bounding box bit is: the Box3d bit.
There may be better ways of doing this though - I remember having trouble
with map projections to get it to work, which is what the SetSRID bit is
doing.
Graham.
On 6 March 2012 20:09, Matthew Wechsler <maw269 at gmail.com> wrote:
> I have a full OSM planet database import that I use for rendering Mapnik
> tiles. I would like to use a bounding box to extract a geographic region
> from the database to be used in rendering on a different server. Does
> anyone know the SQL statement I could use to extract the BB info from all
> the tables into a different DB?
>
> I have tried to use osm2pgsql to go the other way and use the BB to import
> data into another DB but have lately been running into memory issues on the
> import (even though I'm using --slim mode). I am using Windows so I am only
> able to use the old osm2pgsql binary that has been created a few years ago.
> Thanks,
> Matt
>
> _______________________________________________
> newbies mailing list
> newbies at openstreetmap.org
> http://lists.openstreetmap.org/listinfo/newbies
>
>
--
Graham Jones
Hartlepool, UK.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/newbies/attachments/20120306/e682ef83/attachment.html>
More information about the newbies
mailing list