Closed danielreispereira closed 4 years ago
Can you share the KML?
Sure thing. Attached. kmlExample_BastonGithub.kml.txt
Works with the raster I'm using. Can you share the extent and resolution of yours?
Hmm. I'm using the raster attached. CHIRPS rainfall from: https://data.chc.ucsb.edu/products/CHIRPS-2.0/global_daily/tifs/p05/.
class : RasterLayer
dimensions : 2000, 7200, 14400000 (nrow, ncol, ncell)
resolution : 0.05, 0.05 (x, y)
Here's what I'm running:
library(raster)
library(sf)
library(exactextractr)
prec <- raster('chirps-v2.0.2020.02.29.tif')
poly <- st_read('test.kml')
cf <- coverage_fraction(prec, poly, crop=TRUE)[[1]]
plot(cf)
plot(st_geometry(poly), add=TRUE)
Interesting. I keep getting the same error:
Pkg version, windows dependencies maybe?
Interesting. I assume you have the latest exactextractr and sf from CRAN. I'll try to reproduce on a Windows machine.
I suspect this is somehow related to the third dimension, in which case a workaround would be coverage_fraction(prec, st_zm(poly), crop=TRUE)
.
That does the trick. What should have I noticed that I missed in this case? KMLs with 3 dimensions ?
I don't think you missed anything. Ideally the Z dimension would just be ignored, and I'm not sure why this appears to happen on one platform but not another. I'll keep this issue open until I have time to look into it.
Thanks for the fix
I'm getting the following error when trying to get the coverage fraction from a .kml that has multiple holes in it (multipolygon?). Same code works fine if the kml is simple (no holes in the middle).
Since I have no idea what the error means: what should I try first? Redraw the KML ?