OpenStreetMap: Difference between revisions

From GRASS-Wiki
Jump to navigation Jump to search
(+http://downloads.cloudmade.com/)
(+Download as own section)
 
(15 intermediate revisions by 3 users not shown)
Line 1: Line 1:
OSM Homepage: http://www.openstreetmap.org/
OSM Homepage: http://www.openstreetmap.org/


=== Import ===
__TOC__


* [[GRASS_AddOns#v.in.osm]]  (fairly rough script)


Conversion with {{wikipedia|Mapnik}} to raster tiles may work, but be very careful about projection issues, typical online web map tiles are not appropriate for GIS import.
== Download ==
 
==== Administrative boundaries from OpenStreetMap ====
 
For a convenient download in GeoJSON and SHAPE, see https://wambachers-osm.website/boundaries/
 
(using the almost invisible triangle, you can pop out details of a country down to admin level 8)


=== Data as shapefiles ===
=== Data as shapefiles ===


Get data from here:
Get data from here:
* http://download.geofabrik.de/osm/ ,or
* http://download.geofabrik.de/osm/ , or
* http://downloads.cloudmade.com/
* http://downloads.cloudmade.com/


Then import with {{cmd|v.in.ogr}}
=== Data from WMS ===
 
* Web Map Service (WMS) for Europe: [http://mapbender.wheregroup.com/cgi-bin/mapserv?map=/data/umn/osm/osm_basic.map&VERSION=1.1.1&REQUEST=GetCapabilities&SERVICE=WMS GetCapabilities] to access the WMS
* Free/open world-wide server: http://www.mundialis.de/ows-mundialis/
 
=== Data as OSM pbf ===
 
Get data from here:
* http://download.geofabrik.de/osm/
 
== Import ==
 
* [[GRASS_AddOns#v.in.osm]]  (fairly rough script)
 
Conversion with {{wikipedia|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 ===
 
Import with {{cmd|v.in.ogr}}.


=== Data from WMS ===
=== Data from WMS ===


* No free/open server known - Badly needed
Import with {{cmd|r.in.wms}}.
 
=== Data as OSM pbf ===
 
Read http://gdal.org/drv_osm.html. 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 {{cmd|v.in.ogr}} in order to import only the required features and in order to avoid topological problems.
 
For example, import roads from some pbf file with
  v.in.ogr layer=lines where="highway <> ' '".
 
Import landuse from some pbf file with
  v.in.ogr layer=multipolygons where="landuse <> ' '"
 
Import landuse from some pbf file with
  v.in.ogr layer=multipolygons where="landuse <> ' '"
 
Import administrative boundaries for a particular level with
  v.in.ogr layer=multipolygons where="boundary = 'administrative' and admin_level = '<desired level'"
 
'''Alternative''': use {{AddonCmd|v.in.osm}}.
 
=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 {{cmd|version=71|v.build.polylines}} cats=same merges the extra lines into single polyline.
 
Correct topological model is necessary e.g. to perform [[Vector network analysis]].
 
==Example==
 
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.
 
[[Image:01 roundabout before.png‎|center|700px|thumb|v.in.ogr output]]
 
After the  application of v.split it gives too many one segment lines. It is clear form the following image:
 
[[Image:02 roundabout split.png‎|center|700px|thumb|v.split output]]
 
{{cmd|version=71|v.build.polylines}} merges unnecessary segments. All lines starts/ends on the intersections with other lines as can be seen on the following image:
 
[[Image:03 roundabout after.png|center|700px|thumb|v.build.polylines output]]
 
There is another possibility to use {{cmd|version=71|v.clean}} <tt>tool=break</tt> 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:
 
[[Image:Vclean difference.png|center|700px|thumb|Output of v.split -> v.build.polylines]]
[[Image:Vclean.png|center|700px|thumb|Output of v.clean tool=break]]


Then import with {{cmd|r.in.wms}}
=== See also ===


* [[Extrude 2D polygons to 3D]]
* [http://wiki.openstreetmap.org/wiki/Simplifying_OSM_Shapefiles_using_GRASS Simplifying OSM Shapefiles using GRASS]


[[Category: Geodata]]
[[Category: Geodata]]

Latest revision as of 16:24, 10 May 2018

OSM Homepage: http://www.openstreetmap.org/


Download

Administrative boundaries from OpenStreetMap

For a convenient download in GeoJSON and SHAPE, see https://wambachers-osm.website/boundaries/

(using the almost invisible triangle, you can pop out details of a country down to admin level 8)

Data as shapefiles

Get data from here:

Data from WMS

Data as OSM pbf

Get data from here:

Import

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

Import with v.in.ogr.

Data from WMS

Import with r.in.wms.

Data as OSM pbf

Read http://gdal.org/drv_osm.html. 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 v.in.ogr in order to import only the required features and in order to avoid topological problems.

For example, import roads from some pbf file with

 v.in.ogr layer=lines where="highway <> ' '".

Import landuse from some pbf file with

 v.in.ogr layer=multipolygons where="landuse <> ' '"

Import landuse from some pbf file with

 v.in.ogr layer=multipolygons where="landuse <> ' '"

Import administrative boundaries for a particular level with

 v.in.ogr layer=multipolygons where="boundary = 'administrative' and admin_level = '<desired level'"

Alternative: use v.in.osm.

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 v.build.polylines cats=same merges the extra lines into single polyline.

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

Example

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.

v.in.ogr output

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

v.split output

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

v.build.polylines 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 -> v.build.polylines
Output of v.clean tool=break

See also