2

I get different results when measuring a object in QGIS and/or Postgis!

To have something exact I did this:

In QGIS:

  • create a point shp-layer (epsg 25832)
  • add a point
  • created a buffer around it with 100 m
  • made a polygon from layer extents

So I should have a square with 200 m x 200 m right and 40000 qm? And that is what is shown in the attribute table which is created automatically by the "Polygon from layer extent"-Function!

But: When I create a new column and measure the area with $area in QGIS the result is: 39892.72715?

When I import the layer to a postgis (keeping the epsg) table and measure the area with ST_area the result is: 40000.0000000116?

The difference between QGIS and postgis becomes much larger when polygons are involved!

Do I miss something?

Well I/You can reproduce the the result by doing this:

Create a .csv file (called it Point.csv) with this content:

nr,x,y
1,437850,5795350

Add this .csv to a new QGIS project (Set to EPSG:25832) as new Layer with "Add Delimited Text Layer ..." again with EPSG:25832. Now there is point layer called Point.

Now I use Vector > Geoprocessing Tools > Buffer(s) ... with this settings:

Input Vector layer: Point
Segments to approximate: 25
Buffer distance: 50
Output shapefile: BufferPoint.shp

Next I create the square: Vector > Research Tools > Polygon from Layer Extent... with this settings:

Input: BufferPoint
Output: SquarePoint

When I now look into the attribute table (the columns and values are created automaticly) everything looks fine:

MINX      MINY    MAXX    MAXY      CNTX     CNTY         AREA    PERIM  
437800.0 5795300.0 437900.0 5795400.0 437850.0  5795350.0   10000.0   400.0 

HEIGHT WIDTH 
100.0   100.0

But when I create new columns within this attribute table with the field calculator ($area and $perimeter) (both "real", length 15, precision 5) I get this values:

area1         border1
9973.36847    400.14108

And this is what makes me confused?

PS: the Values I get in PostGis (ST_Area, ST_Perimeter) also differ from the expected and right values!

underdark
  • 84,148
  • 21
  • 231
  • 413
StefanW
  • 23
  • 4
  • could you provide the geometry as text so we can test with? – kttii Aug 31 '16 at 14:22
  • @kttii I edited the question with a example, if You need more info: please ask – StefanW Sep 02 '16 at 15:21
  • Thank you sir. I'm no expert at projections but I would venture a guess that the new column is accounting for skew of the polygon into the projection system? – kttii Sep 02 '16 at 15:30
  • Try this answer: http://gis.stackexchange.com/questions/37095/how-to-measure-areas-of-features-in-openlayers-plugin-background-maps-correctly/37114#37114 – kttii Sep 02 '16 at 15:36

1 Answers1

2

This is a long running story in QGIS. Take a look at https://hub.qgis.org/issues/12057

Simple solution: remove all layers that don't use EPSG:25832, and turn OTF reprojection OFF. Then the field calculator calculates area and perimeter on a planar system as 10000 and 400.

Turning OTF ON, I get the values 9973.36 and 400.14108 as you did.

As an alternative, go to Project -> Project Properties -> General tab, Measurement section, and set the Ellipsoid to None/Planimetric while OTF is on. Then QGIS will always do 2D-area calculation. Else, it calculates on an ellipsoidal surface.

Tested with QGIS 2.16.1 on Windows.

AndreJ
  • 76,698
  • 5
  • 86
  • 162
  • Yes that´s it. Now it works fine in QGIS !! Thanks a lot! – StefanW Sep 05 '16 at 10:26
  • @ AndreJ Is there also a solution/workflow for PostGIS? – StefanW Sep 05 '16 at 10:36
  • 1
    See http://gis.stackexchange.com/questions/169422/how-does-st-area-in-postgis-work and http://postgis.net/docs/ST_Area.html . Note that the calculation on an ellipsoid is more "correct" than the planar calculation. – AndreJ Sep 05 '16 at 11:28