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

Hello, I need to get cities boundaries, I know how to do it by query the planet_osm_polygon table and get the exact result as in www.openstreetmap.org but its differ from the real city area as marked in grey

e.g Towcester: https://www.openstreetmap.org/relation/1641604

As it can see the area marked in orange is much bigger than the city area

asked 24 Dec '18, 15:08

altopalo's gravatar image

altopalo
5381013
accept rate: 0%

edited 24 Dec '18, 15:09

2

What do you mean by "the real city area" exactly? It looks like the "area marked as grey" is mapped as landuse=residential. It doesn't correspond to any administrative boundary and naturally a city may have other landuses such as commercial or industrial.

(24 Dec '18, 15:29) alan_gr

Tn'x for the data So I looks for a way to get that 'grey area' (landuse=residential) from the osm dump DB. I assume the area I gets and also seen in the map is the administrative area of the city.

(24 Dec '18, 15:52) altopalo
3

Landuse=residential has nothing to do with administration, it simply marks areas of land that mappers perceive as primarily used for housing.

If you want adminstrative areas you will need to look at boundary relations, but that seems to be where you started as you already gave an example of such a relation.

(24 Dec '18, 18:35) alan_gr

Tn'x but I know how to get the administrative area.

I'm looking for a way to get the Landuse=residentialstrative area of specific city by query the postgis DB.

(25 Dec '18, 07:28) altopalo
2

Well, you'd query the database the same way as you did for the administrative boundary, but instead query for landuse=residential objects. As has been mentioned, though, this won't give you the complete area of a settlement. There will likely also be landuse=industrial, landuse=commercial, landuse=retail, leisure=park, amenity=school, and many other types of areas that together combine to form the area of the settlement. This also assumes that the landuses and other areas have all been mapped, which isn't guaranteed.

(27 Dec '18, 16:56) alester

Thanks @alester Tried your advice and indeed I get a list of polygons inside the polygon I want to, but if i look e.g: on the landuse=residential some are really residential but some are not truly place of people (the gray areas in the map)

e.g this query about Buckland (village in UK)

select i.osm_id, i.name, i.landuse from planet_osm_polygon i join planet_osm_polygon o on ST_Contains (o.way, i.way) where o.osm_id = -4108597 and i.landuse = 'residential'

94353763;"";"residential" 203007994;"";"residential" 203007897;"";"residential" 195214668;"";"residential" 59825490;"Ashtree Farm";"residential" 187233334;"";"residential" 95029739;"";"residential" 94441095;"";"residential" 98217350;"";"residential" ...

(29 Jan '19, 14:41) altopalo
1

You say "some are really residential but some are not truly place of people". Can you give an example of one in that area that is "not truly place of people"?

(29 Jan '19, 15:12) SomeoneElse ♦
1

Do you mean Ashtree Farm ? It's mapped as a residential area, it's "grey" on the map. It's probably the area around the farm house. A place where people live, hence landuse=residential is correct.

Maybe this does not correspond to the area's you want to extract, but I fear that your definition of "city boundaries" does not match any OSM concept, as others pointed out.

(30 Jan '19, 04:09) escada

thanks @SomeoneElse & @escada

e.g: 94353763: https://www.openstreetmap.org/way/94353763 - green area

1369487 : https://www.openstreetmap.org/relation/1369487 is the village and what I need.

What i'm tying to do is by getting a point, decide if its urban area or not.

(30 Jan '19, 06:18) altopalo

I'm not sure why you say 94353763 is a green area. It happens to be surrounded by a wood, but the area itself consists of houses and their gardens (visible in any aerial imagery background) so its mapping as residential is correct, and so is its display as grey in the standard map.

What do you see as the difference between these houses and the ones in 1369487 that qualifies one group of houses as urban and not the other?

(30 Jan '19, 11:57) alan_gr
showing 5 of 10 show 5 more comments

Thanks all for the great info, after some digging I found the way to do what I need.

The purpose is to find the residential boundaries of a given settlement (city, village). for my purpose a farm or few houses alone is not urban so I don't need it

So here are the steps I done, if someone will need it also:

-- 1. find the polygon of the city/village (actually I already have the osm_id of the village in my DB, but to complete the explanation ...) This returned a polygon that include the village but a lot of open areas around it.

select name, osm_id from planet_osm_polygon where name = 'Buckland'

-- 2. get id of the relation(s) that are inside the polygon, need the items with negative osm_id

select i.osm_id, i.name, i.landuse 
from planet_osm_polygon i join planet_osm_polygon o on ST_Contains (o.way, i.way) 
where o.osm_id = -4108597 and i.landuse = 'residential' and i.osm_id < 0

-- 3. get the outer way from planet_osm_rels table

select * from planet_osm_rels where id = 1369487;

-- 4. get the nodes from planet_osm_ways

select * from planet_osm_ways where id = 94437443;

-- 5. get the way's nodes data of the from node table

select * from planet_osm_nodes where id = 1096978061;

I checked it on few locations and its seems to work, of course need to rewrite the queries more efficiently.

permanent link

answered 30 Jan '19, 14:12

altopalo's gravatar image

altopalo
5381013
accept rate: 0%

edited 18 Feb '19, 15:58

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:

×129
×2

question asked: 24 Dec '18, 15:08

question was seen: 3,386 times

last updated: 18 Feb '19, 15:58

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