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 |
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 answered 19 Sep '13, 11:06 SK53 ♦ |
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 . answered 19 Sep '13, 15:41 gormo |
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
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.
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?
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
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.