[Imports] A new ogr2osm version

Paul Norman penorman at mac.com
Mon Apr 30 20:40:25 UTC 2012


 <http://www.gdal.org/ogr/drv_shapefile.html>
http://www.gdal.org/ogr/drv_shapefile.html states that "Normally the OGR
Shapefile driver treats a whole directory of shapefiles as a dataset, and a
single shapefile within that directory as a layer. In this case the
directory name should be used as the dataset name. However, it is also
possible to use one of the files (.shp, .shx or .dbf) in a shapefile set as
the dataset name, and then it will be treated as a dataset with one layer."

 

Previously ogr2osm was rejecting shapefile directories. My example came from
the US NHD data.

 

I was working with NHD data and the following command generated a directory
from the original .mdb file which contained multiple layers

 

ogr2ogr NHDH1711.shp NHDH1711.mdb

 

It then created a directory named NHDH1711.shp which had the following
contents (plus more layers)

 

NHDAreaEventFC.dbf

NHDAreaEventFC.prj

NHDAreaEventFC.shp

NHDAreaEventFC.shx

NHDArea.dbf

NHDArea.prj

NHDArea.shp

NHDArea.shx

NHDFlowline.dbf

NHDFlowline.prj

NHDFlowline.shp

NHDFlowline.shx

 

I could then run ogr2osm on the directory and use a filterLayer() function
in the translation file to eliminate the layers I did not want. The code I
used to do so is at
https://github.com/pnorman/ogr2osm-translations/blob/3e44a11b1bdc441101430fa
d4fb0d356805d3812/us_nhd.py#L55

 

 

From: TC Haddad [mailto:tchaddad at gmail.com] 
Sent: Monday, April 30, 2012 12:50 PM
To: Paul Norman
Subject: Re: [Imports] A new ogr2osm version

 

Hi Paul

can you elaborate on "Support for shapefile directories", or give an
example?

Tanya

On Mon, Apr 30, 2012 at 12:36 PM, Paul Norman <penorman at mac.com> wrote:

Based on Andrew Guertin's work for UVM I have released a new version of
ogr2osm
It can be found at https://github.com/pnorman/ogr2osm

Improvements and bug fixes over the previous version include

- MultiLineStrings are broken up into multiple LineStrings
- More readable raw XML
- Support for keys or values which require escaping in the XML
- upload=false is set by default to help prevent accidental uploads
- Support for shapefile directories
- Significant speed improvements when dealing with data sources where
multiple geometries share points in common. What used to take hours now
takes minutes.

Installation instructions can be found at
https://github.com/pnorman/ogr2osm#installation

ogr2osm has three main advantages over other tools that can convert
shapefiles
- It handles the reprojection for you
- It can deal with shapefile directories which is what gdal uses to handle
multiple layers with shapefiles
- It accepts a python function for converting from datasource tagging to OSM
tagging, allowing you to use more complicated logic to come up with better
OSM tagging

As always, potential importers are reminded about the import guidelines.
ogr2osm allows you to write a good conversion to OSM tagging. It doesn't do
the rest of the work for you and it won't contact the community before
importing for you. You still have to do all of these yourself.

If anyone has good well-commented examples of translations files I welcome
pull requests against https://github.com/pnorman/ogr2osm-translations



_______________________________________________
Imports mailing list
Imports at openstreetmap.org
http://lists.openstreetmap.org/listinfo/imports

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/imports/attachments/20120430/f0a2e6e7/attachment-0001.html>


More information about the Imports mailing list