Before I wade into writing my own function, is anybody able to confirm whether MMA has an inbuilt method for converting longitude and latitude geographic coordinates (as used to specify the position of a point on the earth's surface in the GeoPosition function) to British National Grid coordinates (and visa versa)?
Asked
Active
Viewed 223 times
1 Answers
2
You need the datum "OGB7" and the projection
proj = {"TransverseMercator", "Centering" -> {49., -2.}, "GridOrigin" -> {400000, -100000}, "CentralScaleFactor" -> 0.9996012717, "ReferenceModel" -> "OGB7"}
If you start with a position
p = GeoPosition[{lat, lon}]
then you need (this performs a change of datum and a projection simultaneously):
GeoGridPosition[p, proj, "OG7B"]
Let us separate the two steps in this example:
In[]:= bigben = GeoPosition[Entity["Building", "ElizabethTower::4brf8"]]
Out[]= GeoPosition[{51.5006, -0.124611}]
Those {lat, lon} are in the "ITRF00" datum, which is nearly identical to "WGS84". We first convert to "OGB7" with GeoPosition:
In[]:= GeoPosition[bigben, "OGB7"]
Out[]= GeoPosition[{51.5001, -0.123018}, "OGB7"]
Now we can project, obtaining the coordinates you need:
In[]:= GeoGridPosition[%, proj]
Out[]= GeoGridPosition[{530268., 179630.}, {"TransverseMercator", "Centering" -> {49., -2.}, "CentralScaleFactor" -> 0.999601, "GridOrigin" -> {400000, -100000}, "ReferenceModel" -> "OGB7"}, "OGB7"]
You can go back with GeoPosition:
In[]:= GeoPosition[%]
Out[]= GeoPosition[{51.5001, -0.123018}, "OGB7"]
But that is again in the "OGB7" datum. We can get the original {lat, lon} with
In[]:= GeoPosition[%, "ITRF00"]
Out[]= GeoPosition[{51.5006, -0.124611}, "ITRF00"]
jose
- 6,328
- 1
- 14
- 24
-
Thanks Jose. I worked out how to do this a while back and now have a couple of simple functions that implement the transformation system both ways. All the best, Ian – Ian Nov 18 '17 at 08:50