2

I've got a series of Location / GeoPoint objects that form a polygon in my Android app. I wonder if there's any way to calculate the area covered by it.

So far I'm thinking about setting up a web service that, when posted the list of coordinates, uses the JS Google Maps API v3 to calculate the area. But there might be a way of doing this easily with some feature from Android I don't know about, natively.

Thanks in advance for your help!

fdansv
  • 87
  • 2
  • 8
  • This might help: http://stackoverflow.com/questions/9037083/calculating-area-of-a-polygon-drawn-on-google-map – ferrants Oct 24 '12 at 20:35
  • Yeah I had already checked that out, but I'm looking for a solution specific to Android (which, as far as I know, doesn't have Google Maps API v3 implemented) – fdansv Oct 24 '12 at 20:42
  • 1
    David: yes, look at [this](https://gist.github.com/fdansv/6579158). You'll need [this library](http://www.jstott.me.uk/jcoord/). Sorry if the code contains dependencies and stuff, it's a project from long ago. – fdansv Sep 16 '13 at 10:52
  • @fdansv what is the unit of the calculated area? – Syed Waqas Sep 24 '13 at 06:57
  • square metres if I remember correctly – fdansv Sep 24 '13 at 10:17
  • I posted a method doing this here: http://stackoverflow.com/a/16210785/891479 – L. G. Sep 27 '13 at 13:56
  • Hi. Do you remember how you got the vertices of the polygons? Looking for an answer to find vertices of a polygon on google maps – Optimus Prime Jun 27 '16 at 17:07

3 Answers3

3

A method doing this is posted in following answer:

https://stackoverflow.com/a/16210785/891479

This is based on following formula:

http://mathworld.wolfram.com/PolygonArea.html

http://en.wikipedia.org/wiki/Polygon

Principle of plolygon area calculation using this formula:

http://maruzar.blogspot.com/2011/12/irregular-and-regular-polygon-area-by.html

Community
  • 1
  • 1
L. G.
  • 9,642
  • 7
  • 56
  • 78
1

If you want to do it yourself, the way to calculate any polygn area knowing the corrdinates is explained in Polygon.

You can find a more comprehensive explanation in How to Calculate the Area of a Polygon under the topic Irregular Polygons

Luis
  • 11,978
  • 3
  • 27
  • 35
0

Just in case it helps someone, there is a very good answer in this thread: Calculate the area of a polygon drawn on google maps in an Android application

The answer from Marian Paździoch:

There's already a library for that.

import com.google.maps.android.SphericalUtil;

//...

List<LatLng> latLngs = new ArrayList<>();
latLngs.add(new LatLng(51.893728, -8.491865));
latLngs.add(new LatLng(51.893550, -8.492479));
latLngs.add(new LatLng(51.893216, -8.492224));
latLngs.add(new LatLng(51.893404, -8.491598));
Log.i(TAG, "computeArea " + SphericalUtil.computeArea(latLngs));
Community
  • 1
  • 1
androidseb
  • 1,257
  • 2
  • 14
  • 17