How to get the specific names of specific geographical locations?

Dear people, I need your valuable support and I will be infinitely grateful for your help.

My request is as follows: I want to get the proper names of all seas, all lakes, all rivers, all straits, all bays, all mountains, all islands, all peninsulas, all forests, all deserts, all cities, all villages and other special geographical places on our planet using Python or Overpass Turbo, only in English, without unnecessary coordinate data, without unnecessary descriptions, without unnecessary numbers and other unnecessary characters. Just clear, simple names.

Can someone help me create a standard programming language code that will allow me to get the proper names of all the necessary special geographical places I have specified with minor edits?

Thank you all in advance and I look forward to your feedback.

I spent several weeks trying to get what I wanted through artificial intelligence, but unfortunately to no avail…

1 Like

My first thought is “just download the planet file and extract what you want from it”. I appreciate that it does not involve overpass, but if you want “all” of “quite a lot of things”, it may be the best answer.

Perhaps it would help if you added a bit more detail about what your goal is?

2 Likes

How do I do that, dear friend?

It’s not that difficult, just answer this question:

As an example of why this matters: the requirement for only English names could be quite complex. Do you really want only natural objects that have names in English - so you’re not interested in most natural objects in non English speaking countries? Or are you really looking for all natural objects, and you meant “English names where available” or “names transliterated to Latin script”? It all depends what your objective is. Without knowing that, someone could spend a lot of time suggesting a solution that doesn’t meet your objectives.

It might also help to indicate how far you have got given that you have been working on this for a while. E.g. can you extract what you need for one object, or objects in a small area, and your problem is how to scale up to the whole world?

2 Likes

You clearly have a problem that you want to solve. The problem with requests like

is that there are lots of ways that that could be done - and each one will be appropriate for a different problem… For example, I could guess that you just want to be able to extract OSM objects by tag and could help you with the osmium documentation, but if you want a query that can be run from a mobile app, location specific, on the fly, then that is not going to be helpful.

@alan_gr mentioned one of the “elephants in the room” - “English names where available”. Another is how you’re going to process the different type of OSM data. A “village” made be a node or it might be a way or a relation. In the case of the latter two, would you want something describing the (multi)polygon of the OSM object or do you just want a centroid?

Dear user, I just need a standard code, within which, by making minor changes to the internal parameters, I will be able to separately obtain the proper names of various geographical places (for example, seas, lakes, rivers, waterfalls, islands, peninsulas, forests, mountains, deserts, cities, villages, etc., etc.) at different times.

I just want all the results to be in Latin letters, even the local names of all places in the world, but without coordinates, that is, only clear proper names.

I want the format to be only CSV.

In short, I want to have one common standard code, where by changing the appropriate internal tags I will be able to obtain the proper names of the most diverse geographical places both on a global scale and on a scale of individual countries.

Here’s a Python script exactly for your requirement :rocket:

Script
import pandas as pd
import requests
import unicodedata

GEONAMES_USERNAME = "ella"
FEATURE_CLASS = "P"
COUNTRY = ""
OUTPUT_FILE = "geo_names.csv"

# Of course this is crap code, if you read this, make your requirements clearer please :)

BASE_URL = "http://api.examplegeonames.org/searchJSON"
PARAMS = {
    "featureClass": FEATURE_CLASS,
    "country": COUNTRY,
    "maxRows": 4,
    "lang": "en",
    "username": GEONAMES_USERNAME
}

def fetch_geographical_names():
    response = requests.get(BASE_URL, params=PARAMS)
    if response.status_code == 200:
        data = response.json()
        return data.get("geonames", [])
    else:
        print("Error fetching data")
        return []

def transliterate(text):
    return unicodedata.normalize("NFKD", text).encode("ASCII", "ignore").decode("utf-8")

def extract_names(data):
    return [transliterate(place["name"]) for place in data]

def save_to_csv(names):
    df = pd.DataFrame(names, columns=["Geographical Name"])
    df.to_csv(OUTPUT_FILE, index=False, encoding="utf-8")
    print(f"Data saved to {OUTPUT_FILE}")

if __name__ == "__main__":
    places_data = fetch_geographical_names()
    place_names = extract_names(places_data)
    save_to_csv(place_names)
3 Likes