I need to calculate a polygon area on my mapView. I studied this case, and de Polylines shows the best way to make a area, with the points that the user was informed. But I didn't find the way to calculate his area! Can anyone help me please? Or suggest other alternative to draw polygons and calculate area/perimeter in android application.
convert lat/lon points to cartesian space
Use area of polygon formula you easily find in wiki.
ad 1) if polygons diameter are not more than some 10s of kilomters an EquiRectangular Projection makes sense and is very simple, using the center of the polygon as center of transofrmation (cos (centerLatitude)).
Otherwise task 1 is complex.
Related
I am developing a react-native-mapbox-gl app on Windows 10. I need to "round" GeoJSON points uploaded to the app so that they appear in the center of a house block. For example:
Figure 1: A marker is added on the northeaster corner of a block
Figure 2: The marker is "rounded" / "moved" to the geographical center of the block
Since it's unfeasible to manually create a GeoJSON geometry for every street there is, is there a way to achieve this?
If you encode the boundaries of a particular block as a Polygon feature, you can then use Turf.js's centroid method to calculate the center of said polygon. This will return a coordinate that can be used for the location of the marker.
If you don't have the geographic bounds of these features, one option would be to use the Mapbox Tilequery API to query for all building features within a particular radius, and then create a LatLngBounds object containing these buildings to use as the Polygon defining the boundaries of the block.
I am developing field area calculator app using gps location.Is there any way to calculate the
area of given gps locations?
You can calculate the area of an polygon that is formed by a sequence of GPS coordinates.
The steps are:
transform the spherical lat/lon coordinates to cartesian space.
Use the general formula for area of polygon.
Code is given in this answer:
Polygon area calculation using Latitude and Longitude generated from Cartesian space and a world file
Use the center of the polygon (or just any point of the polygon) as center of transformation.
In the code in the link, that is called latAnchor and lonAnchor.
Especially if the diameter of the polygon does not exceed some 10 kilometers this approach works well. For large polygons step 1 becomes more complex.
Can anyone, help me draw a circle or rather precisely an Arc with a given center point (GeoPoint) and the start and end points as well. So basically, it should help me draw a sector with given center point along with start and end points. I'm planning to use PathOverlay as my baseclass from OSMdroid, so that it would be easier for me to remove or add.
I understand the greatCircle provided in PathOverlay of OSMdroid, but not quit sure how to make use of it, I was wondering if any sample example be provided. Also How would I set the center of this GreatCircle.
Don't use a PathOverlay to draw filled polygons: as you noticed, this doesn't work properly when portions of the polygon are outside the screen.
for filled polygons, use an OSMBonusPack Polygon.
For setting the points of your arc, there is no ready-to-use API currently.
A "great circle" on a map represents the shortest "as the crow flies" path between two points. It is going to look like a straight line on your map. You need to think of the Earth as a sphere when considering the centre of the great circle; the centre is of course, the centre of the Earth.
I have partial map of the world (like America or Africa). and I need to know to pixel size of the world map based on the size of the partial/cropped map pixel size.
I have the size in pixel of the partial map (like 480x256), and I have the minLongitude,maxlongitude,minlatitude,maxlatitude (aka left,right,top,bottom edge)
I know that longitude is easy because linear :
FULL_CIRCLE_DEG = 360
longitudeDelta = (maxLongitude-minLongitude)/FULL_CIRCLE_DEG
MapFullSize = mapCroppedWidth/longitudeDelta
But for the latitude, it's kind of different:
FULL_LATITUDE_DEG = MAX_LAT_ON_EARTH - MIN_LAT_ON_EARTH (like 85.7543...-(-85.7543...))
latitudeDelta = (maxLatitude-minLatitude)/FULL_LATITUDE_DEG
MapFullHeight = ????
Please someone can help me ?
I find lot of algorithm to get a GPScoordinateToPixel conversion but nothing on square calculation.
Thank you.
Here's an idea. First work out the area of your rectangle which is specified by minLongitude,maxlongitude,minlatitude,maxlatitude. Then the ratio of your current map area to the area of the whole world map could be used to scale up the current number of pixels that the map currently occupies to the number of pixels that would be required for the whole map.
To work out the area that the map currently occupies, I think you need a bit of spherical trigonometry, and you can find what you need here on wikipedia. That page on wikipedia gives you a formula for the area of a spherical triangle, so if you regard your rectangle as two triangles, you can use that formula and calculate the area of the current map.
I have searched for explanations and algorhitms how to calculate Earth's polygon surface area. I've found this and this
Lets say I got already convex hull points
[56.992666,24.126051], [58.00282,25.930147], [58.787955,25.565078], [59.4997,24.861427], [59.463678,24.711365], [59.395767,24.599837], [56.992666,24.126051]
From second link the first answers uses Python library and second answer approach won't give quite precise area even if we assume that Earth is sphere (am I right)?
What approaches could I take for calculating the area (less expensive) if we assume that Earth is sphere?
In addition, I have looked for different libraries (geotools.org etc) but haven't found in their documentation about area calculation.
The algorithm for finding the area of a polygon on a sphere can be found here:
Thread: A method to compute the area of a spherical polygon
You could also use this NASA JPL paper for some algorithms:
Some algorithms for polygons on a sphere.