Skip to content

Instantly share code, notes, and snippets.

@wenzeslaus
Last active August 29, 2015 14:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wenzeslaus/d05fc3c14622198d4d52 to your computer and use it in GitHub Desktop.
Save wenzeslaus/d05fc3c14622198d4d52 to your computer and use it in GitHub Desktop.
Buffers, cost surfaces, least cost path with OSM

Geospatial Analysis II: buffers, cost surfaces, least cost path

http://courses.ncsu.edu/gis582/common/grass/buffers_cost.html

Tested with QGIS 2.4 and GRASS GIS 7.0.

Download the OpenStreetMap data in QGIS

Start QGIS.

Plugins > Manage and install

Install GRASS plugin.

Plugins > GRASS > Add GRASS raster layer

Select GRASS database directory with the NC SPM sample Location (probably grassdata in your user home directory or in documents directory). Select nc_spm_08 for Location (or whatever is the name of NC SPM Location you downloaded) and Mapset PERMANENT.

Vector > OpenStreeMap > Download data
Extent: From layer: elevation
Output file: raleigh.osm in Downloads, Documents or in gisdata directory
OK (and wait)
Close the dialog when import is finished
Vector > OpenStreeMap > Import topology from XML
Set Input XML file to `.osm` file downloaded in the previous step
OK
Close the dialog when import is finished
Vector > OpenStreeMap > Import topology from XML
Set Input XML file to `.osm.db` file downloaded in the previous step (`raleigh.osm.db`)
Export type: Polylines
Output layer name: raleigh_osm_roads
In Exported tags, click Load from DB
Select tags: highway, name, oneway, lanes, maxspeed, ref, proposed
OK
Close the dialog when import is finished
Right click on the roads layer and select `Save as`
Choose a filename
CRS: Project CRS
Save

In GRASS GIS, Search module > Import, export and link data > Import vector data > Common import formats (TODO: the string should be changed in GRASS to Common formats). Select the exported file and import.

Additional materials about OpenStreetMap and QGIS

Cost surfaces Compute cumulative cost surface to a given accident site based on speed limits

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment