Sun, 30 Aug 2009
Extracting OSM data with Osmosis
For those of you who might have played with OSM , might
have always felt a need to download and view it on their laptop offline.
The files are typically at a contry level or a state level and most of them are pretty huge and memory hogging.
In any case if you feel a need to extract out a bounding box from a huge .osm file here is what you can do.
First download Osmosis from http://wiki.openstreetmap.org/wiki/Osmosis#Downloading
Since it is java based it will pretty much run on all platforms where java will run.
Then download the state or country maps in osm format from OSM or from Cloudmate
The file format which we need to download the file will be something like <Country or State Name>.osm.bz2 like in my case it is california.osm.bz2
Once you download that file you need to unzip it using a command like bzip2 -d california.osm
Now say for example you want to only extract OSM data from a bounding box between Top Left Longitude -122.093566 / Top Left Latitude 37.39062 and Bottom Right Longitude -122.093566 / Top Right Latitude 37.39062 which is an Area of Sunnyvale and Mountain View, California you would give a command like
./osmosis --read-xml /mnt/officedesktop/maps/california.osm --bounding-box top=37.39062 left=-122.093566 right=-121.939929 bottom=37.318027 --write-xml svl.xml
The output of the command will be called svl.xml
This way you can extract out bounding boxes for areas of your interest and use it in applications like Gosmore
The files are typically at a contry level or a state level and most of them are pretty huge and memory hogging.
In any case if you feel a need to extract out a bounding box from a huge .osm file here is what you can do.
First download Osmosis from http://wiki.openstreetmap.org/wiki/Osmosis#Downloading
Since it is java based it will pretty much run on all platforms where java will run.
Then download the state or country maps in osm format from OSM or from Cloudmate
The file format which we need to download the file will be something like <Country or State Name>.osm.bz2 like in my case it is california.osm.bz2
Once you download that file you need to unzip it using a command like bzip2 -d california.osm
Now say for example you want to only extract OSM data from a bounding box between Top Left Longitude -122.093566 / Top Left Latitude 37.39062 and Bottom Right Longitude -122.093566 / Top Right Latitude 37.39062 which is an Area of Sunnyvale and Mountain View, California you would give a command like
./osmosis --read-xml /mnt/officedesktop/maps/california.osm --bounding-box top=37.39062 left=-122.093566 right=-121.939929 bottom=37.318027 --write-xml svl.xml
The output of the command will be called svl.xml
This way you can extract out bounding boxes for areas of your interest and use it in applications like Gosmore
posted at: 22:14 | category: /worklog | permanent link to this entry


