cartesian to geographical/sperical coordinates - map-projections

I have a dxf file of a town in meter coordinates. I need to extract polylines from the map and convert them to geographical coordinates. My idea is to add 3 or 4 points on the map with known coordinates. I will place them using google map as reference. These 3 or 4 points will be placed at intersections roads so I can not place them as they defined a rectangle (I think it would be simpler).
I can not found out what calculation I have to do to convert all the coordinates of the objects of the map.
google map earth radius: 6378137 meter.
so, If I consider 3 points, I will have 3 relations:
(x1,y1) with (lat1, lng1)
(x2,y2) with (lat2, lng2)
(x3,y3) with (lat3, lng3)
I have done one simple conversion with only 2 points but I'd like a more accurate result.
I preferably use c/c++ to do it.
example of one equivalent point:
latitude: -2.148707
longitude: -79.876270
x: 2012078.15
y: 498355.88
It's not a UTM, I verify it from here. Because I do not know if it s a normalized.
I googled a lot, I found libraries, but without knowing if tmy coordinates meet a specific format, I don't think I can use one.
Anyway, thanks to read and I hope someone could help me.

It is not as easy at that. First you need to know which reference ellipsoid you are using (e.g. WGS-84) and then which projection. I wouldn't try to implement this by hand, but use postgis instead, which would do all this ugly work for you.

The correct way is to ask the provider of the file what the coordinate system is related to. dxf is not realy a suitable format. you need a format like ESRI Shp file or mif/mid with a defined geographic coordinate system.
otherwise it is a bit unclear if the data are precise enough, to be used for geographic reference.
However it is not difficult to transform between meters and wgs84 lat longitude, especially if the area is not more than 10-20 miles.
you could use as first try the cylyndrical equidistant transformation, which is only a few lines of simple code. look also if the y-achsis in the dxf file points to the nort pole, otherwise you must find out that amount of false northing and rotate back to north.
MapInfo Professional is a tool with free evaluation period, this tool alows to specify reference points for such unknown coordinate systems. (at least for bitmaps i rememer that feature).
But if you are a professional sw developper, You should reject that file and demand a version in wgs84 lat lon.

Related

what coordinate system is this and how to convert it to longitude latitudes?

I'm working with a coordinate system but I don't know what type of coordinate system is that.
Here is the part of the data set that I have.in 2nd and 3rd row shows the coordinate system.
Intersection Point Coordinate
N (X) E (Y)
384030.906 474784.247
384041.740 474892.294
384095.694 475203.524
These are real coordinates which were used in Sri Lanka and I want to map these coordinates in GIS map.(I'm making an android app to draw path according to the coordinates by using ArcGIS runtime sdk.)I need to find out what type of coordinate system is this and how to convert it in to longitude latitude? plz help me on this.thank you.
This might be in a Kalianpur (Indian Sub-continet) coordinate system with units in meters.
You can open a map and add a country boundary for Sri Lanka, such as this one: http://www.arcgis.com/home/item.html?id=a842e359856a4365b1ddf8cc34fde079
zoom towards the locale, if known, and choose different coordinate systems under the Layers button > coordinate system. The choose the general tab and pick different units until the measurements look good.
You can create xy data using the following instructions: http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//00s50000001z000000
A quick and dirty approach is to move your cursor around and create points in a shapefile in an edit session.

Algorithm to turn a set of noisy points into a path

I have a set of (slightly noisy) GPS coordinates that I want to turn into a path. How do I go about this?
I find it similar to this question, except my points are ordered. Also, the path does not need to go through the points, but just follow their general direction.
It seems that Bezier curves might be the answer, but is there a way to use Bezier curves on hundreds of points?
Q&A:
How are your points ordered They are ordered by time and attached to a travelling car. There might be data that specify that the the car is travelling backwards, but I can remove that data by requiring that all points move in a "forward" direction. So then I should have just a list of points that all go forwards in space and don't intersect with themselves.
What if we connect all the lines with straight lines It won't look pretty. I'd like for the lines to be continuous and curvy.
What about using a spline between all the points This too will make too much noise. The path will be very "jumpy". It would be better if we didn't care about going through points, but just near them.
It is a bit of heavy machinery, but you can model your GPS observations as points following a Gaussian process with Gaussian noise, where the main Gaussian process model specifies that the underlying unknown true x and y coordinates of two measurements close in time should be close, and the noise allows the observed x and y GPS measurement values to deviate a bit from the true x and y values predicted by the Gaussian process model. You can read the book "Gaussian Processes for Machine Learning" available online if you're interested. I think it's a really elegant, flexible and powerful solution, but it would take way too much space to explain it in enough detail here so you really do need to read about it from the book.
Once you've learned the most likely Gaussian process model solution, you can make predictions of x and y locations for any time point, and it will be a smooth curve, which you can then plot. It won't pass through the observed GPS locations exactly.

Pyephem Algorithms Reference

I have never used pyephem before, and I'm not expert in satellite positioning.
I'd like to exploit pyephem to calculate the position of a satellite using TLE.
I have to do something very easy, like that:
tle=["ISS (ZARYA)","1 25544U 98067A 03097.78853147 .00021906 00000-0 28403-3 0 8652","2 25544 51.6361 13.7980 0004256 35.6671 59.2566 15.58778559250029"]
iss = ephem.readtle(*tle)
observer = ephem.Observer()
observer.lon, observer.lat = ('-84.39733', '33.775867')
observer.date = ephem.Date('2002/4/23 10:10:00.000')
iss.compute(observer)
print iss.alt, iss.az, iss.range
-40:06:46.3 199:08:24.3 8834968.0
These three variables provide the position of the satellite in the horizion reference system.
It's not clear for me how pyephem calculates this values. I've read the reference guide: http://rhodesmill.org/pyephem/radec
Reading the document, it seems that pyephem applies the precession and the nutation, but in the last two line of the document it says:
"Note that no precession was applied to either of the final two sets of coordinates, but only to the first. This means that only the “Astrometric” position will correspond to the lines in your star atlas. The other positions are what are called “epoch-of-date” coordinates, and are measured off of the orientation of the celestial pole and the celestial equator for the very day of the observation itself."
Is the earth precession applied for az and alt?
Moreover I'd like to know what kind of model pyephem uses for precession and nutation (I really need some reference). There is a link to Xephem and libastro, but I can't find anything about the algorithms.
Do you have any suggestions?
Thank you very much!
You can find the various algorithms that PyEphem uses by looking through the various C language files in its libastro directory:
https://github.com/brandon-rhodes/pyephem/tree/master/libastro-3.7.5
But to answer your specific question: precession, aberration, and nutation are effects that are generally only computed for objects outside of the Earth's moving reference frame ­— objects like the Sun, planets, and the distant stars. Since Earth satellites are travelling in our own reference frame, however, I think that libastro generally does a direct comparison between the position of a satellite above the Earth and the position of the observer on the Earth, since these are already coordinates in the same local reference frame.

d3js - how to set albers projection properly?

I have some geojson data for Japan, which I managed to position properly on a mercator projection, but I'm a bit lost as to how to position it properly using an albers projection, other than trial and error.
Is there a good tool to use?
blocks example: http://bl.ocks.org/4043986
long, lat for japan (wikipedia):
latitudes 24° - 46°N,
longitudes 122° - 146°E.
geojson link: https://gist.github.com/raw/4043986/f53b85ab0af1585cd0461b4865ca4acd1fb79e9f/japan.json
As of now, it's the version 3 of D3.js.
It might be worth looking at the original source albers.js at github, which contains :
d3.geo.albers = function() {
return d3.geo.conicEqualArea()
.parallels([29.5, 45.5])
.rotate([98, 0])
.center([0, 38])
.scale(1000);
};
Now, d3.js use combination of projection.rotate and projection.center to place center of the projection to long 98°W, lat 38°N (around Hutchinson, Kansas).
From Geo Projections API,d3.geo.conicEqualArea()
.parallels([29.5, 45.5]) sets the Albers projection’s two standard parallels latitudes 29.5°N and
45.5°N, respectively. But what is two standard parallels?
To understand what parallels setting is, one need to know that Albers projection is a kind of conic projection.
A conic projection projects information from the spherical Earth to a cone that is either tangent to the Earth at a single parallel, or that is secant at two standard parallels.
Choosing the best standard parallels setting seems to be a subtle task, of which the goal is to minimize the projection distortion when mapping between surfaces. Anyway, choosing the two values to be closed to a country top/bottom edges is intuitively good, as it helps minimize the distance between the [conic/sphere] surfaces enclosing a country.
I found the answer looking through the repository - the tool is right there!
clone d3.js from the github repository.
edit /d3/examples/albers.html line 53 to point at your GEOJSON file:
Put the origin long / lat sliders to the center of your country / region (for me, it was 134° / 25°)
Change the paralells to be as close to the edges of your country / region.
adjust scale & offset to a nice size & position.
There are similar tools for the other projections.
edit: The repository has changed (and is constantly changing), so I've created a gist to preserve the example: https://gist.github.com/4552802
The examples are no longer part of the github repository.

Reach a waypoint using GPS/Compass/Accelerometer - Algorithm?

I currently have a robot with some sensors, like a GPS, an accelerometer and a compass. The thing I would like to do is my robot to reach a GPS coordinate that I enter. I wondered if any algorithm to do that already existed. I don't want a source code, which wouldn't have any point, just the procedure to follow for my robot to do so, for me to be able to understand what I do... At the moment, let's imagine that I can access the GPS coordinate everytime, so no need of a Kalman filter. I know it's unrealistic, but I would like to programm it step by step, and Kalman is the next step.
If anyone has an idea...
To get a bearing (positive angle east of north) between two lat-long points use:
bearing=mod(atan2(sin(lon2-lon1)*cos(lat2),(lat1)*sin(lat2)-sin(lat1)*cos(lat2)*cos(lon2-lon1)),2*pi)
Note - angles probably have to be in radians depending on your math package.
But for small distances you can just calculate how many meters in one degree of lat and long at your position and then treat them as flat X,Y coords.
For typical 45deg latitudes it's around 111.132 km/deg lat, 78.847 km/deg lon.
1) orient your robot toward its destination.
2) Move forward until the distance between you and your destination is increasing where you should go back to 1)
3) BUT ... if you are close enough (under a threshold), consider that you arrived at the destination.
You can use the Location class. It's BearingTo function computes the bearing you have to follow to reach another location.
There is a very nice page explaining the formulas between GPS-based distance, bearing, etc. calculation, which I have been using:
http://www.movable-type.co.uk/scripts/latlong.html
I am currently trying to do these calculations myself, and just found out that in Martin Becket answer there is an error. If you compare to the info of that webpage, you will see that the part in the middle:
(lat1)*sin(lat2)
should actually be:
cos(lat1)*sin(lat2)
Would have left a comment, but don't have the reputation yet...

Resources