How Do I Get The Area Of A Geojson Polygon With Python
I have the GeoJSON { 'type': 'FeatureCollection', 'features': [ { 'type': 'Feature', 'properties': {}, 'geometry': { 'type': 'Polygon', 'c
Solution 1:
It looks like geojson.io is not calculating the area after projecting the spherical coordinates onto a plane like you are, but rather using a specific algorithm for calculating the area of a polygon on the surface of a sphere, directly from the WGS84 coordinates. If you want to recreate it you can find the source code here.
If you are happy to carry on projecting the coordinates to a flat system to calculate the area, since it's good enough accuracy for your use case, then you might trying using this projection for Germany instead. E.g:
from osgeo import ogr
from osgeo import osr
source = osr.SpatialReference()
source.ImportFromEPSG(4326)
target = osr.SpatialReference()
target.ImportFromEPSG(5243)
transform = osr.CoordinateTransformation(source, target)
poly = ogr.CreateGeometryFromJson(str(geoJSON['features'][0]['geometry']))
poly.Transform(transform)
poly.GetArea()
which returns 87127.2534625642
Post a Comment for "How Do I Get The Area Of A Geojson Polygon With Python"