Convert from spherical angles to longitude and latitude - latitude-longitude

I have some images extracted from a radar from Austria and a formula for the projections (the exercice says The projection formulas map pixel locations to geographical coordinates), that transforms pixels into (phi, lambda) which the exercise states that are the spherical angles.
PRODUCT-PH-FORMS = "(1.570796326795-2*atan(0.404026225835*pow((1/sin(acotan(5899179.2/\
((5676531.8*pow((tan((1.570796326795-(v1*0.017453292520))/2)/\
0.373884679485),0.737361597616)*sin(0.012869387656*(v0-13.333333333))-\
v3*v4)+COL*v4)-((6380000.0*(0.924636243305-0.889738536848*pow((tan((\
1.570796326795-(v1*0.017453292520))/2)/0.373884679485),0.737361597616)*\
cos(0.012869387656*(v0-13.333333333)))+v2*v5)-ROW*v5)/((5676531.8*\
pow((tan((1.570796326795-(v1*0.017453292520))/2)/0.373884679485),\
0.737361597616)*sin(0.012869387656*(v0-13.333333333))-v3*v4)+COL*v4))))*\
((5676531.8*pow((tan((1.570796326795-(v1*0.017453292520))/2)/\
0.373884679485),0.737361597616)*sin(0.012869387656*(v0-13.333333333))-\
v3*v4)+COL*v4)/6380000.0*0.737361597616/sin(0.767944870878),1/\
0.737361597616)))"
PRODUCT-LA-FORMS = f(pixel row, pixel col, v0, v1, v2, v3, v4, v5)
But this gives very small values which cannot be (latitude, longitude) so I am looking for the transformation between spherical angles (phi,lambda) to (latitude,longitude)
For the result I need to provide (latitude, longitude) so how this conversion could be made?
The exercise provides me as well with some data I do not understand, which may be necessary:
v0=8.194 (reference lon)
v1=50.437 (reference lat)
v2 = 0
v3 = 0
v4=1018.18 (meter / pixel)
v5=1018.18 (meter / pixel)
This variables are used for the transformation formulas but may be useful as well to obtain (latitude, longitude)
EDIT
I have tried to directly consider the values I obtain from the transformation as (latitude, longitude) after *180/pi but the coordinates I get are not in Austria

Related

WGS84 coordinates convert to Lambert72 coordinates

I'm writing a macro in VBA excel. I have two sorts of data types:
WGS84 coordinates
Lambert72 coordinates
The Lambert72 coordinates are more accurate then the WGS84 coordinates. I have to find which WGS84 coordinate is the closest to the lambert72 coordinate (for each lambert72 coordinate) OR which Lambert72 coordinate is the closest to the WGS84 coordinate (for eacht WGS84 coordinate)
So i have to convert the wgs84 to lambert72 format, or vice versa. Someone who has a formula for this? On the internet I found some online converters, but I didn't find any formula.
And then I have to find a method to find the distance between two wgs84 coordinates or two lambert72 coordinates. For lambert72 i know how to do this, these are normally in meter, and is easy to calculate. But wgs84 are in degrees and I am not used to work with these.
Thank you in advance!
The formulas are a bit complicated, but this is what used to construct an excel sheet for those conversions: IGN - Services géodésiques
Exploring these pages you'll find the informations needed (web pages and PDF).
In short, this is the path to follow:
[BD72 datum] Lambert 72 coordinates
-> [BD72 datum] Geographic coordinates (Lat, Lon) (in decimal degrees)
-> [BD72 datum] Geocentric coordinates (X,Y,Z)
-> [WGS84 datum] Geocentric coordinates (X,Y,Z)
-> [WGS84 datum] Geographic coordinates (Lat, Lon) (in decimal degrees)
-> [WGS84 datum] Geographic coordinates (Lat, Lon) (in sexagesimal degrees)
(i.e. "GPS")
(in reverse order to find Lambert 72 coordinates)

What a set of GPS coordinates means?

I have a set of GPS coordinates 12.9611159,77.6362214. What exactly do these mean? How can I convert them to degrees of longitude and latitude? What formula should I use to get accurate distance between two sets of coordinates when the order of distance is 10km.
Most likely 12.9611159 is the latitude in degrees, 77.6362214 the longitude. In that case, the coordinate is in India. If latitude and longitude are reversed, you end up in the Greenland Sea.
You can easily check this by entering the coordinate pair in the Google maps search box. Google expects latitude first.
For the distance, in python you can easily use the haversine package:
from haversine import haversine
my_coord = (12.9611159,77.6362214)
other_coord = (12.9, 77.6)
distance = haversine(my_coord, other_coord)
This will give you the distance in km.

Latitude and longitude

Actually I have the decimal values of latitude and longitude.
In a 2d referential, are those values the x an y coordenates?
example :
in a position P
latitude = 41.15 longitude = -8.64
So, in a 2d dimension P is defined by (41.15,-8.64) ?
Thanks
No, its exactly opposite:
The coordinate (lat, lon) corresponds to the pair (y,x)
So when passinge lat, lon to mathematical routines, like point in polygon calculations
pass in order (lon, lat).
longitude raises parallell to the aequator, which corresponds to our x achsis direction we normally use in cartesian (x,y) systems.
Unfortunatley for historical reasons, the latitude is often written before longitude. (The cause might be that the latitude was easier to determine than the longitude.)
This all leads for us SW developpers to the bad situation, that sometimes functions use (lat,lon) order, sometimes when working with transformations from (lon,lat) to (x,y) or mathematical routines, the order lon, lat must be used. Be careful, every person I know someday has accidentally exchanged that.
In your example:
P is related to (-8.64), 41.15).
But lat,lon are spherical coordinates, for most application you must convert them to cartesian (x,y) .
But this is another question.
Be careful with units. In systems like Google Maps, those numbers are usually in degrees. Usually.
They might also be in radians, though, so at least make sure of what unit the API is using.

Is there a way to convert actual street map coordinates to a set of GPS coordinates?

I wonder is there a way to convert actual street map coordinates to a set of GPS coordinates. I was thinking if I have a set of GPS coordinates on the corners of a rectangular street map, I could virtually put a GPS coordinate to any point in that area. It is logical but I am not sure how to do it.
The Geotools Java project has all the tools you need to transform from one coordinate system to another. I'm not aware of anything similar in C++ though I'm afraid.
There are an absolute wealth of coordinate systems out there (see: http://en.wikipedia.org/wiki/Geographic_coordinate_system), so you'd need to be more specific about the format in which you have your street map coordinates for me to give any more detail.
I think I get the concept. You need two ingredients for that:
1. Scale and..
2. Corner sample.
It's easy to make a program to offset your marked points on the map
but these requires the "Scale" (ex. 1-inch : 121001-meters) and the
sample of "coordinate" in at least one of any of the four corners
(top-left,top-right,bottom-left,bottom-right) for use to offset and
get.
Out of these variables needed, we could easily extract to get the
coords marked on your map.
MAJOR EDIT:
(Note: Disregard what I've written earlier above)
Variables:
mw = 2d mapwidth
mh = 2d mapheight
x = your 2d x coordinate
y = your 2d y coordinate
lat = latitude (our N or ?)
lon = longitude (our N or ?)
Formula:
lat = 180 + ( (x / mw) * 360) )
long = 90 + ( (y / mh) * 360) )
Explanation:
Following the formulas which are used:
x = (mw) * (180 + latitude) / 360
y = (mh) * (90 + longitude) / 180
I've personally transposed the formula above to find our latitude and longitude.
I hope this solves your problem and this is the appropriate answer for your question.
Don't forget to up my answer to save my honor from the humiliation earlier. jk. :)

Determine if a latitude/longitude is within a polygon on Earth's surface

I am trying to figure out if a latitude/longitude point is contained within a polygon defined by vertexes that represent points on the earth (also lat/lon's, in clockwise order). This is trivial for polygons that can be mapped to the 2D lat/lon space.
Where this becomes increasingly difficult is circle's (now switching back to 3D) that may go from pole to pole covering half the earth. The translation to lat/lon looks like a sine wave. The 2D point in polygon test no longer applies to this case. Is there an algorithm that exists that solves this problem?
================== Clarifications on comments below: ===================
The polygon is defined as (lon, lat) pairs in degrees, i.e., (60, 90), (60, 110), (-30, 110), (-30, 90).
I do have code that implements the ray casting algorithm, and that works. however, certain polygons on the surface of the earth do not translate to closed polygons in the 2D space.
As stated by denniston.t, if you are only interested in circles, and you have a radius, you can simply check if the Great Circle Distance between the center point and the point is less than the radius. To find the great circle distance you typically use the Haversine Formula. The following is my implementation in python:
from math import radians, sin, cos, asin, sqrt
def haversine(point1, point2):
"""Gives the distance between two points on earth.
The haversine formula, given two sets of latitude and longitude,
returns the distance along the surface of the earth in miles,
ignoring potential changes in elevation. The points must be in
decimal degrees.
"""
earth_radius_miles = 3956
lat1, lon1 = (radians(coord) for coord in point1)
lat2, lon2 = (radians(coord) for coord in point2)
dlat, dlon = (lat2 - lat1, lon2 - lon1)
a = sin(dlat/2.0)**2 + cos(lat1) * cos(lat2) * sin(dlon/2.0)**2
great_circle_distance = 2 * asin(min(1,sqrt(a)))
d = earth_radius_miles * great_circle_distance
return d
If you have the center point and radius of your circle drawn on the surface of the sphere, calculate the Great-circle distance between the center point and target point. If it's less than the radius of the circle, the target point lies in the circle.
This will not generalize to arbitrary polygons drawn on your sphere, but you only asked about circles, so I don't know if it matters to you.
containsLocation(point:LatLng, polygon:Polygon)