I'm trying to create a raster using the following data frame (without NAs), with the latitude, longitude and values extracted from a HDF4 file generated by SeaDAS:
> dim(df)
[1] 10538622 3
> head(df)
x y z
1 -61.38239 -30.91730 -0.015534
2 -61.38239 -30.91730 -0.015534
3 -61.38239 -30.91730 -0.015534
4 -61.38239 -30.91730 -0.015534
5 -61.37815 -30.91839 -0.015534
6 -61.37815 -30.91839 -0.015534
but I get the following error:
> ras = rast(df, type = "xyz", crs = prj, digits = 6)
Error in matrix(NA, nrow = ncell(r), ncol = nlyr(r)) :
invalid 'nrow' value (too large or NA)
In addition: Warning message:
In matrix(NA, nrow = ncell(r), ncol = nlyr(r)) :
NAs introduced by coercion to integer range
I already tried to reduce the size of the data frame using a bounding box, but even with only 23530 points I still get same error. There are a few points very close to each other (hence the identical points 1, 2, 3 and 4 in the df) and the grid is probably not regular. What could be the issue here?
Thanks, Matheus
If the values are not on a regular grid, you should perhaps use rasterize
instead. I am guessing that a regular grid is detected but at an extremely high spatial resolution. The development version of terra
now should show a warning before the error.