Wednesday, 15 February 2017

qgis - How to get number of Lane from OSM?


I am using OSM for my project, I have downloaded data from http://download.geofabrik.de/ in the OSM file and imported the data in POSTGIS, In the planet_osm_roads, I am not able to see any key related to lanes.


Can you please help me get the information about the number of lanes from OSM?


I have visited Getting lane data from OSM


Number of lanes in road data



Answer



Looking at the .PBF file for Colorado, there are 2 line layers when importing into a QGIS project.


The colorado-latest lines (NOT multistring) contains the HSTORE-type column "other_tags"


In there, you can see this value: "bicycle"=>"yes","cycleway"=>"lane","cycleway:both:buffer"=>"yes","lanes"=>"2","maxspeed"=>"20 mph","maxspeed:type"=>"sign","surface"=>"asphalt"


This contains the lanes=>"2" value.



Ensure your PostgreSQL database has the HSTORE extension enabled.


You can then query the other_tags field with something like:


select * from colorado-latest where other_tags::hstore -> 'lanes' >= '2'

Notice you are casting the other_tags column to hstore in the query (not likely to show up as hstore when loaded via qgis, and you can also alter the table type after loading to avoid having to cast if desired), and you are also using the hstore -> operator.


Query examples: http://www.postgresqltutorial.com/postgresql-hstore/


HSTORE documentation: https://www.postgresql.org/docs/9.0/hstore.html


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...