O'Reilly logo

OpenStreetMap by Jonathan Bennett

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Reading the OpenStreetMap API from Osmosis

So far we've only dealt with data in OpenStreetMap XML files, but Osmosis can handle other sources of data, including databases and the OpenStreetMap API itself. Note that this is not the same as reading and writing to a database in API format, which we'll cover later.

Osmosis only supports the map call of the API to download data. We can get the data of Compton—the village we mapped in earlier chapters—and save it to a file using the read API task, as follows:

osmosis --read-api left="-0.64" bottom="51.21" right="-0.615" top="51.22"
--write-xml file="compton.osm"

We supply the bounding box we want to download as four parameters to the read API task.

However, remember that the main API only allows you ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required