I have written a PostGIS query on a database with OSM data of the state of Baden-Württemberg.
So it turns out that not all cities/towns have an admin_level tag of 8. Is there any way we can further constrain the query to filter out only the towns/cities? asked 08 Mar '19, 05:19 Sujay |
Posting your question in multiple places at once is impolite. It can lead to several people answering your question, without knowing that it has been answered already elsewhere. It means that you just think of yourself (maximizing your chance of getting an answer) and you don't care if you waste the time of others. Think about that before you do it next time! The reason that not all cities in Germany have an admin_level of 8 is that there are some "kreisfreie Städte" which use admin_level 6 (and, outside of Baden-Württemberg, even two "Stadtstaaten" which use admin_level 4). Finding the cities that do not have an admin_level 8 tag but instead an admin_level 6 tag could be done like this:
The "left outer join" instructs PostgreSQL to find pairs of adminlevel 6/8 entities where the adminlevel 6 entity covers the adminlevel 8 entity, and to set the adminlevel 8 entity to NULL if none is found matching this criterion. Then, we only select those adminlevel 6 entities where the adminlevel 8 part is NULL, i.e. those that have no "children" on admin_level 8. answered 09 Mar '19, 23:48 Frederik Ramm ♦ Thank you so much for your answer Frederik! I'm sorry, I will make sure not to post it in multiple places from next time. Thanks again.
(10 Mar '19, 07:46)
Sujay
|
crosspost: https://gis.stackexchange.com/questions/314806/extracting-all-cities-from-a-state-using-postgis