-
Notifications
You must be signed in to change notification settings - Fork 5
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
Subpixel overlap in AggregateRaster #64
Comments
Note that all pixels with center inside polygon or those on the line render path are taken into account. The test in #63 also fails because the polygon stays within a single pixel (so no line algorithm). The line algorithm makes the rasterization less accurate even for larger polygons, because it causes more pixels to be taken into account then without it. Nevertheless, the this issue stands. https://pythonhosted.org/rasterstats/ seems to follow (or use) the same two options that GDAL offers. I understand that QGIS has/had a hybrid method switching to and exact calculation when the amount of pixels aggregated falls below some threshold. Or use all_touched=true (to get rid of the line algorithm) and do multiple runs with different shifts (is that what you mean with the half-pixel shift, @caspervdw ? I've thought in that direction, too, but couldn't get my head around it yet. I think it makes things too complicated anyway. |
This discussion is BTW related to #43, there a reference is made to https://github.com/isciences/exactextract. I think that taking into account partial pixels is overkill for us. "just" doing all_touched=true might be enough. This would overestimate |
Closing as it is a duplicate of nens/lizard-nxt#5262 |
Possibly related to #43
@wietzesuijker Raised this issue originally. If a polygon is smaller (or comparable) to the size of a single raster cell (pixel), then in some cases the polygon gets
NaN
for the aggregation result. A test confirming this behaviour is in #63The issue here is that GDAL's Rasterize only takes into account pixels whose center are inside the polygon. In other words, if a polygon does not contain any pixel centers, there is nothing to aggregate.
What do we want to do in dask-geomodeling? One way to tackle this is adding
ALLTOUCHED=TRUE
to the options, but that might not be good in all cases. (see https://gdal.org/python/osgeo.gdal-module.html#RasterizeOptions)Also, I have the feeling that we might be introducing a half-pixel shift here? @arjanverkerk
Note that this also has consequences for the
bucketize
algorithm.The text was updated successfully, but these errors were encountered: