Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add N to reported stats #2

Open
aloboa opened this issue Apr 17, 2018 · 7 comments
Open

Add N to reported stats #2

aloboa opened this issue Apr 17, 2018 · 7 comments
Assignees
Labels
enhancement New feature or request

Comments

@aloboa
Copy link

aloboa commented Apr 17, 2018

Could you add the nb of pixels to the reported stats? Also, if possible,
as you are reporting the median, could you add the mad (median absolute deviation),
https://en.wikipedia.org/wiki/Median_absolute_deviation
which is the robust estimator of the standard deviation (median,mad are the robust versions
of mean, std. dev).

@pedrocamargo pedrocamargo self-assigned this Apr 17, 2018
@pedrocamargo
Copy link
Owner

Will look into adding these statistics. Update to probably come for QGIS 3 only.

@pedrocamargo pedrocamargo added the enhancement New feature or request label Apr 19, 2018
pedrocamargo added a commit that referenced this issue Apr 19, 2018
pedrocamargo added a commit that referenced this issue Apr 19, 2018
@pedrocamargo
Copy link
Owner

@aloboa The features have been included, and I have uploaded the new version to the QGIS repository. Just wait for them to approve now.
Version for QGIS 3 will come at some point

@aloboa
Copy link
Author

aloboa commented Apr 20, 2018 via email

@aloboa
Copy link
Author

aloboa commented Apr 24, 2018

I think that results are wrong. I suspected because I was getting median and mad values that were always integer, which is unlikely even if dealing with integer input data.
Then I made an small data test:
(see R code for generating the test raster at the end)
test raster https://www.dropbox.com/s/nilutodduzd0gzn/test.tif?dl=0
test polygons (drawn in qgis) https://www.dropbox.com/s/lpgswivazh22xsf/test.zip?dl=0
rasterstats output csv in https://www.dropbox.com/s/kskupclvvqjv6q2/test.csv?dl=0

Results do not correspond to what I get in R, but you can actually check that even the nb of pixels is wrong, you can count them directly on the image:
rasterStats indicates 10, 18 and 14 (for each polygon) while you can count 8, 12 and 12.
Also, "average" and "mean" are redundant.

You can check R method and results in this pdf
https://www.dropbox.com/s/jywn87kp5h3pk59/testRasterStats_log.pdf?dl=0
Agus

@pedrocamargo
Copy link
Owner

Hey Agus,

Mean and average were indeed redundant. On the count, however, things are right. If you zoom in enough, you will see that the the polygons touch the number of pixels it says they are touching, and that is how the statistics are computed.
I could look into computing the statistics in a way to consider, for each polygon, only pixels that have centroids falling inside such polygon, but that was not the approach taken until this point.

I don't have a view either way, as I built this plugin to support my brother's work and my own work with rasters considers polygons that are much bigger (as in 2 orders of magnitude) than the raster pixels, which dwarves these differences you are pointing to. What is your view on this? Any literature I should look into?

On the MAD computation I have actually made a mistake by not converting the numbers to floats, so there will be a next version with that fix (which also eliminates avg/mean redundancy).

@pedrocamargo pedrocamargo reopened this Apr 24, 2018
@aloboa
Copy link
Author

aloboa commented Apr 24, 2018 via email

@pedrocamargo
Copy link
Owner

pedrocamargo commented Apr 24, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants