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
7,139
questions
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 ...
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 ...
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 ...
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 ...
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?
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?
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/...
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,...
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....
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 ...
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 ...
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 ...
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 &...
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 ...
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, ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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).
...
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 ...
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, ...
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 ...
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 ...
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.
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 ...
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 ...
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?
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
...
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 ...
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. ...
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 ...
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 ...
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 ...
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 ...
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, ...
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 ...
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....
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,...
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 ...