3

I am trying to convert a GIS LINE shapefile into a .osm.pbf file on Windows.

I've done some research on the topic and some tools that kept coming out are:

  • Merkaator
  • shp2osm - which deals mostly with point shapefile
  • shape2osm.py - which keeps bringing up an error with importing * elementtree.SimpleXMLWriter

But nothing seems to be working.

6

According to https://wiki.openstreetmap.org/wiki/Shapefiles you can try JOSM with the OpenData plugin to open a Shapefile.

https://wiki.openstreetmap.org/wiki/Software_comparison/Import_a_shapefile#Advanced:_Conversion_tools lists various other tools for converting a shapefile to OSM data:

There are multiple tools for converting shapefiles into .osm format suitable for importing. These include:

  • Merkaartor — simply import the shp, export the osm.xml.
  • shp2osm (and polyshp2osm) — require some programming skill, but very flexible
  • shp-to-osm.jar — less flexible, but requires only a simple configuration file
  • shape2osm — a Python script that will convert a POINT shapefile to OSM XML
  • PostGIS
    • convert shp to osm using grass and gpsbabel
    • Load the shapefile into PostGIS first, using shp2pgsql (feature of PostGIS) May be helpful as first conversion step
  • ogr2osm (ogr2osm) — a new script to convert any OGR supported vector format into .osm format, with emphasis in converting polygon boundaries into relations
  • Using QGIS & GPX Editor to convert to GPX

    • 1) Menu "Plugins/ Manage Plugins..." enable ,,GPS Tools".
    • 2) Menu "Plugins/GPS Tools/Create new GPS layer"
    • 3) Select feature(s) in the default layer. Copy, paste into a GPS tracks layer, save the changed layer.
    • 4) In GPX Editor open the gpx file. Menu "Edit/ OpenStreetMap Tools/ Anonymize time".
  • MapCreator-Toolset: ShapeToOsmTool — This C#-OpenSource tool converts a set of shape files to an osm file, applying specific conversion rules defined in a dedicated XML conversion rule file.

    • The tool is simple and flexible.
    • The tool can convert many layers (represented by many shape files) to one OSM output file.
    • The tool supports the following geometries: Polygon, LineString and Point. A Polygon will be mapped to a Closed OSM Way, a LineString to a OSM Way and a Point to a OSM Node.
    • With certain limits the tool can convert geometry types (Polygon to Point, LineString to Point), if so wanted.
    • The tool supports a flexible Tag generation. The Tag values can be constant or read out of the shape file fields.
  • SHPtoOSMBoundaries python script. If the SHP contains Administrative Boundaries and you want to transform them into OSM in order to autogenerate and join the multiple boundary relations before importing.

Please don't forget that you are not allowed to import a shapefile directly into OSM! See the Import Guidelines for details.

0

I just faced the problem and solved using JOSM and two different plugins:

JOSM -> https://josm.openstreetmap.de/

OpenData -> https://wiki.openstreetmap.org/wiki/JOSM/Plugins/OpenData

PBF -> https://wiki.openstreetmap.org/wiki/JOSM/Plugins/PBF

With this three pices you will be able to convert a .shp file into a .osm.pbf (and probably others formats).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.