Help needed with query (newbie)

I’m very new to overpass queries, and I need help with a tricky one. I am trying to query OSM for continental Australia (including Tasmania). When I do a query for Australia I get continental Australia plus all its external territories, i.e. Christmas Island, Cocos-Keeling Island, Lord Howe Island, Norfolk Island, Willis Island, Mellish Reef, Heard Island & Macquarie Island (and probably a few others).

So I have developed the query below which queries the combination of all Continental states. It improves the situation - many of the external territories are now excluded, but a few remain. Places like Lord Howe Island and Heard Island are still being returned though. How can I tweak this query to exclude a few relations I don’t want?

As a further question, the boundaries returned are administrative ones, i.e the territorial limit. I really just want the actual coastline.

[out:json][timeout:100];
(
nwr[“ISO3166-2”=“AU-ACT”];
nwr[“ISO3166-2”=“AU-NSW”];
nwr[“ISO3166-2”=“AU-VIC”];
nwr[“ISO3166-2”=“AU-QLD”];
nwr[“ISO3166-2”=“AU-SA”];
nwr[“ISO3166-2”=“AU-WA”];
nwr[“ISO3166-2”=“AU-TAS”];
nwr[“ISO3166-2”=“AU-NT”];
nwr[“ISO3166-2”=“AU-JBT”];
);
way(r);
out geom;

Maybe you are looking for Linestrings for coastlines?
You can open it in QGIS and select the coastlines and generate a new layer with the selection. Just in case that is the purpose of the query.

If it is about searching for elements within a polygon area you can use something like this
by polygon

[out:xml][timeout:125];
way[natural=coastline](poly:"-21.330274 112.368120 -18.854269 116.367144 -18.854269 120.805620 -16.256825 121.728472 -14.689839 123.046831 -14.264340 124.233354 -12.726041 125.683550 -13.581878 128.320269 -10.185144 129.858354 -9.925523 133.417925 -10.487769 138.076128 -14.434638 139.482378 -10.962753 141.295155 -10.865665 142.152089 -10.606609 142.492665 -10.709187 142.671201 -11.040949 142.888181 -11.517702 142.940366 -11.544614 142.896421 -11.716786 142.882688 -11.861973 142.965085 -11.883475 143.160092 -11.904976 143.286435 -12.060806 143.363340 -12.318533 143.302915 -12.495574 143.324887 -12.618895 143.519895 -12.873390 143.591306 -13.218551 143.635248 -13.918067 143.816523 -14.280349 143.937372 -14.237761 144.188689 -14.252403 144.301299 -14.273698 144.367217 -14.139238 144.485320 -14.177853 144.578703 -14.428029 144.707792 -14.595543 144.872588 -14.602188 144.906920 -14.635409 144.942626 -14.813386 145.298308 -14.973972 145.441130 -15.215287 145.384825 -16.037892 145.711667 -17.109290 146.159360 -18.169337 146.716916 -18.875100 146.826779 -19.660691 147.958371 -20.019802 148.837275 -20.272498 148.831782 -20.596789 149.024042 -21.596145 150.303950 -23.241326 152.446267 -26.568857 156.994607 -33.339689 153.478982 -44.918123 147.678201 -44.221576 144.832753 -39.010630 140.383279 -34.723537 125.969217 -36.562582 116.015603 -32.546795 112.785623 -24.006306 111.621072");
out geom;

tell us what the purpose is to better refine the response :sweat_smile:

How about relation 4095122, “Mainland Australia”?

[out:json][timeout:100];
relation(4095122);
>; out;

This returns quite a lot of data - you might try Overpass Ultra which handles things like that better.


Edit: If the downloaded stuff is too much, you could try using some GIS software to simplify and reduce it.

I found this feature by the following:

You might follow a similar procedure to find a feature that meets your requirements for Tasmania too.

It’s 50Mb of data. It also doesn’t include Tasmania. When I include Tasmania, Heard Island is also in there. How did you find “Mainland Australia”? When I search for “Australia” I didn’t get it returned. Will look into Overpass Ultra.

I tried your zooming in technique, but it doesn’t work for me. I just get a browser context menu on right click. Left click shows me the way involved.

A solution would be for me to put a bounding box “(-44,110,-10,154)” into a query like that below, but I can’t work out where to put it.

[out:json];
(
nwr[name=“Mainland Australia”];
nwr[name=“Tasmania”];
);
way(r);
out geom;

I am looking for linestrings of country boundaries, but I have 340 ‘countries’ to do, so I wish to do it programatically, not using QGIS.

On close inspection, “Mainland Australia” is literally that - it does not include some close islands, like Kangaroo and Rottnest islands for instance. I’m back to my original question - how do I modify the query below to add a bounding box “(-44,110,-10,154)” ?

[out:json];
(
nwr[name=“Australia”];
nwr[name=“Tasmania”];
);
way(r);
out geom;