How can i get the nearest significant town or city from google maps?
Asked Answered
G

3

5

Is this possible?

I have users who will show where they live on a map, if this isn't a large town or city, i'd like to find that and associate this information with the users record.

Any idea how to do this?

Groundless answered 2/8, 2011 at 13:24 Comment(2)
check this post similar question https://mcmap.net/q/764312/-reverse-geocoding-with-google-map-api-and-php-to-get-nearest-location-using-lat-long-coordinates/760489Bellwort
nah - that will give me the village or town they are in - not the nearest significant town. so if they live in the sticks, i need to know the nearest large town or city to themGroundless
C
4

Why not use the GeoNames Web Service. You can download the complete dump.

It takes Lat/Lng as parameters and also there is an optional parameter called radius(distance in km) as well as parameter cities where:

cities1000.zip : all cities with a population > 1000 or seats of adm div (ca 80.000)

cities5000.zip : all cities with a population > 5000 or PPLA (ca 40.000)

cities15000.zip : all cities with a population > 15000 or capitals (ca 20.000)columns

Comfy answered 4/6, 2014 at 18:4 Comment(2)
The link you provided is giving an error. I will like to know of an API where I provide a location and a radius, and it returns all the locations (towns etc) within that radius. I dont want locations as provided in Google Places API such as cafe, museum etc.Calzada
I've updated the link. The webservice isn't useful for this use case, but you can download a complete dump.Christadelphian
I
3

I realize this is an old post; however, I'm posting my views for the benefit of the people who stumble upon this post (like I did) in their research.

In order to find the largest/closest large city/town you would need to define 'large'.

  1. What is a large city/town? This is completely subjective - my definition will be different from yours. A mapping service, cannot decide the definition of 'large'.

  2. Priority of large cities? Let's say even if you somehow achieved #1, how will you prioritize. A 'small' town X might have 2 large cities close to it - A & B. Which one would you accept?

Based on the two statements above, I advice you against it; however, if it is impossible for you to avoid this, you would need to put in custom logic in your application. Example: Get all locations within 25 miles and decide for yourself what place you want to save.

Isidore answered 31/7, 2013 at 20:9 Comment(1)
which API I can use that will give me all the locations within a specified radius? By location I dont mean cafe, hospital, museum etc, I mean an actual town/city.Calzada
O
1

I struggled to find the best way to do this for a while. Google's API seems to mostly use addresses/town boundaries when decoding coordinates, which is unhelpful.

If you're in the United States, the National Weather Service's API is perfect. Given coordinates in the US, it can provide the nearest town/census-designated place and the point's distance and direction from the town.

I created a basic site to try it out at https://nearest.town/

Oneiromancy answered 31/3, 2021 at 2:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.