Expand zonal_statistics supported geometry types#450
Conversation
davemfish
left a comment
There was a problem hiding this comment.
@megannissel this looks good to me.
As far as the tests, I think testing all the different geometry types is probably not necessary. It certainly doesn't hurt, and if it was useful to write the tests in order to convince ourselves that all the different types are treated the same way, then that's a good enough reason to write the tests. But our function here does not do anything different with the different types, so I think we're ultimately testing things like gdal.Rasterize more than we're testing pygeoprocessing.zonal_statistics. And in that sense, I don't think we need to test gdal.
|
|
||
| polygon_a = [ | ||
| (origin[0], origin[1]), | ||
| (origin[0], -pixel_size * n_pixels+origin[1]), |
There was a problem hiding this comment.
It's a really minor thing, but I think these would be more readable with spaces around the + operator. Especially since that operator is lower priority than the * which does have spaces. Alternatively, no spaces around * and spaces around + would also be more readable, I think.
|
Writing these tests and confirming that nothing unexpected happened did make me feel more confident that I wasn't overlooking anything. But completely agree that we don't really need to be testing gdal itself. |
davemfish
left a comment
There was a problem hiding this comment.
Thanks for the update, @megannissel . I forgot to suggest that we update HISTORY, but I think we should do that too.
Fixes #448
zonal_statisticspreviously only supportedwkbPolygonandwkbMultiPolygongeometries. However, it would be reasonable to support 3D and measured (multi)polygons as well, as the z coordinates shouldn't have an affect / should be ignored for the purposes of the zonal stats calculations.This change also brings
zonal_statisticsin line with InVEST validation of input vectors, where the model spec inputgeometry_typesmaps'POLYGON'and'MULTIPOLYGON'to several ogr types:Allowing for the same list of valid geometries will prevent InVEST models that calculate
zonal_statisticsfrom failing on vectors that would otherwise be valid InVEST inputs.