Bug report #8558
Switching CRS On The Fly messes up area calculations
|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.
#2 Updated by Charles Rethman about 9 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.