I am conducting a spatial econometrics study on housing prices.
In order to calculate spatial auto-correlation between house locations using some econometric software (like Matlab), I use decimal latitude/longitude coordinates of each house as the location in the entry of the program.
I was recently surprised by the question of a researcher asking me if the coordinates that I enter in Matlab are indeed Cartesian coordinates and not geographic ones? Otherwise, he said, estimates leads to wrong results!
I didn't respond to him because I ignored the difference between geographic coordinates and cartesian coordinates.
Today I find in wikipedia the definition of the projected coordinate system that I use (Universal Transverse Mercator) that it "uses a 2-dimensional Cartesian coordinate system to give locations on the surface of the Earth". I am confused.
Are UTM coordinates already cartesian ones? If not, how are they related?
Related
I have a csv file with longitude and latitude coordinates at various times and then another column that assigns a value from 1-10 for each of the location points. I want to create a contour map of each location and its value as a visualization. I was thinking of using mathematica but the very little programming experience I have is with python only.
You can try my implementation for geographic maps in PHP at https://contourplot.codeplex.com. It uses a delaunay triangulation and a linear transformation along the edges of the triangles. It also uses 2 colors to show the difference between local and statewide z-values of any triangles and also the triangles and isolines maps nicely with the border (from the shapefile). Some shapes with extreme concavities, holes and islands can be a problem. Another algorithm is conrec from Paul Bourke. There is also the algorithm from indiemaps blogs but only for openlayers.
Here's my problem. I want to compare the area within multiple polygons in different parts of the world. I have the longitude and latitudes for each point of each polygon. My problem is that I don't know what projection to use to get x-y coordinates from the long-lat coordinates. I know OpenStreetMap has the projectMercator() function, but areas are known to inflate quite badly with latitude. (http://en.wikipedia.org/wiki/List_of_map_projections)
--> Do you guys know of an R function like projectMercator, that doesn't have such a distortion? I've been going over different types of projections in Wikipedia, but it's very unclear to me which is best for area comparisons, and then if those projections exist in R as functions (if they don't I'm fine hand coding them, though!)
Thanks!!!
Hillary
Mine are follow-ups to the question & answer in Approaches for spatial geodesic latitude longitude clustering in R with geodesic or great circle distances.
I would like to better understand:
Question #1: If all the lat / long values are within the same city, is it necessary to use either fossil or distHaversine(...) to first calculate great circle distances ?
or, within a single city, is it OK to run clustering on the lat/long values themselves ?
Question #2: jlhoward suggests that :
It's worth noting that these methods require that all points must go into some cluster. If you just ask which points are close together, and allow that some cities don't go into any cluster, you get very different results.
In my case I would like to ask just ask "which points are close together", without forcing every point into a cluster. How can I do this ?
Question #3: To include one or two factor variables into the clustering (in addition to lat/long), is it as easy as including those factor variables in the df upon which the clustering is run ?
Please confirm.
Thanks!
"within a single city, is it OK to run clustering on the lat/long values themselves ?"
Yes, as long as your city is on the equator, where a degree of longitude is the same distance as a degree of latitude.
I'm standing very close to the north pole. One degree of longitude is 1/360 of the circumference of the circle round the pole from me. Someone ten degrees east of me might only be ten feet away. Someone one degree south of me is miles away. A clustering algorithm based on lat-long would think that guy miles away was closer to me than the guy I can wave to ten degrees east of me.
The solution for small areas to save having to compute great-circle ellipsoid distances is to project to a coordinate system that is near-enough cartesian so that you can use pythagoras' theorem for distance without too much error. Typically you would use a UTM zone transform, which is essentially a coordinate system that puts its equator through your study area.
The spTransform function in sp and rgdal will sort this out for you.
I'm making a core-location driven app where I must calculate lots of things for a given latitude/longitude pair, such as:
Distance to another lat/long coordinate
The target lat/long coordinate when traveling a distance x into direction y
Is there something open sourced which can be used?
Since you are using CoreLocation, you can use CoreLocation's distanceFromLocation as #progrmr points out.
On the other hand, since you specified open source, and that ain't open sourced, you can look at GeographicLib implementations as suggested by #MikeT.
(My original answer, suggesting the Haversine formula, was flawed. As #MikeT points out, the Haversine formula is only valid for spheres. And the Earth is not a perfect sphere.)
Original, flawed answer:
It sounds like you want the Haversine formula.
The Wikipedia page for the Haversine formula explains what it is and (at the bottom, under "External links") contains links to many implementations. I haven't checked, but I have to imagine that at least some of them are open source projects.
There are some C functions on github that does heading from a coordinate pair, or destination coordinates given start and heading. Distance between coordinates you can do with CLLocation.
These are based on the Spherical Law of Cosines and derived from the algorithms here and here.
GeographicLib has been implemented in several programming languages, including Java. The library calculates lengths and related mathematical properties of geodesics on ellipsoids of revolution (or spheroid). The calculation errors are generally in the range of micrometers.
To find the distance between two coordinates:
GeodesicData g = Geodesic.WGS84.Inverse(lat1, lon1, lat2, lon2,
GeodesicMask.DISTANCE);
then get g.s12 for the distance between the two points.
The second example in the question, to project a location given distance and direction, is found using the Direct methods.
I've been searching extensively for a way of converting from ordanance survey coords to valid esri coordinates. I've found quite a few pages that convert to lat long (if a little off) but nothing to convert to esri (which I believe is utm.)
This is for use in python or JavaScript / actionscript etc - I'm not too worried about syntax more an understanding of the maths involved.
Thanks
Ian
This type of conversion is called a "geodetic transformation". OS and UTM are both "transverse mercator" projections, wherein the ellipsoid of the earth is unwrapped into a cylinder, which is then unrolled into a flat sheet and sub-divided into grid sections. OS coordinates are specific to regions (eg: OSGB for Great Britain), whereas UTM is a "universal" system and specifies a system of grids for the whole earth. Regional grids are used in order to reduce the side-effects of distortion introduced by the mercator projection. It follows that converting between such systems is possible, but can also be quite complex depending in the accuracy desired.
It seems there are only indirect methods, as you have already referred to, the most common being to convert from OSGB36 to WGS84 (lat/long) and then to UTM.
Here are some resources which might be helpful:
Convert WGS84 lat/long to UTM: http://www.uwgb.edu/dutchs/usefuldata/utmformulas.htm. Note the inclusion of specific parameters for each region. For example, if you were converting coordinates for Britain, the parameters for "Airy 1830" would be used. (also links to a spreadsheet and webpage with conversions).
Similar information as above on Wikipedia.
JavaScript to convert OSGB36 to WGS84 (7 metre accuracy): http://www.nearby.org.uk/tests/GeoTools.html
A more accurate JavaScript conversion using a Helmert transformation (5 metre accuracy): http://www.movable-type.co.uk/scripts/latlong-convert-coords.html and http://www.movable-type.co.uk/scripts/latlong-gridref.html
Comprehensive coverage of the OSGB36 coordinate system, including transformations to and from other coordinate systems: http://www.ordnancesurvey.co.uk/oswebsite/gps/docs/A_Guide_to_Coordinate_Systems_in_Great_Britain.pdf
Miscellaneous links and resources: http://www.ordnancesurvey.co.uk/oswebsite/gps/information/resourceinfolinks/gpslinks.html
As for accuracy, it is summed up in this excerpt from ordnancesurvey.co.uk:
... OSGB36 contains randomly variable scale errors, mainly due to it being
computed in blocks and the fact that scale and azimuth were
controlled entirely by the 11 stations from the
Principle Triangulation. These scale variations
mean that OSGB36 can be described as inhomogeneous ...
The inhomogenity of OSGB36 does not affect its
adequacy as a mapping datum but it does make a
simple transformation between ETRS89 and OSGB36 too inaccurate for national use.
For example, the accuracy of a national 7 parameter (3
shifts, 3 rotations and a scale change) transformation is approximately 5 metres
Here is a link to more comprehensive information regarding the ARC/INFO file format.
Quick google search: http://google-maps-utility-library-v3.googlecode.com/svn/trunk/arcgislink/docs/examples.html