[QGIS-Developer] Difference in area calculation using memory vs output layer
Rudi von Staden
rudivs at gmail.com
Fri Aug 10 12:14:45 PDT 2018
On Thu, 9 Aug 2018 at 08:39, Nyall Dawson <nyall.dawson at gmail.com> wrote:
> On Wed, 8 Aug 2018 at 18:06, Rudi von Staden <rudivs at gmail.com> wrote:
>
> >
> > I did also calculate a range of zonal stats on the layer (which has only
> one multipolygon feature), but those results were consistent between output
> / memory layers.
> >
> > Is the area difference expected because of how shapefiles store geometry
> vs how they are handled by memory layers, or could there be a bug
> somewhere? Maybe this isn't the recommended way to calculate area? In case
> it matters, I'm using a custom CRS:
> >
> > "+proj=aea +lat_1=-24 +lat_2=-32 +lat_0=0 +lon_0=24 +x_0=0 +y_0=0
> +datum=WGS84 +units=m +no_defs"
>
> This may be a silly question -- but can you confirm that both layers
> are definitely in the same CRS?
>
Yes, they are both the result of an algorithm operating on the same source
layer.
> If so, I'd try exporting the two geometries to WKT and inspect for
> differences.
>
There are partial differences between the WKT. It seems that the OGR layer
drops some polygons. I also used isGeosValid() to check the validity, and
the OGR layer reported invalid geometry, while the Memory layer was valid.
I should note that the input layer has some invalid geometries (I'm using
buffer by 0 to try to clean up the geometry). I've put together a test
project and processing script to demonstrate the issue, including text
files with the WKT of the memory and ogr features. As a side-note, the
script also crashes QGIS a minute or so after running. I suspect it's
because I may have used incorrect output parameters.
https://www.dropbox.com/s/u1la8y63qlabiu4/area_test.zip?dl=0
Let me know if I should submit a bug report for this.
Rudi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20180810/0fa4dd3e/attachment.html>
More information about the QGIS-Developer
mailing list