Bug report #8558

Switching CRS On The Fly messes up area calculations

Added by Charles Rethman about 6 years ago. Updated over 4 years ago.

Category:Projection Support
Affected QGIS version:master Regression?:No
Operating System: Easy fix?:No
Pull Request or Patch supplied:No Resolution:duplicate
Crashes QGIS or corrupts data:No Copied to github as #:17307


My data covers whole Southern Africa region -- South Africa up to DRC-- therefore it is stored in Long-Lat WGS84. However, I need to do many calculations with the data such as area, distances etc. and therefore I project to Albers EAC or Lamberts CC (I use UTM for Malawi, Swaziland and Lesotho). I have defined a set of "national" Albers EA CRSs and saved them as user-defined or custom CRSs in QGIS 1.9. The bug happens as follows: I load a set of data that are in Long-Lat and then enable Set CRS On The Fly and change project CRS to my user-defined (custom) one. All the layers are reprojected. If I now load a layer that is in the custom CRS, and then use the Field Calculator to add a column and calculate something on the geometry (such as $Area), I get nonsense numbers in the new calculated field. To get a sensible result, I must first close the file with the long-lat dat in it, and then open the file with the only the custom projection data. I can then do the calculations I require.

In short, it appears QGIS does not like layers with different CRSs, even if they are reprojected On The Fly to whichever one is working in . It works reliably when all the layers have the same CRS.

My Albers EA proj4 definition is +proj=aea +lat_1=-19.3 +lat_2=-25.38 +lat_0=0 +lon_0=24.69 +x_0=500000 +y_0=3000000 +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs.

Example data for Botswana also supplied.

demog_eas.prj (412 Bytes) Charles Rethman, 2013-09-03 12:07 AM

demog_eas.cpg (5 Bytes) Charles Rethman, 2013-09-03 12:07 AM

demog_eas.shp - Enumeration Areas in Botswana in Albers EA, used to calculate area (1.33 MB) Charles Rethman, 2013-09-03 12:07 AM

demog_eas.dbf (3.2 MB) Charles Rethman, 2013-09-03 12:07 AM

demog_eas.shx (11.3 KB) Charles Rethman, 2013-09-03 12:07 AM

demog_eas.qpj (447 Bytes) Charles Rethman, 2013-09-03 12:07 AM


#1 Updated by Giovanni Manghi about 6 years ago

  • Status changed from Open to Feedback
  • OS version deleted (10.8)
  • Operating System deleted (Mac OS X Mountain Lion)
  • Priority changed from High to Normal

it seems duplicate of #4564 - please leave feedback.

#2 Updated by Charles Rethman about 6 years ago

  • Assignee set to Giovanni Manghi

Looking at #4564, my issue is similar, although more specific to 1.9 (2.0 alpha) because the Field Calculator is now a part of the core app functionality. It would make sense to merge the two issues if you like but I think it's important to this release. Also, my feature request #8559--Field Calculations on geometry (such as $Area) should take place in the Project CRS (even that has been re-projected "on the fly") and not in the CRS of the original file--is related to this bug.

#3 Updated by Giovanni Manghi about 5 years ago

  • Assignee deleted (Giovanni Manghi)

#4 Updated by Giovanni Manghi over 4 years ago

  • Resolution set to duplicate
  • Status changed from Feedback to Closed

see #12057

Also available in: Atom PDF