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
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.
-- 2. get id of the relation(s) that are inside the polygon, need the items with negative osm_id
-- 3. get the outer way from planet_osm_rels table
-- 4. get the nodes from planet_osm_ways
-- 5. get the way's nodes data of the from node table
I checked it on few locations and its seems to work, of course need to rewrite the queries more efficiently. answered 30 Jan '19, 14:12 altopalo |
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.
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.
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.
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.
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.
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" ...
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"?
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.
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.
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?