3

I want to put the coordinates of cities in a spatial db and then find cities from a given city at some given distance. I am hoping these functions would be readily available in a spatial db like PostGis. First, am I right in assuming this?

The problem I am facing though is this - I do not know where to store these coordinates from. I have this with me - http://download.geonames.org/export/dump/ and it has a 290 mb file (allcountries.zip) with coordinates of all cities but I am not sure how accurate it is. I am going to use this data to build something important so I want to know if someone here uses something more accurate or concise.

If the cities are much farther apart, just the latitudes and longtitudes won't do right? Will need something like spatial ref Ids also? Please suggest the right approach.

Also, given so much info, how does one proceed to find cities from a given city and given distance?

closed as too broad by PolyGeo May 1 '16 at 20:59

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

2

I am hoping these functions would be readily available in a spatial db like PostGis. First, am I right in assuming this?

You're asking if PostGIS can find points within a certain distance of a given point? Yes, it can.

I am going to use this data to build something important so I want to know if someone here uses something more accurate or concise.

What do you think is wrong with the dataset you have? Why not try it and see? Are you concerned there are too many small places in it?

If the cities are much farther apart, just the latitudes and longtitudes won't do right? Will need something like spatial ref Ids also?

If you're asking, does the data have to be in a projected format (with a given SRS identifier) in order to do what you want, then no - there's no problem either using the data in its current unprojected form (EPSG:4326) or projecting it to another system if needed.

How does one proceed to find cities from a given city and given distance?

See Return all results within a 30km radius of a specific lat/long point?

2

Depending on what you like I think you have a few options available. You will need two components

  1. The Location of the cities X,Y
  2. An Origin Destination Matrix (this requires a Network in order to function)

OpenSource: Section 1(the location of the cities)

node [place=city]({{bbox}}); out; the Overpass API Language can consume the Place Tags from the OpenStreetMap Tags

Section 2(an origin destination matrix)

Google:

Section 1(the location of the cities)

  • using natural earth data above, gather the Lat/Long of each city

Section 2(an origin destination matrix)

ArcGIS Online

You can use the Connect Origins to Destinations function on ArcGIS Onlineenter image description here

2

There is no absolute accuracy in city coordinates.

For example, New York City is 1214 km² large, and there is no definition which point is New York City. You can take the centroid of the border, or the Town Hall, or any point within the border you might prefer.

  • Agreed! So, isn't there a dataseet with these centroids? – Kumar Vaibhav Sep 1 '15 at 5:40
  • You can get the borders out of the Openstreetmap database from osm.wno-edv-service.de/boundaries by expanding the tree on the left, select your area, then export at the bottom to shp. Calculating centroids is a simple task for all GIS software. – AndreJ Sep 1 '15 at 5:54
  • BTW calculating the centroid in UTM or any other projected CRS might give you a slightly different centroid point than doing it in WGS84 latlong degrees. – AndreJ Sep 1 '15 at 6:14
  • Thanks for your response! See this is what I am talking about - I don't know what a WGS84 is or what a UTM is. – Kumar Vaibhav Sep 1 '15 at 10:18
  • 1
    "I don't know what a WGS84 is or what a UTM is" - you can Google these terms. Please do some of your own research, thanks. – Steve Bennett Sep 1 '15 at 13:48

Not the answer you're looking for? Browse other questions tagged or ask your own question.