Getting distance between multiple cities - google-maps

I'm looking for an easy way to find out the distances in miles (as the crow flies) between multiple cities.
Example (New York):
New York, NY - Tampa, FL
New York, NY - Las Vegas, NV
New York, NY - Moscow, Russia
etc
I have over 20 cities that I need to determine the distance between... That's a lot of looking up to do manually (not just between the main city and other cities but between every city and every city)...
Any ideas?

Once you get the latitude/longitude from the Google Maps API geocoder, you can use the Geometry library to calculate the distances between them.
http://code.google.com/apis/maps/documentation/javascript/geocoding.html
http://code.google.com/apis/maps/documentation/javascript/geometry.html#Distance

The Google Maps API might help you get the Latitude and Longitude of each, then you could use an algorithm (like http://www.movable-type.co.uk/scripts/latlong.html) to calculate the distances.

Related

What is maximum points limit for Google's heatmap feature?

Hello there's I am use google's Heatmap feature in my project. I do not know whats the maximum points (latitude ,longitude )limit for google's heatmap to visualization.
There is no limit to the number of points added to the heatmap, but there are practical constraints (the memory of the device displaying them, the time to load them, etc.)
Longitude is in the range -180 and +180 specifying coordinates west and east of the Prime Meridian, respectively. For reference, the Equator has a latitude of 0°, the North pole has a latitude of 90° north (written 90° N or +90°), and the South pole has a latitude of -90°.
The limit is for longitude and latitude not for google heatmap feature for using latitude or longitude. If your latitude/longitude is in valid range , it will work.

Regions of England in Google Maps API

I have a list of latitude/longitude which point to some cities in England.
For each of these coordinates I want to get the region they belong to.
By region, I mean one of these: https://en.wikipedia.org/wiki/Regions_of_England
For instance: For coordinates (53.38112, -1.47008), ie. Sheffield, I need to find Yorkshire and the Humber.
To achieve this, I tried to use Google Reverse Geocoding API:
https://maps.googleapis.com/maps/api/geocode/json?latlng=53.38112,-1.47008&key=
Google then tells me that:
country is United Kingdom
administrative_area_level_1 is England, which is a State (or kind of)
administrative_area_level_2 is South Yorkshire, which is a County
administrative_area_level_3 is Sheffield District, which is a District
So Google returns me the correct State, County and District. However, Region is missing.
Is there any way to obtain it?
Looking at the documentation I don't think the Google API returns such information.
An alternative way to get round this would be to build a list of which counties belong in which of the 9 regions and then look up the region based on the county name. Obviously, this would be a bit of work on your part putting all the county names into a list.
While this doesn't directly answer your query, you could use a set of polygons which trace the regions and a point in polygon algorithm (this example is in PHP but the algorithm exists in many languages) which would allow you to check which of the regions any latitude and longitude is in

Is there a numeric road identifier in google maps?

I'm looking for a way to identify roads or streets on google maps.
I don't need the road name, just an identifier for a road. And I don't really care if GPS coordinate is really on the road as long as the results are consistent.
I need this in order to determine if two GPS coordinates are on the same road.
Now I know I can compare the road name between the two coordinates using geocoder but In some cases the road name is null, and I actually don't care about the name itself.
Is there any road ID that I can get using a geocoder ?
What do you mean by the 'same road'?
A road can have many different names and designations at the same time and over its length.
Consider Route 66 do you want to be considered to be on the same road if you are on the same road if your two locations are on route 66 near Los Angeles and Chicago or is it a series of different roads as wends its way through the cities en-route?
Should a road have a different id if has an arbitrary name change as it goes round a bend or crosses from one town to the next?

package for geocoding (street location!) and next calculation of distance

EDIT: And package for not geographical distance between two lan-long points, but distance by car, or foot (like this http://code.google.com/intl/sk/apis/maps/documentation/directions/) Travel mode - driving, walking. No map, just distance. Thanks for any idea.
Hello. I search package in R, what gives me longtitude and latitude for data frame with 10000 locations like this "STREET, town, Europe".
And then package, what gives me distance per haversine formula for those locations. But mainly package for lat-long.. Distance should be easy.
I searched a lot but found nothing useful for me. Thanks for help! I hope that R knows it :)
Package dismo has address level geocode(), though installation can be difficult on some platforms.
Package sp has WGS84 ellipsoidal distance in spDistsN1().
Getting street locations is going to need google's help or similar. Or possibly OpenStreetMap, but I'm not sure what the API is:
http://nominatim.openstreetmap.org/
For just cities, search the geonames database for populated places using my geonames package:
>library(geonames)
> GNsearch(q="Toronto",fcode="PPLA")
countryName adminCode1 fclName countryCode lng
1 Canada 08 city, village,... CA -79.4163
fcodeName toponymName fcl name fcode
1 seat of a first-order administrative division Toronto P Toronto PPLA
geonameId lat adminName1 population
1 6167865 43.70011 Ontario 4612191
You may use function 'mapdist' in 'ggmap' package
See package 'geosphere' for distances between lon/lat points.
'gdistance' does things like cost-distance (on grids).
For distances along roads etc perhaps you can use igraph
You could try looping through your addresse using this method.
Or leave R and take advantege of Python's geopy.

How to map google Geocoding API results to simple City, Region, Country

I have some markers on a map and when the user click them I use the google geocoder to get the address information. The issue is the format that Google returns this data. I want to display the address in a consistent format such as
Vancouver, British Columbia, Canada
Seattle, Washington, United States
Sydney, New South Wales, Australia
does any one know a simple way to parse this data so I end up with some nice simple json like
{"city":"Vancouver", "region":"British Columbia", "country":"Canada"}
Thanks.
Oh man, the days when I thought political geography was this simple were sweeter days. If Google could return data like this, they surely would. Instead you get a mess of locality, sublocality, administrative_area_level_*, country, etc.
To illustrate this, consider the following:
http://maps.googleapis.com/maps/api/geocode/json?address=11215&sensor=false
http://maps.googleapis.com/maps/api/geocode/json?address=10010&sensor=false
For Manhattan, you're in okay shape. You get the borough (Manhattan), the city (New York), the county (New York), and the state (New York). For Brooklyn, things aren't so clean. You get the borough (Brooklyn), the county (Kings), and the state (New York).
Now if you go a little ways out onto Long Island, you get more fun:
http://maps.googleapis.com/maps/api/geocode/json?address=40.723464,%20-73.716282&sensor=false
In this case you get the village (Floral Park), the town (Hempstead), the county (Nassau), and the state (New York), but everything is kind of muddled up.
This is the variation within 20 miles in one state. If you move out of that, you can count on even less. In the UK, what most of what we'd want to see as London, will be some smaller borough of Greater London.
Google provides a deep and rich taxonomy to deal with this variation, but you will still need to apply your own rules to make sense of it (often at the state by state and country by country level)