From GRASS-Wiki
Revision as of 21:41, 15 February 2018 by Mmetz (talk | contribs) (Import OSM pbf: wiki formatting)
Jump to navigation Jump to search

OSM Homepage:


Conversion with Mapnik to raster tiles may work, but be very careful about projection issues, typically online web map tiles are not appropriate for GIS import.

Data as shapefiles

Get data from here:

Then import with

Data from WMS

Then import with

Data as OSM pbf

Get data from here:

Read Create a OSM_CONFIG_FILE file, selecting tags. The options other_tags and all_tags should be disabled to avoid errors when creating attribute tables.

When importing, use the layer and where options of in order to import only the required features and in order to avoid topological problems.

For example, import roads from some pbf file with layer=lines where="highway <> ' '".

Import landuse from some pbf file with layer=multipolygons where="landuse <> ' '"

Import landuse from some pbf file with layer=multipolygons where="landuse <> ' '"

Import administrative boundaries for a particular level with layer=multipolygons where="boundary = 'administrative' and admin_level = '<desired level'"

OSM vs. GRASS topology

OSM topological model is different to GRASS topological model. OSM topologically correct connections of the lines can be on all nodes of the line. Unlike OSM, GRASS allows to connect lines only on their starting/end nodes.Therefore after the import it is needed to split lines into the smallest segments by "v.split vertices=2". However after application of the v.split, there are too many lines and some of them are not necessary. Module cats=same merges the extra lines into single polyline.

Correct topological model is necessary e.g. to perform Vector network analysis.


The following image represents roundabout after the import of the OSM shapefile from geofabrik. You can see that there is only one category number 917. It means that the roundabout circle is just one line and grass does not see all connections to the other lines, because they are not on the starting/end node of the circle. output

After the application of v.split it gives too many one segment lines. It is clear form the following image:

v.split output merges unnecessary segments. All lines starts/ends on the intersections with other lines as can be seen on the following image: output

There is another possibility to use v.clean tool=break but if there is e.g. a bridge then v.clean connects it to the roads going below it which is incorrect. The above described approach does not split the bridge there. See the difference on the following images:

Output of v.split ->
Output of v.clean tool=break

See also