[GRASS-user] GRASS-module to import OSM-data

Jannis Achstetter krippi at gmail.com
Sat Jul 14 18:49:26 EDT 2007


Brad Douglas schrieb:
> On Fri, 2007-07-13 at 13:19 +1200, Hamish wrote:
>   
>> Jannis Achstetter wrote:
>>     
>>> I wanted to import data from the OpenStreetMap-project to GRASS. I
>>> found a bash-script written by Hamish some (long) time ago and tried
>>> it that way. His script has 3 disadvantages for me:
>>> - It somehow had X and Y swapped (maybe worked correctly for earlier
>>> version of GRASS?)
>>> - It didn't work with OSM-files written by JOSM (Files written by
>>> server/API were OK)
>>> - It's slow (Spawns lot of procs, used tempfiles very often)
>>> So I quite rewrote the script in TCL (using similar techniques but
>>> improved ;) fixing some stuff.
>>> When I had the thing done, I tried to rewrite it, so it now became a
>>> module for GRASS (though written in TCL).
>>> The script reads the file line-by-line and stores the important stuff
>>> in arrays and then imports the data as vector map using 1 polyline for
>>> each way. Since TCL uses quite a bit of memory for arrays (it's not C
>>> after all), you might not want to import the whole planet.osm.
>>> Since this is my first module for GRASS and things can always be
>>> improved, feedback is very welcome and wanted.
>>> You can find the script here:
>>> http://kripton.kripserver.net/software/v.in.osm
>>> Written for GRASS 6.2.1, not tested for other versions.
>>>       
>> Excellent stuff Jannis. I look forward to trying it out.
>> Yes, mine was a quick hack just to get it working. I was mostly
>> interested in building a connected network from all the OSM segments to
>> try out GRASS's v.net.* and d.path routing modules with real data.
>> Hopefully OSM has standardized some on road types (dirt, residential,
>> highway, etc.) since then. I remember correcting for that taking most of
>> the time. I'll update my google page to list your script once I get my
>> Debian upgrade finished ;)  Until then perhaps you could add it to the
>> GRASS Wiki add-ons page?
>>     
>
> I would recommend adding it to the SVN repository, but the script
> requires tcsh. :(
>
> I'd like to use OSM, but I've found it horribly lacking in both
> consistency and metadata

Hello again ;)

First, to respond to your notes:
Thanks for the feedback, I'll add the module to the mentioned Wiki-page
soon.
Yeah, it needs the tclsh but I don't think it'll be a problem since the
"GRASS Manager" needs that, too. It even requires Tk to run, which my
module doesn't. IMO, Tcl/Tk is found on nearly every Linux-Desktop and
if it's not installed it shouldn't be a big problem to install it.
Sure, OSM doesn't yet cover the world but you're very welcome to
contribute. Metadata-proposes can be done via the wiki, all proposals
are voted upon.

Now to some good news:
I greatly improved the functionality of the script:
- You can now import only nodes or segs if wanted
- You can just import all "roads" (ways with "highway"-tag)
- You can let the script try to import "closed ways" as areas. There's a
little problem here:
    The script just checks, wether the first node of the first segment
(first means segment #1 of the way) and the last node of the last
segment (means segment with the highest number in that way) match. This
must be the case with closed ways but can occur with unordered ways, too
(Way: 3,4,5,1,2 for example). That's why "highway" and "junction"-tagged
ways are ignored at the area-check.

The new script can be downloaded here:
http://kripton.kripserver.net/software/v.in.osm/v.in.osm-2007-07-14-00
the old one has moved to:
http://kripton.kripserver.net/software/v.in.osm/v.in.osm-2007-07-12-00

The old one still contains a bug: it WILL ignore the "output"-parameter
and will always write to "planet_seg".

Finally, I made a screenshot (sorry for the quality, didn't figure out
how to do better, yet):
http://kripton.kripserver.net/software/v.in.osm/screen.jpg
You can see the region I live in there with "visual_bright"-raster-map
as background, the "normal" OSM-data (black), only the roads with
directions (green) and the imported areas (blue). Just ignore the
orange, red and brown overlays.

Enjoy,
    Jannis




More information about the grass-user mailing list