I'm trying to translate latitude and longitude coordinates into coordinates of my own defined map. For instance:
51.876324 maps to 659.33 in my map
0.943395 maps to 2585.17 in my map other such examples might be:
51.875737 - 505.77
0.943564 - 2055.39
51.875883 - 1090.58
0.944658 - 1935.42
My math skills/knowledge is kind of rusted, but should I use substitution to find out what is the factor by which the coordinates can be mapped into mine?
Any hints are appreciated
Cheers!
It is not quite possible to answer this question exactly without knowing details about the map projection algorithm used. While lat and lon are angular coordinates on the earth (almost) ellipsoid the other seem to be map (x,y) coordinates.
If your map covers only a small part of the surface you might approximate this by a simple transformation
x = lon * factor_x + offset_x
y = lat * factor_y + offset_y
with constants factor_x, factor_y and offset_x and offset_y. From two distinct points on your map you may derive these constants by inversion:
factor_x = (x1-x2) / (lon1-lon2)
offset_x = x1 - lon1 * factor_x
and same for y.
Related
I'm looking for the R function (or code) equivalent to the MATLAB function scxsc
This gives the Intersection points for pairs of small circles on a sphere.
The application is "a vessel is at bearing X1 and distance d1 from point 1 and bearing X2 and distance d2 from point 2. What is it's position in Lat, lon?"
I see plenty of examples for the intersection of great circles but not with small circles
I found the answer on https://gis.stackexchange.com/questions/48937/calculating-intersection-of-two-circles/273855#273855
NB I have a suspicion that in the two (unmodified) lines below ...
lat1 = rad2deg(atan2(point1[2] ,point1[1]))
lon1= rad2deg(asin(point1[3]))
and
lat2 = rad2deg(atan2(point2[2] ,point2[1]))
lon2 = rad2deg(asin(point2[3]))
... the lat and lon are inverted !
It worked much better for me with these changes!
I have a set of 2d grid points (x,y) that I want to map/project onto a sphere as 3d points (x,y,z).
I realize there will be some warping towards the poles as abs(y) increases but my grid patch will only cover a portion of the sphere near the equator so severe warping will be avoided.
I'm having trouble finding the right equations for that.
Paraphrased from the wikipedia article on Mercator projection:
Given a "mapping sphere" of radius R,
the Mercator projection (x,y) of a given latitude and longitude is:
x = R * longitude
y = R * log( tan( (latitude + pi/2)/2 ) )
and the inverse mapping of a given map location (x,y) is:
longitude = x / R
latitude = 2 * atan(exp(y/R)) - pi/2
To get the 3D coordinates from the result of the inverse mapping:
Given longitude and latitude on a sphere of radius S,
the 3D coordinates P = (P.x, P.y, P.z) are:
P.x = S * cos(latitude) * cos(longitude)
P.y = S * cos(latitude) * sin(longitude)
P.z = S * sin(latitude)
(Note that the "map radius" and the "3D radius" will almost certainly have different values, so I have used different variable names.)
I suppose that your (x,y) on the sphere are latitude, longitude.
If so, see http://tutorial.math.lamar.edu/Classes/CalcII/SphericalCoords.aspx.
There:
phi = 90 degree - latitude
theta = longitude
rho = radius of your sphere.
I would expect that you could use the inverse of any of a number of globe projections.
Mercator is pretty good around the equator compared to other projections.
Formulas are on the wiki page.
http://en.wikipedia.org/wiki/Mercator_projection
I have two points (x1, y1) and (x2,y2) which represent the location of two entities in my space. I calculate the Euclidian distance between them using Pythagoras' theorem and everything is wonderful. However, if my space becomes finite, I want to define a new shortest distance between the points that "wraps around" the seams of the map. For example, if I have point A as (10, 10) and point B as (90,10), and my map is 100 units wide, I'd like to calculate the distance between A and B as 20 (out the right edge of the map and back into the left edge), instead of 80, which is the normal Euclidian distance.
I think my issue is that I'm using a coordinate system that isn't quite right for what I'm trying to do, and that really my flat square map is more of a seamless doughnut shape. Any suggestions for how to implement a system of this nature and convert back and forth from Cartesian coordinates would be appreciated too!
Toroidal plane? Okay, I'll bite.
var raw_dx = Math.abs(x2 - x1);
var raw_dy = Math.abs(y2 - y1);
var dx = (raw_dx < (xmax / 2)) ? raw_dx : xmax - raw_dx;
var dy = (raw_dy < (ymax / 2)) ? raw_dy : ymax - raw_dy;
var l2dist = Math.sqrt((dx * dx) + (dy * dy));
There's a correspondence here between the rollover behavior of your x and y coordinates and the rollover behavior of signed integers represented using the base's complement representation in the method of complements.
If your coordinate bounds map exactly to the bounds of a binary integer type supported by your language, you can take advantage of the two's complement representation used by nearly all current machines by simply performing the subtraction directly, ignoring overflow and reinterpreting the result as a signed value of the same size as the original coordinate. In the general case, you're not going to be that lucky, so the above dance with abs, compare and subtract is required.
If I have the coordinates of a point (lat lon) and the azimuth angle how can I calculate what points are at "the end' of a distance of 10 miles.
Ex. I am watching North , I know I am at a certain point ... At 10 miles apart what coordinates has that geo point ?
This site has a pretty good collection of formulae. For your case,
Let lon1,lat1 be the starting point, θ the azimuth angle (also often referred to as the "bearing") in radians,
d the distance traveled (km), and R the earth's radius (approx 6371 km). Then you can find
the final coordinates lon2, lat2 :
lat2 = asin(sin(lat1)*cos(d/R) + cos(lat1)*sin(d/R)*cos(θ))
lon2 = lon1 + atan2(sin(θ)*sin(d/R)*cos(lat1), cos(d/R)−sin(lat1)*sin(lat2))
Note: d/R represents an angle in radians corresponding to the arc length d.
θ is measured such that North=0 degrees, East=90 degrees, and so forth.
That doesn't make much sense. Let's take the first formula
lat2 = asin(sin(lat1)*cos(d/R) + cos(lat1)*sin(d/R)*cos(θ))
sin(lat1)*cos(d/R) -> as sin and cos will never be larger than 1, the largest result can be 1
cos(lat1)*sin(d/R)*cos(θ) -> same as above: the biggest possible result is 1
=> the result is that lat2 according to that formula can be 2 at most.
You need to also have a bearing to calculate this distance as well. For very short distances, great circle distance (the distance along the path of the earth) will be very close to cartesian distance, but the site provided by Jim Lewis' answer is a nice interactive site. This site also has a very extensive set of lat/lon formulas http://williams.best.vwh.net/avform.htm.
Say you have n GPS coordinates how could you work out the central GPS point between them?
In case it helps anyone now or in the future, here's an algorithm that's valid even for points near the poles (if it's valid at all, i.e. if I haven't made a silly math mistake ;-):
Convert the latitude/longitude coordinates to 3D Cartesian coordinates:
x = cos(lat) * cos(lon)
y = cos(lat) * sin(lon)
z = sin(lat)
Compute the average of x, the average of y, and the average of z:
x_avg = sum(x) / count(x)
y_avg = sum(y) / count(y)
z_avg = sum(z) / count(z)
Convert that direction back to latitude and longitude:
lat_avg = arctan(z_avg / sqrt(x_avg ** 2 + y_avg ** 2))
lon_avg = arctan(y_avg / x_avg)
Depends on what you mean by the central GPS point. You could simply take the average of all the points, as suggested by Stephen - but keep in mind that GPS coordinates are not continuous - this will fail spectacularly around discontinuities such as the poles.
In most cases you'll need to convert to a coordinate system that doesn't have this issue.
You could also look at all the points bounded by it, calculated all the distances to each GPS point, and minimize the sum of the distances to all the GPS points. You'll need to look into great circle calculations for this.
Further, each GPS might have a higher or lower degree of uncertainty, you should take that into account and weight them accordingly.
What exactly are you trying to find out?
-Adam