Open Mukhtabdi opened 2 years ago
I achieved to create the grid, but when I try to plot the it onto the raster, I get this error below:
Code
> tm_shape(IA_cdl_15) +
+ tm_raster(title = "Land Use ") +
+ tm_shape(IA_grids) +
+ tm_polygons(alpha = 0) +
+ tm_layout(legend.outside = TRUE)
Error
Error: Unable to warp stars. You could try with raster.warp = FALSE (argument of tm_shape)
In addition: Warning message:
In fetch(.x, ..., downsample = downsample) :
with RasterIO defined, argument downsample is ignored
>
For creating grids, you can use the following code (the book has been updated to use this code).
IA_grids <-
tigris::counties(state = "IA", cb = TRUE) %>%
#--- create regularly-sized grids ---#
st_make_grid(n = c(50, 50)) %>%
#--- project to the CRS of the CDL data ---#
st_transform(terra::crs(IA_cdl_15))
I uploaded IA_cdl_15.tif in the replication data set folder (https://www.dropbox.com/sh/gkprbgp8sg5362f/AABLLEUjsGkelCK2aUxaUI72a?dl=0). Can you try the code for mapping using this file?
Thank you for your quick response.
Could not thought that the book is updated. By the way, I got the updated version of the book. Apart from that, I tried to produce the map using the tmap code of the updated version of the book:
+ tm_raster(title = "Land Use ") +
+ tm_shape(IA_grids) +
+ tm_polygons(alpha = 0) +
+ tm_layout(legend.outside = TRUE)
But, couldn't produce the map and the problem still persist:
stars_proxy object shown at 17795 by 11671 cells.
Error: cannot allocate vector of size 792.3 Mb
In addition: Warning message:
In fetch(.x, ..., downsample = downsample) :
with RasterIO defined, argument downsample is ignored
However, I can produce the map of the grid on the raster using plot()
function.
plot(IA_cdl_15)
plot(IA_grids, add = TRUE)
thank you again
Thanks, I will have a look.
Hi Dr Taro Mieno. I am enjoying the book, thanks for providing it for free.
I am practicing chapter 6.0, specifically 6.11:DATASET.
I have an error when creating a regularly-sized grids over Iowa state. I run the chunk of code below: `
--- create regularly-sized grids ---
--- project to the CRS of the CDL data ---
--- convert to sf from sfc ---
I downloaded Iowa state boundaries from another website and tried to create the grid, fortunately I achieved to the grid and when I tried to plot the grid onto the raster, another issue appeared (stars_proxy object shown at 17795 by 11671 cells).
Any suggestion on how to solve this problem, please?