1

First, I created a regular grid of the size 1km^2 (epsg: 2056). Then I calculated the area of of this grid using different GIS:

Python: arcpy

area_arc

# Python Setup
import arcpy
arcpy.env.overwriteOutput = True

# Data_in
poly = "C:/Hexbins.shp"

# Area Caculation
arcpy.AddField_management(poly,'area_arc','DOUBLE')
arcpy.CalculateField_management(poly,'area_arc','!shape.area!','PYTHON')
#arcpy.CalculateGeometryAttributes_management(poly,["area_arcpy", "AREA"],'Meters')

R sf

area_sf

Hexbins<- read_sf("LC:/Hexbins.shp")

Hexbins<-Hexbins %>% 
mutate(
area_sf= as.vector(st_area(.))
) 

QGIS

area_q

Field calculator: 
Input: poly
- output field name: area_q
Output field type: Decimal number (real)
Outpu field length: 10
Precision: 3
Expression: $area

area_q2

Field calculator: 
Input: poly
- output field name: area_q
Output field type: Whole number
Outpu field length: 10
Precision: 3
Expression: $area

The libraries Python arcpy and R sf lead to the expected result of 1km^2. The result I obtained using qgis is somewhat astonishing:

The libraries Python arcpy and R sf lead to the expected result of 1km^2. The result I obtained using QGIS $area is somewhat astonishing:

enter image description here

Is there an explanation for this randomness?

4

This is because EPSG:2056 is an Oblique Mercator projection that is "An oblique cylindrical projection that is conformal but not equal area". So it doesn't preserve area (as you are seeing).

  • Interesting, but why do R sf and Python arcpy lead to the result I expected? I used the same CRS for all area calculations. – kalakaru May 8 at 8:55
  • rounding error? – Ian Turton May 8 at 9:11
  • R sf and Python arcpy lead to exactly 1'000'000 m^2 = 1km^2. It seems to me that QGIS calculates the area differently than R sf and Python arcpy. I do not see, where the rounding errors could happen. – kalakaru May 8 at 9:49
  • 2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.