Hot answers tagged

30 votes
Accepted

Calculating area in km² for Polygon in WKT using Python

It wasn't readily apparent to me how to use @sgillies answer, so here is a more verbose version: import pyproj import shapely import shapely.ops as ops from shapely.geometry.polygon import Polygon ...
user avatar
  • 1,178
30 votes
Accepted

Getting polygon areas using GeoPandas

If the crs of the GeoDataFrame is known (EPSG:4326 unit=degree, here), you don't need Shapely, nor pyproj in your script because GeoPandas uses them). import geopandas as gpd test = gpd.read_file("...
user avatar
  • 50.7k
26 votes

Calculate area for each polygon in R

You can do library(raster) x <- shapefile('file.shp') crs(x) x$area_sqkm <- area(x) / 1000000 Or with terra library(terra) x <- vect('file.shp') x$area_sqkm <- expanse(x) / 1000000 That ...
user avatar
20 votes

Calculating area in km² for Polygon in WKT using Python

It looks like your coordinates are longitude and latitude, yes? Use Shapely's shapely.ops.transform function to transform the polygon to projected equal area coordinates and then take the area. ...
user avatar
  • 8,468
19 votes
Accepted

How to calculate the polygon area and create a column of results in R

Can you provide data for an example? Anyways, try this: library(sf) f <- st_read("shapefile.shp") f$area <- st_area(f) #Take care of units Best
user avatar
  • 828
18 votes
Accepted

Calculate total area of polygons in shapefile using GDAL?

There's a special field in OGR SQL called OGR_GEOM_AREA which returns the area of the feature's geometry: ogrinfo -sql "SELECT SUM(OGR_GEOM_AREA) AS TOTAL_AREA FROM myshapefile" myshapefile.shp ...
user avatar
17 votes

More accurate way to calculate area of rasters

There is a relatively simple exact formula for the area of any spherical quadrangle bounded by parallels (lines of latitude) and meridians (lines of longitude). It can be derived straightforwardly ...
user avatar
  • 67.5k
15 votes

Creating a circle with radius in metres

By design Shapely is unaware of coordinate reference systems or units. To use it to solve real world problems, you must learn to transform longitude and latitude to an approximately planar local ...
user avatar
  • 8,468
15 votes
Accepted

Circle area calculation in QGIS is inaccurate

All recent versions of ArcGIS cheat -- the underlying shape type knows when it was generated as a circle, and reports a perfect circle area, even when the vertex count would make it an octagon. I ...
user avatar
  • 18.8k
14 votes

Why accurate area of all countries cannot be obtained using a single EPSG code, even if it corresponds to an equal-area projection?

What went wrong: EPSG:3395 is not equal area The CRS you use, EPSG:3395, is definitely not an equal area projection. It is a World Mercator projection that heavily distorts areas, see here, including ...
user avatar
  • 40k
14 votes
Accepted

Calculating area of lat/lon polygons without transformation using GeoPandas

Overview Since version 0.7.0 geopandas has embedded the pyproj library as the crs object. pyproj, since version 2.3.0, has the ability to calculate the area of arbitrary polygons on a sphere. (see ...
user avatar
  • 865
11 votes

How does ST_Area in PostGIS work?

SELECT      st_astext(col)     ,st_area(col, false) AS area FROM table ST_Area(geometry) calculates the polygon area as WGS1984, WITHOUT ...
user avatar
11 votes
Accepted

Calculating area of newly added polygons on same layer?

You can use the AutoFields plugin, which solves exactly that issue. Go to the plugin's docked window, select your polygon layer, choose the 'Area' field from the list of existing fields, choose the ...
user avatar
11 votes
Accepted

Using area() or $area function in QGIS, when the data (polygon) is stored in UTM?

The curved surface of the spheroid is unfailingly deformed when taken to the plane. The planimetric area is not equal to the ellipsoidal area. The differences, moreover, are not constant in a ...
user avatar
11 votes

Calculating area of polygons without script in QGIS Field calculator

There are two tabs under the field calculator - Expression and Function editor, i suppose you're referring to the function editor tab which requires coding skills. If you stay on the Expression tab ...
user avatar
  • 5,473
10 votes

Removing only some donut holes from polygons using ArcMap

You can use "Eliminate Polygon Part" tool (Data Management Tools -> Generalization) in ArcToolbox. You can specify minimum hole area/percentage to remove.
user avatar
10 votes

Calculating area in km² for Polygon in WKT using Python

The above answers seem to be correct, EXCEPT that at some point recently, the lat1 and lat2 parameters in the pyproj code were renamed with underscores: lat_1 and lat_2 (see https://stackoverflow.com/...
user avatar
10 votes
Accepted

Deleting polygons smaller than certain dimension using ArcGIS Desktop?

Use my script from Checking if polygon fits inside another polygon using ArcGIS or QGIS? to create points inside your polygons. Each point is a centre of maximum inscribed circle of the parcel. ...
user avatar
  • 21.4k
10 votes

Calculating proportional area of polygon within another layer's polygon using QGIS

Take your model layer and in the attribute table, add a new field called area_mod for example. Note that there are two ways to generate area: $area is an ellipsoid based calculation using not just ...
user avatar
  • 9,921
10 votes

Selecting polygon with the largest area in QGIS

You would be better off using "Select by expression" instead of "Select by attribute". Your expression should be something like: "AREA" = maximum("AREA") ...
user avatar
  • 1,956
10 votes
Accepted

How does $area function calculate area in QGIS?

Function $area: Returns the area of the current feature. The area calculated by this function respects both the current project's ellipsoid setting and area unit settings. For example, if an ...
user avatar
10 votes
Accepted

$area gives NULL for some polygons in QGIS's Field Calculator

Short Answer you have to re-project the shapefile to EPSG:3148 - Indian 1960 / UTM zone 48N Long Answer Load the shapefile Left click the shapefile in Layers pallet Go to Export > Save feature as ...
user avatar
10 votes

Calculating polygon area in QGIS without adding new field

The identify tool does offer you this information. Click any feature, then expand the topmost dropdown menu. Here all basic geometric information is hidden, incl. the area and circumfence.
user avatar
  • 12.4k
10 votes

Calculating polygon area in QGIS without adding new field

Create a label with the expressin $area (I should have used round($area)):
user avatar
  • 51.2k
9 votes
Accepted

How to calculate a percentage of an area covered by polygons ArcGIS 10.1

There are two ways of calculating, raster on raster or vector on vector. radouxju has given an instruction on raster on raster but I believe the vector on vector might be more what you're after. ...
user avatar
9 votes

Area is calculating wrong using $area in field calculator (QGIS 2.8.1-Wien)

It took me 2 hrs to figure this out.Use area($geometry) instead of "$area" because according to the QGIS documentation, "area" returns the area of a geometry polygon object. Calculations are always ...
user avatar
  • 101
9 votes

Calculating area of newly added polygons on same layer?

There are 2 approaches: 1/ select all area's which has no value ("Area" is null) and do the calculation just on the selected ones. Check 'only update XXX selected features' and 'update existing field'...
user avatar
  • 5,069
9 votes

Calculate total area of polygons in shapefile using GDAL?

Yes, it is possible, but you need to use the OGR SQLite dialect as follows: ogrinfo -dialect SQLite -sql 'SELECT SUM(ST_Area(geometry))/10000 FROM myshapefile' myshapefile.shp Also, ensure that ...
user avatar
  • 4,752
9 votes

Calculating percentage of overlap of two layers in QGIS 3

Since QGIS 3.8, it's now included in QGIS core, without plugin or coding. In the Processing Toolbox, search for Overlap and open the Overlap analysis: Source: http://changelog.qgis.org/en/qgis/...
user avatar
  • 5,665
9 votes

Why accurate area of all countries cannot be obtained using a single EPSG code, even if it corresponds to an equal-area projection?

In addition to the fact that EPSG:3395 is not an equal area projection (therefore inaccurate for area measures), as mentioned by @Babel, a precise measure of the area requires a good projection. ...
user avatar
  • 48.5k

Only top scored, non community-wiki answers of a minimum length are eligible