I have a dataset which represents a global grid with latitude and longitude and the length of each pixel along the x and y axis. These are simply lat/long CRS.
Like this
head(latlong)
x y x.leng y.leng value
80.221 50.854 72334 16027.8 0.1
80.000 50.214 32132 2404.4 0.2
79.779 50.214 72334 16027.8 0.6
79.664 50.854 77632 23841.8 0.5
79.572 51.548 80556 29873.3 0.3
79.491 52.270 82574 34953.4 0.2
Where x and y are the center of the cell and leng is the total length of the cell in the two directions.
Because I have to do area-based calculations like extracting the values of cells in a raster that overlap with polygons, I cannot convert to a regular-sized raster and I don't want to interpolate values. So the functions rasterize
and rasterXYZ
don't work for me.
I know rast
objects can have irregular-sized cells when they are projected but I am not sure how to set this up from the above data frame.
Should I consider creating a multi-polygon simple feature? What are my options?