Say I have a square which consists of four CLLocationCoordinate2D points, which are in lat, lon, and I want to find the area of the square in meters. I convert the CLLocationCoordinate2D points into MKMapPoints, and I find the area in X-Y space. However, the area I find is in the units of MKMapPoint, which don't directly translate to meters. How can I translate this area in MKMapPoint-space back into meters?
Asked
Active
Viewed 4,398 times
2 Answers
8
The MapKit function MKMetersBetweenMapPoints
makes this easier.
For example, if you wanted to get the area of the currently displayed region:
MKMapPoint mpTopLeft = mapView.visibleMapRect.origin;
MKMapPoint mpTopRight = MKMapPointMake(
mapView.visibleMapRect.origin.x + mapView.visibleMapRect.size.width,
mapView.visibleMapRect.origin.y);
MKMapPoint mpBottomRight = MKMapPointMake(
mapView.visibleMapRect.origin.x + mapView.visibleMapRect.size.width,
mapView.visibleMapRect.origin.y + mapView.visibleMapRect.size.height);
CLLocationDistance hDist = MKMetersBetweenMapPoints(mpTopLeft, mpTopRight);
CLLocationDistance vDist = MKMetersBetweenMapPoints(mpTopRight, mpBottomRight);
double vmrArea = hDist * vDist;
The documentation states that the function takes "into account the curvature of the Earth."
-
ok thanks, this is pretty helpful. but what if I have a irregular polygon? There is a formula for the area of a polygon given the vertices, but I would be doing the calculation in MKMapPoint units. How would I convert those to meters? – Paul Sep 14 '11 at 05:11
-
The question said "square" so I gave an example of a rectangular area. Even then, _the above is still an approximation and only useful for relatively small areas_ where the curvature isn't a significant factor (though the _distance_ function is accurate regardless). For irregular polygons, sorry I don't have a simple answer. Try starting with [this answer](http://stackoverflow.com/questions/1340223/calculating-area-enclosed-by-arbitrary-polygon-on-earths-surface). You'll have to decide what algorithm you want to use and go from there. – Sep 14 '11 at 13:34
-
Try this to calculate area of an irregular polygon: http://stackoverflow.com/questions/22038925/mkpolygon-area-calculation – Feb 26 '14 at 13:33
0
You can use the Haversine formula to calculate it, assuming that the earth is a perfect sphere.
To understand how lat/lon vs meters works in the context of the earth, you may find it interesting to read about Nautical miles.
You can find some more resources and some sample code by googling objective-c Haversine formula.
Enjoy!

vfn
- 6,026
- 2
- 34
- 45