[Imports] polyshp2osm.py

Dan Homerick danhomerick at gmail.com
Wed Oct 21 00:42:29 BST 2009


On Tue, Oct 20, 2009 at 3:45 PM, Sam Vekemans
<acrosscanadatrails at gmail.com> wrote:
> Hi,
> Can you give an example of a situation when you'd need to use multiple
> source fields for 1 osm tag?

Sure. To give a little context, the import I just did is for
waterways. The source data has a boolean field NAMED that indicates
whether or not a particular stream is named. There's a second field,
STREAM_NAME which contains a string. When NAMED is 'Yes', then
STREAM_NAME has something like 'Newell Creek' in it. When NAMED is
'No', then STREAM_NAME has something like 'Stream 243' in it.

I wanted to add a 'name' tag only for the named streams, and leave it
off for the 'Stream 243' streams.

So that's a case of wanting an 'IF' statement, really. An IF/ELSE
would be even better, if tests for equality were available. The
"polyshp2osm.py" script is wonderfully flexible since you are
customizing the source code for your import. It's also useless if you
don't have any exposure to programming or don't have a clue about
Python. It's good to see tools like shp-to-osm which use a rules.txt
file to drastically lower the bar.

> Also, if your creating intersecting ways, double check to see that the
> nodes are infact connected. (shp-to-osm doesnt connect the ways.
> (thats why im not dealing with roads, and leaving it to the shp2osm
> script to handle) but it seems all other features are fine though.

I noticed that, and used the validator plugin in JOSM to merge nodes.
I was lucky that when two streams merged, they (usually) had
overlapping nodes at the merge point. I'm still correcting by hand a
few cases where this wasn't true, however. Also, my first attempt at
uploading failed, because JOSM added a modified='true' attribute[1] to
the ways when I did the merges. I used a text editor's find/replace to
remove those, and the second attempt went smoothly.

[1] Or something like that...

- Dan




More information about the Imports mailing list