hunzikp / velox

https://hunzikp.github.io/velox/
119 stars 23 forks source link

Add argument df=TRUE to extract #14

Closed MatthieuStigler closed 6 years ago

MatthieuStigler commented 6 years ago

Adding an argument df=TRUE to extract, both for raw data and aggregated (using fun) one. Output is similar to that of raster::extract. Differences include:

  1. With non-overlapping polygons (i.e. polygons whose center does not fall into a cell), raster::extract uses cells around, if small=TRUE. So comparison with raster should be made with small=FALSE

  2. Column name: I named the polygons ID_sp, while raster has ID. I remember being confused when using raster which was the raster and the polygon ID, so something more explicit like ID_sp seems clearer. But for consistency reason, you might well choose to use the same.

  3. Content of the ID_sp column: here returns the polygon ID, not number. In the test, ID is number so don't see the difference, but in other cases difference would show up. Not sure how much this polygon ID is general to shp files, or specific to the sp implementation? I think for example in sf this is not the case anymore?

Please check also what I added in help file, might surely be improved.