Hot answers tagged

4

This did not work well, indeed, with terra 1.1-5; but it works with version 1.1-10. # the value of "now" as it changes over time; you may need to change it to run this now <- "hrrr.20210515" ff <- c("hrrr.t00z.wrfnatf00.grib2", "hrrr.t00z.wrfnatf00.grib2.idx") if (!all(file.exists(ff))) { url <- paste0(&...


4

Got the clue Use download.file(url, file_path, quiet = TRUE, mode = "wb") as on Windows, it seems to be needed e.g https://community.rstudio.com/t/download-file-issue-corrupted-file/60844/2 The required part is the mode = "wb" option Your issue is related to your OS. FYI, my R version is R scripting front-end version 3.6.3 (2020-02-29)) ...


3

Converting to SpatialPoints drops the raster attribute information, I believe you are looking for SpatialPointsDataFrame. The most likely reason for the discrepancy in size is that NA values are dropped when converted to points. You can avoid this by converting to something like a SpatialPixelsDataFrame, which is the sp raster class. Now, that said, you do ...


3

find here a full solution. First, let's check if EPSG:26910 is suitable for Africa: library(giscoR) library(sf) library(tidyverse) # Wrong projection - full world gisco_coastallines %>% st_transform(26910) %>% ggplot() + geom_sf() It doesn't look very nice. If we check the crs we see the wkt string: st_crs(26910) #> Coordinate Reference ...


3

two things: firstly the invalid subscript type 'S4' error is because sapply loops over elements of the list, not indexes, so inside your function x is one of the raster stacks, and so you are trying to subscript your list of stacks by a stack: new_crs_myrasterlist <- sapply(myrasterlist, function(x) spTransform(myrasterlist[[x]], CRSobj=utm18)) Instead, ...


2

Let's see. First make a 5x4 raster: > library(raster) Loading required package: sp > r = raster(matrix(1:20,5,4)) > r class : RasterLayer dimensions : 5, 4, 20 (nrow, ncol, ncell) resolution : 0.25, 0.2 (x, y) extent : 0, 1, 0, 1 (xmin, xmax, ymin, ymax) crs : NA source : memory names : layer values : 1, 20 (min, ...


2

Adding a buffer may not affect the result if the buffer is small, relative to the cell size of the raster. You provide no reproducible example, or information on the data your using such as show(raster) or head(points) making it very difficult to help you. Can you please edit your question and include some of that? You seem to be barking up the tree with ...


2

"constant" means if you split the feature up, that attribute is still correct for both parts. example: land use category. split a field in half, both halves are still fields. "identity" is for attributes for features which when split, aren't the same any more. They've lost their identity. example: the name attribute of a county. split it ...


2

I think you can do that like this: a <- list.files(pattern="\\.grd$") b <- lapply(a, stack) year <- substr(a, 1, 8) bands <- c("NDVI","NBR","Brightness","Greenness", "Wetness") fnames <- lapply(year, function(y) paste0(bands, "_", y, ".tif")) for(i in seq_along(b)...


1

Don't use readTIFF for reading GeoTIFF files. It will not read the spatial information and may mess up in other ways too: ghanaPop = readTIFF(ghanaPopLocation) #Get initial GEOTIFF loaded use raster from the raster package: > gpop = raster("./gha_ppp_2020.tif") and you get something with coordinates: > gpop class : RasterLayer ...


Only top voted, non community-wiki answers of a minimum length are eligible