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

2708 questions
991
votes
46 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
  • 13,373
  • 3
  • 32
  • 40
837
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
  • 95,927
  • 63
  • 178
  • 243
454
votes
21 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
  • 41,810
  • 20
  • 83
  • 116
412
votes
30 answers

Calculate distance between 2 GPS coordinates

How do I calculate distance between two GPS coordinates (using latitude and longitude)?
nicudotro
  • 6,631
  • 6
  • 23
  • 17
356
votes
17 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
  • 197,368
  • 66
  • 382
  • 508
351
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,519
  • 2
  • 11
  • 3
341
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
  • 36,940
  • 32
  • 104
  • 137
168
votes
6 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
  • 1,719
  • 2
  • 11
  • 5
160
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
  • 69,174
  • 40
  • 208
  • 346
158
votes
22 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,189
  • 2
  • 23
  • 40
145
votes
13 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
  • 6,820
  • 13
  • 52
  • 92
107
votes
4 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 it's exactness, but operations on decimal floating point numbers are slower then binary floating point numbers (double). I read that most of the time…
KRTac
  • 2,401
  • 4
  • 20
  • 18
104
votes
11 answers

What's the best way to store co-ordinates (longitude/latitude, from Google Maps) in SQL Server?

I'm designing a table in SQL Server 2008 that will store a list of users and a Google Maps co-ordinate (longitude & latitude). Will I need two fields, or can it be done with 1? What's the best (or most common) data-type to use for storing this kind…
Jonathan
  • 29,612
  • 37
  • 126
  • 201
102
votes
9 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,001
  • 3
  • 19
  • 27
93
votes
11 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?
1
2 3
99 100