Adminitrative boundaries in Poland

Czesc everyone,

sorry, I have to post in English, but if someone comes up with a solution, I promise to improve my Polish again. :wink:
What I need is relatively simple: A digital map of Poland (which I can link with other data) that contains voivodeship, powiat, and gmina administrative boundaries. I have been experimenting with the geofabrik extracts, but when I use osmosis or osmfilter, something weird happens (I have filtered for boundary=administrative and admin_level=7 to get the gminy): Some areas in the resulting map are broken-down into much smaller parts which are not gminy.
In Openstreetmap, I have located ways in these areas which are tagged as administrative boundaries, but without an admin_level. I have not been able to filter the ways such that the “wrong” ones are eliminated, but the other ones defining gminy boundaries are kept.
Do you happen to know a solution or other data sources? I think you have just discussed the issue of borders in another thread, but I wasn’t able to understand much.

Thanks in advance.

Luźnie tłumaczenie powyższego tekstu

Cześć wszystkim ,

Przepraszam, że piszę w języku angielskim , ale jeśli ktoś znajdzie rozwiązanie, obiecuję poprawić mój polski. :wink:
Co potrzebuje, jest stosunkowo proste : Cyfrową mapę Polski ( którą mogę połączyć z innymi danymi ) , która zawiera wojewódzkie , powiatowe i gminne granice administracyjne. Eksperymentowałem z ekstraktami geofabrik , ale gdy używam osmozy lub osmfilter, coś dziwnego się dzieje (filtrowałem dla boundary=administrative i admin_level=7 , aby uzyskać gminy ) : Niektóre obszary w powstałej mapie są rozbite na wiele mniejszych części, które nie są gminami.
W OpenStreetMap znalazłem linie na tych obszarach, które są oznaczone jako granice administracyjne , ale bez admin_level . Nie byłem w stanie odfiltrować tych linii tak, aby te " złe " zostały wyeliminowane , ale inne określające granice gminy zastały.
Nie znacie przypadkiem rozwiązania lub innego źródła danych ? Myślę, że dyskutowaliście omówioną kwestię granic w innym wątku , ale nie byłem w stanie wiele z tego zrozumieć.

Z góry dzięki .

Koniec tłumaczenia.

Hello,

currently administrative boundaries are mapped using relations. This increases the likelihood of (but not guarantees, unfortunately) forming properly closed polygons. You can try extracting them using Overpass Turbo:

(
  relation
    ["boundary"="administrative"]
    ["admin_level"="7"]

  ({{bbox}}) /* this is auto-completed with the
              current map view coordinates. */

);
/*added by auto repair*/
(._;>;);
/*end of auto repair*/
out;

But I’d rather import the data into PostGIS database and export using SQL query.

I’ve done exactly this, but it doesn’t deliver the correct result. E.g. south of Warsaw, keeping only the relations does not give a closed area, but adding the ways which are administrative boundaries messes everything up there.

I’m quite new at all this, can you please give me some hints? What data from where, exporting to what with which tool/commands? Dzięki.

Which operating system do you use? And do you have any other GIS/mapping software installed?

There are three tools that could help you:
osm2pgsql - http://wiki.openstreetmap.org/wiki/Osm2pgsql
Imposm - http://wiki.openstreetmap.org/wiki/Imposm
OGR2OGR (from version 1.10) http://www.gdal.org/ogr/drv_osm.html

All of them are capable of consuming poland-latest.osm.pbf extract from Geofabrik and importing its contents to a PostGIS database. OGR2OGR can also write the data to Spatialite file-based database or shapefiles, without the need of installing and configuring PostGIS.

Win 7 64bit. I installed QGIS also PostGIS already.

Thanks, if I can run them like osmosis via batch files, then I know what to do.

My problem is that I don’t see how this helps because when I zoom very close into e.g. the problematic areas in OpenStreetMap, I can see the poorly tagged ways that are causing the trouble. But when the problem lies inside the OSM data, then how can converting and importing into PostGIS be a step to a solution?

If a boundary is properly mapped using relation, then converter won’t care about ways’ tags at all. Instead, it will try to extract member ways regardless of tagging, and build a polygon feature from their nodes. After the import, if there any gaps left, you can always fix them by hand in QGIS.
I have prepared a sample extract (WGS84 Spatialite) as a proof. It was made using osm2pgsql and patching the gaps with another OSM extract, so it might be topologically wrong. Use at own risk :slight_smile:
https://www.dropbox.com/s/pqd1jsb31u5fq19/gmina.sqlite

Thanks! Looks quite good actually, 2518 objects compared to currently 2479 gminy. May I ask about your data sources and how this patching works?
By the way, I have found maps on the Polish geoportal and osmapa.pl where the administrative divisions look quite correct, but I haven’t seen a possibility to export them or to download the underlying data. Do you know anything about whether there are possibilities?

I have just used two OSM extracts (one fresh and one from a month ago, both taken from Geofabrik), imported using two different tools (osm2pgsql and Imposm). None of them was complete due to improperly closed polygons, so I turned on editing mode in QGIS and used copy/paste features functions.

Thanks again. However, some of your tools have not been released for Win yet and the usage of those which have been released is not “trivial”, so I can’t replicate what you did.
Via JOSM, I think I found the source of the problem: There are subareas defined in some of the gminy, which I believe are known to be problematic in general. Here they indeed mess things up. Shall I remove them piece-by-piece via JOSM, or is there a faster method to get rid of them?

Nie chcę marudzić, ale ktoś nam tutaj systematycznie kasuje subarea z granic gminnych. http://www.openstreetmap.org/user/andreasb85/history

Please do not remove the subarea within the administrative boundaries relations in Poland.
They are very important in determining the relationship between the borders of parent and child. They also help prevent the creation of duplicate borders by JOSM.

Hi,

sorry for beginning the removal without informing.
I have browsed OSM boards and I haven’t found something that would justify your concerns. Subareas are noted as “Optional, disputed and redundant” here: http://wiki.openstreetmap.org/wiki/Relation:boundary#Relation_members
I’ve followed some recent discussions within the German-speaking community and there the prevailing point of view is also that subareas are redundant and in fact undesirable. A German user wrote: “The same can be achieved via a simple spatial query in an osm2pgspl-generated database. And exactly this type of database is used by the large majority of mappers, if they use a database at all.”
One of the reasons why they are undesirable in my view is that (as far as I know) one cannot filter them with osmosis, osmfilter, etc. See the simple task I’ve described at the beginng of the thread: Obtain a map of Poland with administrative boundaries at the level of gminy.
If you run osmfilter with

--keep-nodes="admin_level=7" --keep-relations="admin_level=7" --keep-ways="admin_level=1 =7"

on a Geofabrik extract from the beginning of the week, the result looks like this:

Now, after removing quite a lot of subareas, the result is:

I dare say the latter looks much closer to the correct depiction. Sorry again for deleting without notice and if this makes someone’s work with the subareas redundant, but so far I see no reason to keep the subareas.

No i usunął masowo wszystkie relacji między granicami dla całej Polski.
Czy to nikogo więcej nie interesuje?
Relacje miedzy granicami nadrzędnymi i podrzędnymi są opisywane zgodnie z zaleceniami na Wiki, które na dzień dzisiejszy nie zostały wycofane.
Gdy zostaną usunięte wszystkie relacje granic w Polsce, nie będziemy mieli możliwości stwierdzić, czy są już jakieś, lub możemy zacząć rysować duplikaty.

To, że jakiś oprogramowanie nie może wybrać poprawnie odpowiednich danych, to nie znaczy, że ktoś nie napisze jutro oprogramowania które to zrobi.
Przyjęliśmy zasadę, że nie tagujemy pod Render, tylko staramy się bazować na aktualnych zaleceniach na Wiki.
Jeśli te “subarea” zostaną usunięte, to ja rezygnuję z rysowania granic.
Obecnie przy ich rysowaniu w JOSM nie widzę innych linii poza liniami granic, a w bocznym oknie Relacje mam ich listę jako “subarea”. Tak więc wiem szybko, które są narysowane a których brak.
Rysowanie granic jest bardzo czasochłonne i dodatkowe włączanie innych podglądów przekracza moje możliwości.

I’m not an expert in this but to my knowledge OSM Poland has a bit different naming convention. Gmina is not lowest dividable area. I believe village is. If You find it as deviation, please keep in mind that Poland unlike UK has a weak userbase, and there are dozens not thousands of senior members, and there are few who make imports of data like village boundaries in Poland.

I’m sure other guys will comment this further.

Tomek

Zgadzam się z Władysławem.
O wiele łatwiej edytuje się granice, korzystając z subarea w JOSM.
To, że uznano taki sposób za opcjonalny nie powinien oznaczać, że można sobie to usunąć bez uzgodnień z naszą społecznością w Polsce.

Przykład w Poznaniu: http://www.openstreetmap.org/relation/165941
Granice były posklejane, wybrakowane. Teraz po korekcie, pobierając relację granicy miasta i pobierając członków podrzędnych od razu widać, czy ktoś czegoś do tych granic nie przykleił.
Oczywiście nie wszystkie jednostki pomocnicze zostały włączone jako subarea, ale jest to jak napisał Władysław, bardzo czasochłonne.
Teraz co!? Mam edytować dalej!?

andreasb85 I’m sure You’ll become a celebrity with Your own haters here :slight_smile:

Andreas,
bitte Deine Änderungen ASAP rückgängig machen. Sonst muß ich bitten, dass man Dich sperrt.
Bevor man als Neuling eine Aktion in einem anderen Land macht, bitte diese nicht nur umfassend auf die Besonderheiten in einem anderen Land prüfen:
Die Ansichten der Community in der BRD müssen hier erst Mal Akzeptanz finden.

Hochachtungsvoll,
Marek

Po polsku:
proszę o natychmiastowe cofnięcieTwoich zmian. Jeśli nie, wystąpię o bana dla Ciebie.
Zanim jako nowicjusz zabierzesz się za taką akcję powinienieś postarać się zrozumieć odrębności występujące w danym kraju:
Poglądy społeczności z RFN muszą tutaj najpierw zostać zaakceptowane.

Jak to jest możliwe, że ktoś jest na OSM od 13 dni i jedyne co zrobił to usunął około 650 relacji dotyczących tylko Polski :slight_smile:

To wolny projekt. Wiec wolno.
Jak chcesz, mozesz wykasowac granice w RFN, tylko po co. W RFN byla na talk-dedyskusja o oczyszczeniu granic i po konsultacjach zrobili to u siebie, przy okazji konczac domykanie granic m. in granic obszarów kodów pocztowych (PLZ) . Chlopak przeczytal i chcial dobrze za granica.