Questions tagged [latitude-longitude]

Managing data about geographic point locations, using a latitude-longitude pair (degrees north/south, and east/west, respectively) per point.

Latitude

enter image description here

Longitude

enter image description here

2920 questions
1143
votes
49 answers

Calculate distance between two latitude-longitude points? (Haversine formula)

How do I calculate the distance between two points specified by latitude and longitude? For clarification, I'd like the distance in kilometers; the points use the WGS84 system and I'd like to understand the relative accuracies of the approaches…
Robin Minto
  • 15,027
  • 4
  • 37
  • 40
856
votes
28 answers

What is the simplest and most robust way to get the user's current location on Android?

The LocationManager API on Android seems like it's a bit of a pain to use for an application that only needs an occasional and rough approximation of the user's location. The app I'm working on isn't really a location app per se, but it does need to…
emmby
  • 99,783
  • 65
  • 191
  • 249
492
votes
22 answers

What is the ideal data type to use when storing latitude / longitude in a MySQL database?

Bearing in mind that I'll be performing calculations on lat / long pairs, what datatype is best suited for use with a MySQL database?
Codebeef
  • 43,508
  • 23
  • 86
  • 119
437
votes
18 answers

How to get a time zone from a location using latitude and longitude coordinates?

Given the latitude and longitude of a location, how does one know what time zone is in effect in that location? In most cases, we are looking for an IANA/Olson time zone id, although some services may return just a UTC offset, or some other time…
Matt Johnson-Pint
  • 230,703
  • 74
  • 448
  • 575
436
votes
31 answers

Calculate distance between 2 GPS coordinates

How do I calculate distance between two GPS coordinates (using latitude and longitude)?
nicudotro
  • 7,129
  • 6
  • 25
  • 17
399
votes
8 answers

What datatype to use when storing latitude and longitude data in SQL databases?

When storing latitude or longitude data in an ANSI SQL compliant database, what datatype would be most appropriate? Should float be used, or decimal, or ...? I'm aware that Oracle, MySql, and SQL Server have added some special datatypes specifically…
dthrasher
  • 40,656
  • 34
  • 113
  • 139
396
votes
7 answers

What are the lengths of Location Coordinates, latitude and longitude?

How many digits can latitude and longitude have, before the decimal, and after the decimal? Here is an example I am getting from the location sent by a Windows Phone device: Latitude=-63572375290155 Longitude=106744840359415 This is very long and…
user2273259
  • 3,985
  • 2
  • 13
  • 3
226
votes
7 answers

Which data type for latitude and longitude?

I am newbie to PostgreSQL and PostGIS. I want to store latitude and longitude values in PostgreSQL 9.1.1 database table. I will calculate distance between two points, find nearer points by using this location values. Which data type should I use…
user1008404
  • 2,307
  • 2
  • 14
  • 6
186
votes
23 answers

Calculate the center point of multiple latitude/longitude coordinate pairs

Given a set of latitude and longitude points, how can I calculate the latitude and longitude of the center point of that set (aka a point that would center a view on all points)? EDIT: Python solution I've used: Convert lat/lon (must be in radians)…
zeke
  • 3,603
  • 2
  • 26
  • 41
179
votes
9 answers

Preferred order of writing latitude & longitude tuples in GIS services

When dealing with GIS source code you often need to write latitude and longitude coordinate tuples. E.g. in Google Maps links (123,…
Mikko Ohtamaa
  • 82,057
  • 50
  • 264
  • 435
177
votes
15 answers

Calculating Distance between two Latitude and Longitude GeoCoordinates

I'm calculating the distance between two GeoCoordinates. I'm testing my app against 3-4 other apps. When I'm calculating distance, I tend to get an average of 3.3 miles for my calculation whereas other apps are getting 3.5 miles. It's a big…
Jason N. Gaylord
  • 7,910
  • 15
  • 56
  • 95
130
votes
5 answers

Double or decimal for latitude/longitude values in C#

What is the best data type to use when storing geopositional data in C#? I would use decimal for its exactness, but operations on decimal floating point numbers are slower then binary floating point numbers (double). I read that most of the time you…
KRTac
  • 2,767
  • 4
  • 22
  • 18
118
votes
14 answers

How can I get city name from a latitude and longitude point?

Is there a way to get a city name from a latitude and longitude point using the google maps api for javascript? If so could I please see an example?
111
votes
8 answers

Calculating distance between two points, using latitude longitude?

Here's my try, it's just a snippet of my code: final double RADIUS = 6371.01; double temp = Math.cos(Math.toRadians(latA)) * Math.cos(Math.toRadians(latB)) * Math.cos(Math.toRadians((latB) - (latA))) +…
m4design
  • 2,112
  • 3
  • 21
  • 28
110
votes
15 answers

Get lat/long given current point, distance and bearing

Given an existing point in lat/long, distance in (in KM) and bearing (in degrees converted to radians), I would like to calculate the new lat/long. This site crops up over and over again, but I just can't get the formula to work for me. The…
David M
  • 2,763
  • 4
  • 21
  • 24
1
2 3
99 100