OpenStreetMap

How to create a translation file to convert a shp file to osm

Posted by baditaflorin on 31 October 2017 in English (English). Last updated on 1 November 2017.

Obviously but very importantly:

  • Before copying anything into OSM the license needs to be properly vetted.
  • If you are planning to perform any kind of bulk update, the full extent of the Import Guidelines applies.

After comparing Tiger 2017 for 16 US states until now, using shp2cygnus, a tool that I written at Telenav to be able to compare big datasets in a automatic way, to identify roads that are present in the dataset, but not in OSM

After posting on the talk-us, some people told that it would be more useful to run this tool on other datasets, from state or local authorities.

In this article, I want to teach you how to create your own translation file, so that if you have a shp file, you can use Cygnus to compare this with OSM, using this link http://cygnus.improve-osm.org If you have a shp were the size is bigger then 50*50 km, you can send me a email and I can process it for you.

But you need to learn how to create your own translation file.

So, first step.

  1. Find your data

We will use as a example Philadelphia Each city or local authority should have a open data portal. After a google search for “Philadelphia Open data”, I found this site https://www.opendataphilly.org/ image

Search for either street or road

image

Click the data-set, and identify the shp, that you need to download

image

Extract the archive and open the shp into JOSM.

To be able to open shp in JOSM, you will need to install the OpenData Plugin

image

If we look at the tags, we see that they don`t have any connection with what we are used to, like highway=residential, tertiary, etc or oneway=yes

To be able to understand how to translate the shp to osm, you need the Street Centerline Metadata

image

Click Download, and you will see, at least for the Class, what is the highway type.

image

To see how you can create the translation for osm, you can look here for the OSM highway tags http://wiki.openstreetmap.org/wiki/Key:highway

After doing this, run this script, and then load the output.osm file into JOSM.

python ogr2osm.py -t translation_philadelphia.py –add-timestamp –add-version –positive-id input_shapefile.shp -o output.osm

It will not be perfect, this is after the first try.

image

Comparing this with osm data I see that I have to much yellow roads (tertiary)

Also, the trunk roads are actually motorway on OSM

image

We look at the shapefile and identify that Class=4 should be highway=residential, instead of highway=tertiary

image

We run again the converter image

And we get now a more better result, more accurate with what we have in OSM.

image

If we are happy with the result, we need to save the osm XML file to PBF, so that we can use them with Cygnus.

We do this by installing the pbf plugin in JOSM

image

Save the file as Pbf

image

We next go to the http://cygnus.improve-osm.org website, and load the pbf file.

image

Also, you can select some tags of interest, for me, this was oneway.

image

In the end you should see something like this

image

You can download the translation file for Philadelphia from here

https://github.com/baditaflorin/ogr2osm-translations/blob/master/philadelphia_translation_file.py

Comment from mvexel on 31 October 2017 at 17:37

Obviously but very importantly:

  • Before copying anything into OSM the license needs to be properly vetted.
  • If you are planning to perform any kind of bulk update, the full extent of the Import Guidelines applies.

The Cygnus web interface links to my diary entry that points out these things in big capital letters, but it cannot be stressed enough!


Login to leave a comment