Questions tagged [coordinates]

Refers to a sequence of numbers used to indicate the position of an object relative to an axis. Commonly, refers to a latitude/longitude pair that indicates a geographical position.

coordinates
Filter by
Sorted by
Tagged with
280 votes
15 answers
316k views

Function to calculate distance between two coordinates

I'm currently using the function below and it doesn't work properly. According to Google Maps, the distance between these coordinates (from 59.3293371,13.4877472 to 59.3225525,13.4619422) are 2.2 ...
Airikr's user avatar
  • 6,346
219 votes
18 answers
289k views

Find nearest latitude/longitude with an SQL query

I have latitude and longitude and I want to pull the record from the database, which has nearest latitude and longitude by the distance, if that distance gets longer than specified one, then don't ...
Basit's user avatar
  • 16.7k
188 votes
13 answers
241k views

Measuring the distance between two coordinates in PHP

Hi I have the need to calculate the distance between two points having the lat and long. I would like to avoid any call to external API. I tried to implement the Haversine Formula in PHP: Here is ...
maxdangelo's user avatar
  • 3,103
182 votes
3 answers
602k views

Plotting a list of (x, y) coordinates

I have a list of pairs (a, b) that I would like to plot with matplotlib in python as actual x-y coordinates. Currently, it is making two plots, where the index of the list gives the x-coordinate, and ...
CodeKingPlusPlus's user avatar
159 votes
7 answers
470k views

How to position a DIV at specific coordinates?

I want to position a DIV at specific coordinates, how can I do that using JavaScript?
Adham's user avatar
  • 64.2k
156 votes
11 answers
181k views

Getting View's coordinates relative to the root layout

Can I get a View's x and y position relative to the root layout of my Activity in Android?
fhucho's user avatar
  • 34.3k
110 votes
6 answers
76k views

Is OpenGL coordinate system left-handed or right-handed?

I am trying to understand the OpenGL coordinate system. However, some tutorials say the default coordinate system is left handed (see http://www.c-sharpcorner.com/UploadFile/jeradus/...
341008's user avatar
  • 10k
99 votes
5 answers
152k views

Create Google Maps links based on coordinates

How can I create Google Maps links based on coordinates? Their new basic share urls contain a lot of parameters, for example: https://www.google.com/maps/place/Vetlanda,+Sweden/@57.4217311,15.0849255,...
Staffan Estberg's user avatar
87 votes
13 answers
143k views

Calculate area of polygon given (x,y) coordinates

I have a set of points and would like to know if there is a function (for the sake of convenience and probably speed) that can calculate the area enclosed by a set of points. for example: x = np....
pbreach's user avatar
  • 16.6k
87 votes
3 answers
36k views

Lat Long or Long Lat

There seems to be no standard whether Longitude,Latitude or Latitude,Longitude should be used. WSG84 and stuff based directly on it, seem to prefer Long,Lat. "Normal people" always tend to speak of ...
Thomas M.'s user avatar
  • 1,516
77 votes
7 answers
93k views

How to validate latitude and longitude

I have two UITextFields which users can enter in a latitude and longitude, these co-ordinates are then used to create a pin on an MKMapView. I want find a way to validate whether the values they ...
user avatar
76 votes
14 answers
61k views

Covering Earth with Hexagonal Map Tiles [closed]

Many strategy games use hexagonal tiles. One of the main advantages is that the distance between the center of any tile and all its neighboring tiles is the same. I was wondering if anyone has any ...
carrier's user avatar
  • 32.6k
74 votes
5 answers
94k views

How to calculate an angle from points?

I want to get a simple solution to calculate the angle of a line (like a pointer of a clock). I have 2 points: cX, cY - the center of the line. eX, eY - the end of the line. The result is angle (0 &...
durumdara's user avatar
  • 3,431
68 votes
10 answers
117k views

Convert long/lat to pixel x/y on a given picture

I have a city map of Moscow. We modified a Google Maps image with some artistic elements, but the relation between GPS coordinates and pixels remains the same. Problem: How do I convert GPS ...
Kalinin's user avatar
  • 2,499
55 votes
4 answers
30k views

How do you find a point at a given perpendicular distance from a line?

I have a line that I draw in a window and I let the user drag it around. So, my line is defined by two points: (x1,y1) and (x2,y2). But now I would like to draw "caps" at the end of my line, that is, ...
AZDean's user avatar
  • 1,794
46 votes
12 answers
22k views

Java: What is a good data structure for storing a coordinate map for an infinite game world?

I am used to coding in PHP but I am not really proficient with Java and this has been a problem for some time now. I expect it to be a fairly easy solution, however I cannot find any good example code ...
Aykın's user avatar
  • 649
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
43 votes
2 answers
8k views

Creating a resizable/draggable/rotate view in javascript

I've been trying to create something like this in Javascript: As you can see, the container can be dragged, rotated and resized. Most of the things work fine but the resizing of container when it is ...
Axel's user avatar
  • 4,701
41 votes
6 answers
72k views

Faster numpy cartesian to spherical coordinate conversion?

I have an array of 3 million data points from a 3-axiz accellerometer (XYZ), and I want to add 3 columns to the array containing the equivalent spherical coordinates (r, theta, phi). The following ...
BobC's user avatar
  • 3,380
39 votes
4 answers
54k views

Validate latitude and longitude

I want to validate the latitude and longitude. Right now, I check just so that the value is not empty, but I want a validation to check that it is a valid latidue or longitude. How do I do that? My ...
Hysteria's user avatar
  • 391
38 votes
4 answers
25k views

Calculating bearing between two CLLocationCoordinate2Ds

Very "simple" problem: given two CLLocationCoordinate2Ds, how can I get the bearing (as radians) from the first to the second? I've done a lot of research and studying on this, both the general ...
James J's user avatar
  • 6,458
38 votes
4 answers
38k views

Converting 3D position to 2d screen position [r69!]

I need Three.js code to convert 3D object coordinates to 2d ones in a 'div' element so that I can place text labels where they need to be (without those labels scaling/moving/rotating along with the ...
Darren Enns's user avatar
38 votes
2 answers
82k views

How to find the element's x center coordinates and related window offset

i would like to retrieve the element offset starting from his own x center coordinates. how can i do it? Actually i can find the window offset of an element but it retrieves the coordinates from the ...
Filippo oretti's user avatar
37 votes
4 answers
53k views

Geographical boundaries of states/provinces -> Google Maps Polygon

I'm building a web application that is going to dynamically highlight certain U.S. states and Canadian provinces on a Google Map, based on buttons and click events. Plan A) Polygons My primary idea ...
motto's user avatar
  • 1,307
37 votes
4 answers
107k views

Plot coordinates on map

I am trying to plot my coordinates using R. I have tried already to follow different post (R: Plot grouped coordinates on world map ; Plotting coordinates of multiple points at google map in R) but I ...
flacchy's user avatar
  • 511
36 votes
3 answers
25k views

Sort latitude and longitude coordinates into clockwise ordered quadrilateral

Problem Users can provide up to four latitude and longitude coordinates, in any order. They do so with Google Maps. Using Google's Polygon API (v3), the coordinates they select should highlight the ...
35 votes
8 answers
45k views

Detecting whether a GPS coordinate falls within a polygon on a map

As stated in the title, the goal is to have a way for detecting whether a given GPS coordinate falls inside a polygon or not. The polygon itself can be either convex or concave. It's defined as a set ...
Saul's user avatar
  • 18k
34 votes
8 answers
76k views

Calculating the angle between two lines without having to calculate the slope? (Java)

I have two Lines: L1 and L2. I want to calculate the angle between the two lines. L1 has points: {(x1, y1), (x2, y2)} and L2 has points: {(x3, y3), (x4, y4)}. How can I calculate the angle formed ...
jNoob's user avatar
  • 361
34 votes
3 answers
32k views

What exactly are eye space coordinates?

As I am learning OpenGL I often stumble upon so-called eye space coordinates. If I am right, you typically have three matrices. Model matrix, view matrix and projection matrix. Though I am not ...
danijar's user avatar
  • 33.3k
34 votes
1 answer
100k views

Google Maps API V3: How to get region border coordinates (polyline) data? [duplicate]

I'm trying to get (specified) region borders as GMaps coordinates (to form a polyline) from Google Maps. Is this possible in some way? (either from maps.google.com or my own GMaps in my own domain). ...
Harri Virtanen's user avatar
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
33 votes
7 answers
19k views

How to recalculate x,y coordinates based on screensize

I'm have a heat map application and store I store the x,y coordinates of a click and also the viewport width and height. Real data for 2 clicks: x, y, width, height 433, 343, 1257, 959 331, 823, ...
Naterade's user avatar
  • 2,645
33 votes
2 answers
103k views

tool to get coordinates of an image pixel [closed]

I need a tool using which, when I point the mouse at a particular location of an image, it should give me location of the pixel relative to the image. For ex. I have a 720x480 image, my pointer is ...
androidnewbie's user avatar
32 votes
9 answers
84k views

How to perform bilinear interpolation in Python

I would like to perform blinear interpolation using python. Example gps point for which I want to interpolate height is: B = 54.4786674627 L = 17.0470721369 using four adjacent points with known ...
daikini's user avatar
  • 1,317
31 votes
6 answers
45k views

Convert address to coordinates swift

How can I convert a String address to CLLocation coordinates with Swift? I have no code yet; I looked for a solution but couldn't find any.
Paul Bénéteau's user avatar
31 votes
5 answers
18k views

Generating triangular/hexagonal coordinates (xyz)

I'm trying to come up with an iterative function that generates xyz coordinates for a hexagonal grid. With a starting hex position (say 0,0,0 for simplicity), I want to calculate the coordinates for ...
John Schulze's user avatar
  • 2,198
31 votes
7 answers
60k views

Generating multiple random (x, y) coordinates, excluding duplicates?

I want to generate a bunch (x, y) coordinates from 0 to 2500 that excludes points that are within 200 of each other without recursion. Right now I have it check through a list of all previous values ...
user2901745's user avatar
30 votes
6 answers
50k views

Getting the coordinates from the location I touch the touchscreen

I try to get the coordinates from the location where I hit the touchscreen to do put a specific UIImage at this point. How can I do this?
Lukas Köhl's user avatar
  • 1,569
29 votes
3 answers
27k views

Get new position of coordinate after rotation with Matrix

I'm wondering how to use a Matrix to get the new position of a coordinate within a rectangle after rotation. What I would like to do is: Define a rectangle Define a coordinate within that rectangle ...
DecodeGnome's user avatar
  • 1,809
28 votes
10 answers
4k views

Matrix transforms; concepts and theory, are there any free resources for learning practically? [closed]

I've been having fun rendering charts and graphs from co-ordinates lately, and I'm fascinated by using matrices to transform co-ordinate spaces. I've been able to successfully scale and invert 2 ...
John Weldon's user avatar
  • 40.4k
28 votes
2 answers
3k views

how to plot networks over a map with the least overlap

I have some authors with their city or country of affiliation. I would like to know if it is possible to plot the coauthors' networks (figure 1), on the map, having the coordinates of the countries. ...
Ferroao's user avatar
  • 3,171
27 votes
4 answers
33k views

Efficiently finding the closest coordinate pair from a set in Python

The Problem Imagine I am stood in an airport. Given a geographic coordinate pair, how can one efficiently determine which airport I am stood in? Inputs A coordinate pair (x,y) representing the ...
Kieran's user avatar
  • 3,356
27 votes
1 answer
17k views

How can I get the frame of a table view cell in the coordinate space of the table view?

I have a table view with a bunch of cells in it. I want to get the frame of a cell, not in its superview's coordinate space, but in the table view's coordinate space. A picture would probably explain ...
Sweeper's user avatar
  • 236k
26 votes
5 answers
5k views

How to get the user Home/Work location for a user in Android

Im developing an app that brings the user a quick list of "info" items but i want to set an options so that he receives this items as notifications when he is leaving home or work. I noticed (using ...
LordSidious's user avatar
25 votes
10 answers
301k views

How to draw lines in Java

I'm wondering if there's a funciton in Java that can draw a line from the coordinates (x1, x2) to (y1, y2)? What I want is to do something like this: drawLine(x1, x2, x3, x4); And I want to be able ...
Karoline Brynildsen's user avatar
24 votes
4 answers
13k views

Calculate distance between two x/y coordinates?

I would like to calculate the distance between two x/y coordinates on the surface of a torus. So, this is a normal grid that has the property that its corners and sides are 'connected'. For example, ...
Ropstah's user avatar
  • 17.7k
23 votes
7 answers
58k views

How do i open Google Maps for directions using coordinates on the iphone

I am using UIMapView to display locations on the iPhone. I want to do a directions from current location to the location of interest, I don't think its possible using MapKit (but if it is please ...
Aran Mulholland's user avatar
23 votes
2 answers
20k views

Calculate if an object is inside a set of coordinates?

I have a set of X and Y points that builds a shape and I need to know if an object is inside it or not what is the calculation to it ? X and Y coords example: 522.56055 2389.885 544.96 2386.3406 554....
Prix's user avatar
  • 19.5k
22 votes
7 answers
30k views

How to determine if a point is within a quadrilateral

Goal I want to determine if a test point is within a defined quadrilateral. I'm probably going to implement the solution in Matlab so I only need pseudo-code. Inputs Corners of quadrilateral : (x1,...
slykat's user avatar
  • 876
22 votes
6 answers
39k views

How can i calculate the distance between two gps points in Java?

I used this code but it doesnt work: Need the distance between two gps coordinates like 41.1212, 11.2323 in kilometers (Java) double d2r = (180 / Math.PI); double distance = 0; try{ double ...
Benni's user avatar
  • 321

1
2 3 4 5
143