Archive

Archive for January, 2011

Exporting data from OpenStreetMap using GDAL

GDAL can be used to export data from OpenStreetMap. We need an xml file that defines the WMS service and the GDAL people has provided one for us. It is quite simple:

<GDAL_WMS>
    <Service name=”TMS”>
        <ServerUrl>http://tile.openstreetmap.org/${z}/${x}/${y}.png</ServerUrl>
    </Service>
    <DataWindow>
        <TileLevel>19</TileLevel>
    <TileCountX>1</TileCountX>
    <TileCountY>1</TileCountY>
        <YOrigin>top</YOrigin>
    </DataWindow>
    <Projection>EPSG:900913</Projection>
    <BlockSizeX>256</BlockSizeX>
    <BlockSizeY>256</BlockSizeY>
    <BandsCount>3</BandsCount>
    <Cache />
</GDAL_WMS>

Assuming that this file is available as frmt_wms_openstreetmap_tms.xml we can now translate the data using gdal_translate:

gdal_translate -of GTIFF -outsize 512 512 wms_openstreetmap_tms.xml world.tif

This will create a tif file of size 512×512. We can select a subset using the srcwin parameter to gdal_translate. OpenStreetMap uses Mercator1SP coordinates (epsg id 900913). So, exporting only italy can be done using:

gdal_translate -of GTIFF -outsize 512 512 -projwin 747340 5155416 2385740 4293100 frmt_wms_openstreetmap_tms.xml italy.tif

When storing tiff files we should normally prefer tiled and compressed images we can be achieved by adding some custom options:

gdal_translate -of GTIFF -outsize 512 512 -projwin 747340 5155416 2385740 4293100 frmt_wms_openstreetmap_tms.xml italy.tif -CO “TILED=YES” -CO “COMPRESS=LZW”

Note: Be careful not to export large amounts of data so that the OpenStreetMap server gets overloaded. Make sure you have read and understood the tile usage policy.

Advertisements
Categories: Uncategorized

Fossil

I stumbled upon fossil today. Fossil is a younger cousin of Mercurial and GIT. It lacks maturity but providesĀ a few interesting concepts… or how about this:

  • Built-in bug tracking and wiki(!)
  • Extremly light weight; one single executable
  • Single file repository
  • Autosync (haven’t tried this one yet)

Maybe I’ll use it for my next hobby project.

Categories: Uncategorized