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?

PolyGeo
  • 65,136
  • 29
  • 109
  • 338

3 Answers3

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?

Steve Bennett
  • 5,682
  • 2
  • 44
  • 69
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

MDHald
  • 1,871
  • 13
  • 20
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.

AndreJ
  • 76,698
  • 5
  • 86
  • 162
  • Agreed! So, isn't there a dataseet with these centroids? – Kumar Vaibhav Sep 01 '15 at 05:40
  • You can get the borders out of the Openstreetmap database from https://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 01 '15 at 05: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 01 '15 at 06: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 01 '15 at 10:18
  • WGS84 is the coordinate system taht uses degrees, while UTM uses meters (https://en.wikipedia.org/wiki/Universal_Transverse_Mercator_coordinate_system). For NYC, I get 25m offset between the centroids. With GIS software like QGIS, you can reproject points or border lines between any coordinate systems. – AndreJ Sep 01 '15 at 10:23
  • 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 01 '15 at 13:48