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

Hey guys, I am looking for a function in python that has only latitude and longitudes as input values and gives me the landuse as output value. It is basically enough to know if the location is in a building or not. The type of building is not so important. I already checked in the osmnx library based on Open Street Map, but couldn't find anything that matches my question. But maybe osmnx already offers the solution and I did not see it.

The solution should be something like: landuse = ??function??(lat, lon) And than the output might be "residential_building" or "agricultural_open_area".

I am glad for any helps Greetings Chris

This question is marked "community wiki".

asked 26 May '19, 15:20

Chris_Ali_del_Vari's gravatar image

Chris_Ali_de...
11112
accept rate: 0%


You could do it with Overpass (same as the web site does when you click somewhere with the question mark icon) though if you'd like to run this more frequently, using Overpass runs the danger of making the server unusable for others. Therefore you'll want to load the OSM data into your own PostGIS database with osm2pgsql. Then you can make queries like

SELECT "natural",landuse,building FROM planet_osm_polygon WHERE ST_Contains(way, ST_MakePoint(lon,lat))

(note that for this query to work, you need to run osm2pgsql with -l option, or you might need a ST_Transform around your ST_MakePoint).

permanent link

answered 26 May '19, 17:32

Frederik%20Ramm's gravatar image

Frederik Ramm ♦
82.5k927201273
accept rate: 23%

Thank You for the fast answer. I am sure the way You described works well. Unfortunatly I don't know much about Overpass and don't know how to integrate it into Python, so I am trying a different approach with a downloaded .shp file from the city and the sjoin command of the geopanda tools. Got the approach from a Youtube Tutorial and it seems to work for me as well: https://www.youtube.com/watch?v=HzPSVwyP2Y0

(30 May '19, 22:30) Chris_Ali_de...

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:

×78
×55
×6
×5
×2

question asked: 26 May '19, 15:20

question was seen: 2,323 times

last updated: 30 May '19, 22:30

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