Is there any algorithm that gives the compass direction of a shadow given latitude, longitude, date and time?
(Assuming we are an flat ground and that whatever the shadow falls from stands upright.)
You're looking for the declination and right ascension of the sun at a given time and location. Hit Google.
You tagged this question 'mathematica' so look at AstronomicalData["Sun", ...]
Related
I'm trying to match a latitude and longitude pair to a road segment that has a start and end latitude and longitude. All of the formulas I've been able to find query by the closest match to a single latitude and longitude, but not to a pair. I suppose one option is to get the average, or center of the segment, but this is not ideal. I'm querying this in SQLLite since my data is in GeoPackage format, but if anyone even has a formula to use I can translate that to SQLLite.
Thanks!
Hmm interesting. Conceptually, and without considering performance, would the following work? (consider this untested pseudo):
SELECT
MIN(ABS(lon_field - :lon1)) AS start_lon,
MIN(ABS(lat_field - :lat1)) AS start_lat,
MIN(ABS(lon_field - :lon2)) as end_lon,
MIN(ABS(lat_field - :lat2)) AS end_lat;
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.
In WP7, is it possible to show compass direction based on the given latitude and longitude values. (For example, if I am in India and if the latitude and longitude values of a place in some other country is given). If yes, please give some idea on how to achieve this.
This is what is known as the Second (inverse) geodetic problem.
"Given two points, determine the azimuth and length of the line
(straight line, arc or geodesic) that connects them." Wikipedia
You can get the distance using System.Device.Location.GeoCoordinate.GetDistanceTo(). Otherwise have a look at the excellent C# Geodesy Library for GPS – Vincenty’s Formulae. In particular the GeodeticCurve.
I doing a small program using Processing, and it's basically a map of Europe and a question will ask where a certain capital is in Europe. For example, if the question is where Milan is and the person clicks on Madrid I want to use a GPS to calculate the distance between Milan and Madrid. So hopefully the output would be "You have clicked on the wrong city. You are xxx miles away from Milan".
How do I code for this?
You definitely don't need a GPS for that, in fact a GPS won't even do what you want. All you need is the coordinates of the capitals for which you will ask the location. Presumably you can get this as latitude and longitude, although since you're displaying them on the screen, perhaps you will just get their x/y coordinates from whatever image/display you are using.
Lets assume you have an x and y for a city, and a click on the screen. The distance between two points on a plane is probably something you learned in high school geometry. The equation is available on Wikipedia.
If for some reason, you need to calculate the distance between two points of latitude/longitude, that's a little more complicated, and probably not worth it, but it's doable -- in fact, the question has been asked on SO.
That should be enough to get you started. If not, you should probably flesh your question out with some details.
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...