NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum

Hello, I'm a student working on a thesis of traffic optimization. I'm getting desperate: I need a shapefile out of a little portion of a city (Milan, in my case). I achieved that by downloading the portion of the map in ".osm", installing the OpenStreetMap plugin on QGis, and exported in shapefiles. The main problem I found is that during this operation I lose a lot of data (my main problem is that I lose traffic lights information). I can clearly see that the traffic light is handled as a point in QGis and OSM but as I export as a shapefile and import it back in QGis I lose all the traffic ligths I had when I imported the portion of the map from OSM. I don't really know if I expalained myself well, my brain is actually dried out after all the searches I did on google and relatives. I'd gladly appreciate any tip or advice on how to get a shapefile with informations on traffic lights in it. Thanks in advance.

P.S. I need the map in shapefile format because I've to load it on Repast Simphony

asked 16 Sep '13, 14:54

MassimoUNIMIB's gravatar image

MassimoUNIMIB
11113
accept rate: 0%

edited 16 Sep '13, 14:55

3

two hint for you:

Be sure that the OSM-import-plugin of QGIS can work with all you data: There is currently a problem with object id numbers szored in 64-bit data:

http://wiki.openstreetmap.org/wiki/64-bit_Identifiers

and:

all about OSM2Shapefile should be collected at http://wiki.openstreetmap.org/wiki/Shapefile

(16 Sep '13, 17:08) stephan75
2

one more idea: you can use ogr2ogr (http://www.gdal.org/ogr/index.html) to read the .osm file, then produce a shapefile from it. Once the data is in shapefile format, the 64-bit data isn't an issue.

(16 Sep '13, 17:28) neuhausr

Hello everyone, thanks for the quick answers! My data is still pretty small, a little square located here: http://www.openstreetmap.org/#map=16/45.5012/9.2365 . I'm now triyng the ogr2ogr's way but I'm encountering new problems: it seems the driver doesn't like the geometry type "Geometry Collection" saying that shapefiles don't support that kind of geometry(Error6). I've tried to bypass (with skipfailures) it but it gives Error 1 "Non increasing node id. Use OSM_USE_CUSTOM_INDEXING=ON. I'm feeling a bit lost, probably because I can't find proper documentation anywhere!Can you point me to it?

(17 Sep '13, 08:53) MassimoUNIMIB
1

to extract points try something like this:

ogr2ogr -where "OGR_GEOMETRY='Point'" -lco SHPT=POINT outfile.shp infile.osm

Also, make sure you're using GDAL 1.10

(17 Sep '13, 16:01) neuhausr

Hello, I tried that but it still gives me the same error: Non increasing node id. Use etc...". I found a temporary solution by downloading arcGis for desktop and converting the .osm maps with it. It still has some problems (it doubles some points and lines, but I guess I'll fix them with my software). Thanks for replying anyway! Bye.

(19 Sep '13, 09:51) MassimoUNIMIB

I find that far & away the simplest way to get shapefiles from OSM data out of QGIS is to use osm2pgsql to import the data to a PostGIS database and then pull the data into QGIS that way.

A couple of things are necessary: use the hstore option to get all the tags; and create a view on the standard tables loaded by osm2pgsql to shorten all column names to <= 10 characters if you need those with long names, such as addr:housenumber (otherwise QGIS gets stroppy, saving the data as a Shape file).

permanent link

answered 19 Sep '13, 11:06

SK53's gravatar image

SK53 ♦
28.1k48268433
accept rate: 22%

You could take your OSM file, use OSMConvert to convert it to a CSV and then import that into qgis.

Also, you could use osmfilter to only keep relevant data.

See http://wiki.openstreetmap.org/wiki/Osmconvert#Writing_CSV_Files .

permanent link

answered 19 Sep '13, 15:41

gormo's gravatar image

gormo
2.9k32660
accept rate: 13%

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×710
×87
×37
×21

question asked: 16 Sep '13, 14:54

question was seen: 11,564 times

last updated: 19 Sep '13, 15:41

NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum