Visualizing Vietnamese districts in 2019

I use this query to visualize Vietnamese districts:

[out:json];
rel(id:49915)->.a;
rel(r.a:'subarea')['boundary'='region']['admin_level'=3]->.b;
rel(r.b:'subarea')['boundary'='administrative']['admin_level'=4]->.c;
rel(r.c:'subarea')['boundary'='administrative']['admin_level'=6];
out geom;

Is there a way to do the same thing on attic data (in my case, data from 2019-12-01T00:00:00Z)? I tried adding [date:] to the query, but it always timed out.

The date: option is correct, but it does tend to make queries time out more easily. You can try increasing the timeout using the timeout: option. If you start hitting the memory limit, you might also need to increase the maxsize:.

If you don’t specifically need to verify that the boundaries are all subareas, you could also try simplifying your query. The following query completes for me in about 100 seconds. However, it includes a few false positives in neighboring countries, due to slight differences between the district boundaries at the time and the area computed from the present-day national boundary.

[out:json][timeout:120][date:"2019-12-01T00:00:00Z"];
rel(id:49915);
map_to_area;
relation["admin_level"="6"](area);
out geom;
1 Like

Sure, it seems to be working as you described, but is there another way to get the exact districts without using date:?

Not sure I understand – date: is how you’d query OSM data from a particular time in the past. Is there some other question you want answered, like districts that previously existed in the real world?

Or do you mean you’d like to get the same results as my query, but without the spillover in other countries? You could use the subarea-based query as before, but with a higher timeout.

1 Like

I would be glad if you could find such a tweak that both avoids the spillover and the timeout

While it isn’t strictly scientifically correct, you could filter by some known differences between Vietnamese districts and equivalent administrative areas in neighboring countries. For example, only China’s administrative areas have Chinese characters in name=*, and only Laos is tagging its districts with Lao characters or DNAME=*:

[out:json][timeout:120][date:"2019-12-01T00:00:00Z"];
rel(id:49915);
map_to_area;
relation["admin_level"="6"]["name"!~"[县区市岛]"]["alt_name"!~"ເມື່ອງ"][!"DNAME"](area);
out geom;

There is still one false positive, which doesn’t make sense to me. I wonder if it’s a bug in Overpass.

Another heuristic you could use is that only Vietnamese districts are being tagged with links to the Vietnamese Wikipedia:

[out:json][timeout:120][date:"2019-12-01T00:00:00Z"];
rel(id:49915);
map_to_area;
relation["admin_level"="6"]["wikipedia"~"^vi:"](area);
out geom;

Going forward, we could also facilitate similar queries by setting each Vietnamese administrative boundary’s border_type=* to a country-specific value such as province, district, or municipal_city.

Incidentally, if you’re interested in the districts because of the planned reorganization of Vietnam’s administrative areas, you might want to connect with this user who has been adding some district boundaries to OpenHistoricalMap, where historical boundaries can go for safekeeping.

1 Like

I guess the Overpass API just cannot handle attic data efficiently then…

Unfortunately, if no query can work properly, then I cannot close this topic