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-longitude
Filter by
Sorted by
Tagged with
1160 votes
49 answers
1.2m views

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 ...
Robin Minto's user avatar
  • 15.2k
858 votes
28 answers
365k views

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 ...
emmby's user avatar
  • 100k
495 votes
23 answers
363k views

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's user avatar
  • 43.7k
449 votes
19 answers
382k views

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 ...
Matt Johnson-Pint's user avatar
438 votes
32 answers
541k views

Calculate distance between 2 GPS coordinates

How do I calculate distance between two GPS coordinates (using latitude and longitude)?
nicudotro's user avatar
  • 7,189
412 votes
7 answers
336k views

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

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 ...
dthrasher's user avatar
  • 41.3k
401 votes
7 answers
371k views

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

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 ...
user2273259's user avatar
  • 4,035
232 votes
7 answers
209k views

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 ...
user1008404's user avatar
  • 2,367
187 votes
23 answers
154k views

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 ...
zeke's user avatar
  • 3,623
181 votes
9 answers
74k views

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, 456): http://maps.google.com/maps/ms?msid=214518704716144912556....
Mikko Ohtamaa's user avatar
178 votes
15 answers
218k views

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 ...
Jason N. Gaylord's user avatar
136 votes
4 answers
65k views

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 ...
KRTac's user avatar
  • 2,827
127 votes
17 answers
140k views

How to calculate the bounding box for a given lat/lng location?

I have given a location defined by latitude and longitude. Now i want to calculate a bounding box within e.g. 10 kilometers of that point. The bounding box should be defined as latmin, lngmin and ...
Michal's user avatar
  • 3,161
118 votes
14 answers
313k views

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?
Dennis Martinez's user avatar
116 votes
15 answers
150k views

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 ...
David M's user avatar
  • 2,893
115 votes
8 answers
216k views

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....
m4design's user avatar
  • 2,152
106 votes
11 answers
133k views

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 (...
Jonathan's user avatar
  • 32.5k
98 votes
10 answers
120k views

Algorithm to find all Latitude Longitude locations within a certain distance from a given Lat Lng location

Given a database of places with Latitude + Longitude locations, such as 40.8120390, -73.4889650, how would I find all locations within a given distance of a specific location? It doesn't seem very ...
Val Schuman's user avatar
  • 1,808
86 votes
6 answers
55k views

Java double vs BigDecimal for latitude/longitude

When storing latitudes/longitudes which are typically of the format: 44.087585 (i.e. max 2 numbers before the dot and 6dp) do I need to bother with bigdecimals?
DD.'s user avatar
  • 21.8k
86 votes
8 answers
160k views

Calculating distance between two geographic locations

please shed some light on this situation Right now i have two array having latitude and longitude of nearby places and also have the user location latiude and longiude now i want to calculate the ...
Sunny's user avatar
  • 14.7k
81 votes
2 answers
149k views

Function to calculate geospatial distance between two points (lat,long) using R [duplicate]

I have geocoded points in long, lat format, and I want to calculate the distance between them using R. This seems pretty straight forward, yet I can't find a function that will do it easily. I've ...
SteveO7's user avatar
  • 2,440
81 votes
15 answers
84k views

proper/best type for storing latitude and longitude

In a system level programming language like C, C++ or D, what is the best type/encoding for storing latitude and longitude? The options I see are: IEEE-754 FP as degrees or radians degrees or ...
BCS's user avatar
  • 76.9k
77 votes
3 answers
199k views

Calculate distance in meters when you know longitude and latitude in java [duplicate]

Possible Duplicate: Working with latitude/longitude values in Java Duplicate: Working with latitude/longitude values in Java How do I calculate distance between two latitude longitude points? I ...
Espen Herseth Halvorsen's user avatar
76 votes
12 answers
97k views

How can I measure distance and create a bounding box based on two latitude+longitude points in Java?

I am wanting to find the distance between two different points. This I know can be accomplished with the great circle distance. http://www.meridianworlddata.com/Distance-calculation.asp Once done, ...
will's user avatar
  • 1,175
76 votes
18 answers
173k views

How to convert an address to a latitude/longitude?

How would I go about converting an address or city to a latitude/longitude? Are there commercial outfits I can "rent" this service from? This would be used in a commercial desktop application on a ...
swilc0x's user avatar
  • 1,031
66 votes
8 answers
113k views

How can I quickly estimate the distance between two (latitude, longitude) points?

I want to be able to get a estimate of the distance between two (latitude, longitude) points. I want to undershoot, as this will be for A* graph search and I want it to be fast. The points will be at ...
fread2281's user avatar
  • 1,136
65 votes
12 answers
136k views

Google Maps API - how to get latitude and longitude from Autocomplete without showing the map?

I'm trying to get latitude and longitude from Autocomplete Google Maps API without showing the map. In my script autocompletion works well, but I can't get the latitude and longitude. <...
MCRD's user avatar
  • 651
60 votes
5 answers
162k views

Using Address Instead Of Longitude And Latitude With Google Maps API

I've heard that it is possible to submit an Address instead of Longitude and Latitude and this would be much more feasible for my system. The user has to input their address when creating their ...
edwoollard's user avatar
  • 12.3k
58 votes
8 answers
143k views

Find distance between two points using latitude and longitude in mysql

Hi I have the following table -------------------------------------------- | id | city | Latitude | Longitude | -------------------------------------------- | 1 | 3 | 34.44444 | ...
Enthusiast's user avatar
57 votes
13 answers
80k views

get Lat Lang from a place_id returned by autocomplete place api

I am searching the place in my apps using the google autocomplete place api and now I want to get latitude and longitude of the place that i have searched. How to get latitude and longitude from the ...
Sajal's user avatar
  • 1,462
51 votes
3 answers
35k views

Geographic / geospatial distance between 2 lists of lat/lon points (coordinates)

I have 2 lists (list1, list2) with latitude / longitudes of various locations. One list (list2) has locality names that list1 does not have. I want an approximate locality for every point in list1 ...
grammar's user avatar
  • 917
49 votes
8 answers
88k views

Retrieve latitude and longitude of a draggable pin via Google Maps API V3

I will explain. I managed to have a draggable pin on a map. I want to retrieve the coordinates of this point and put them into two fields: Latitude and Longitude. These coordinates will later be send ...
Macxim's user avatar
  • 664
46 votes
5 answers
202k views

How to get the Google Map based on Latitude on Longitude?

I want to display Google map in my web page based on longitude and latitude. First user want to enter longitude and latitude in two text box's. Then click submit button I have to display appropriate ...
Gnaniyar Zubair's user avatar
45 votes
4 answers
92k views

Maximum Lat and Long bounds for the world - Google Maps API LatLngBounds()

The Google Maps terrain view by default has unlimited panning of the map tile. You can use LatLngBounds() to limit this, but what are the maximum and minimum coordinates I should use to set the ...
Ryan Brodie's user avatar
  • 6,564
45 votes
7 answers
50k views

3D coordinates on a sphere to Latitude and Longitude

I've got the following information: There exists a sphere with origin (0,0,0) and radius R. After doing a ray-sphere intersection I know a point (XYZ) in 3D space that is on the sphere (the exact ...
Roy T.'s user avatar
  • 9,539
44 votes
7 answers
212k views

Get latitude and longitude based on location name with Google Autocomplete API

I have a textbox in my page which gets a location name and button with text getLat&Long. Now on clicking my button I have to show an alert of latitude and longitude of the location in the textbox. ...
Chandra's user avatar
  • 523
44 votes
3 answers
65k views

Converting longitude/latitude to X/Y coordinate

I created a map using Google Maps API that highlights all Minnesota counties. Basically, I created the county polygons using a set of longitudes/latitudes coordinates. Here's a screenshot of the ...
limc's user avatar
  • 39.7k
42 votes
6 answers
53k views

Calculating bounding box a certain distance away from a lat/long coordinate in Java

Given a coordinate (lat, long), I am trying to calculate a square bounding box that is a given distance (e.g. 50km) away from the coordinate. So as input I have lat, long and distance and as output I ...
Bryce Thomas's user avatar
  • 10.6k
41 votes
11 answers
59k views

Find city name and country from latitude and longitude in Swift

I'm working on application in Swift3 and I have letter problem i can't find the answer for it. How can I know city name and country short names base on latitude and longitude? import UIKit ...
joshua's user avatar
  • 967
41 votes
6 answers
55k views

R - Finding closest neighboring point and number of neighbors within a given radius, coordinates lat-long

I am trying to figure out how isolated certain points are within my data set. I am using two methods to determine isolation, the distance of the closest neighbor and the number of neighboring sites ...
user2934942's user avatar
38 votes
8 answers
56k views

Check if a latitude and longitude is within a circle

See this illustration: What I would like to know is: How to create an area (circle) when given a latitude and longitude and the distance (10 kilometers) How to check (calculate) if a latitude and ...
Peter Warbo's user avatar
  • 11.3k
36 votes
1 answer
30k views

mySQL longitude and latitude query for other rows within x mile radius

I have a database populated with roughly 10k rows currently. All of them have a longitude/latitude based on the center of a zipcode. I found a query that I am now attempting to expand on, but all in ...
chris's user avatar
  • 36.5k
36 votes
2 answers
30k views

Is the Haversine Formula or the Vincenty's Formula better for calculating distance?

Which is better for calculating the distance between two latitude/longitude points, The Haversine Formula or The Vincenty's Formula? Why? The distance is obviously being calculated on Earth. Does ...
jjNford's user avatar
  • 5,210
36 votes
1 answer
84k views

Positive/Negative Latitude and Longitude values vs. Cardinal Directions [closed]

As I've been taught, lat and long are of following types: Latitude North Longitude West Latitude South Longitude East During software development, if I receive two numeric values for lat and log, ...
Deepak's user avatar
  • 1,065
35 votes
4 answers
49k views

Getting Time Zone from Lat Long Coordinates? [duplicate]

I am trying to get the time zones for latitude and longitude coordinates but am having a few problems The mistakes are probably very basic I have a table in a database with around 600 rows. Each row ...
John Smith's user avatar
  • 2,636
35 votes
8 answers
49k views

C# Sunrise/Sunset with latitude/longitude

Is there a way in C# to calculate given a latitude and longitude when the sun will set and rise for a given day?
Ian Vink's user avatar
  • 67.9k
34 votes
6 answers
31k views

Determining UTM zone (to convert) from longitude/latitude

I'm writing a program which expects a number of lat/long points, and I convert them internally to UTM in order to do some calculations in metres. The range of the lat/long points themselves is quite ...
mathematical.coffee's user avatar
34 votes
6 answers
56k views

Longitude and latitude value from IP address

Is it possible to get the longitude and latitude value from IP address in asp.net? If it is possible, please let me know how can I get this.
Zerotoinfinity's user avatar
33 votes
11 answers
15k views

Moving a CLLocation by x meters

I have a CLLocation defined, and I'd like to move that point x meters to the east and y meters to the south. How may I achieve that?
Oliver's user avatar
  • 23.3k
33 votes
8 answers
79k views

Converting Longitude & Latitude to X Y on a map with Calibration points

If i have a jpeg map with size sizeX, sizeY and some calibration points on the map (X, Y, Lon, Lat) What would be the algorithm for calculating the corresponding XY point in the map with a given ...
Jorge's user avatar
  • 2,186

1
2 3 4 5
59