I am dealing with a spatial dataset that I need to divide into a training and a validation subset.
To be specific, I have a raster with 31 bands; I need to use all of them as parameters for the division of the dataset into the two subsets. I wish to…
I am trying to plot a raster over New Zealand in leaflet but I am having some issues. I've found that polygons and points/markers plot as expected:
library(raster)
library(leaflet)
library(dplyr)
library(sp)
p1 <-…
I'm using R for a climate research study and I'm trying to draw a map with a digital elevation model as base layer. I want to plot another (smaller) raster (containing climate information) on top of this dem, obviously with different colors. The…
I have two environmental rasters for the same extent etc, and dataframe of model results (which contains all possible combinations of env1 and env2). I am trying to create a third raster filled with model results for each cell.
library(raster)
##…
I have a raster image (.tif) with continuous values in each pixel between 0 and 1.
I want to calculate the area (can be a number of pixels too) in this raster which has values in a set of value intervals: i.e. 0.1 - 0.2, 0.3 - 0.4, 0.7 - 0.8.
The…
I have two problems.
Problem 1:
I would like to delete all cells of the grid whose centroid is not located over the raster. I'm not even sure if I'm working with the right "types of objects" (RasterLayer, SpatialPixels, etc.).
See example with…
I need to compute number of three consecutive days when value of each pixel in a raster stack (x) is above a given threshold (defined by another raster y). I tried using rle for the purpose with calc as follows after stacking x and y together into…
I would like to display a set of points over a raster layer, and have them colored on the same scale as the raster. I've looked through other questions but have not solved it. The point values represent concentrations at 30 stations. The raster…
I have many NCDF files in a folder. I try to extract them into raster brick using raster and ncdf4 packages. If I separately extract each NCDF file it works. However, I try to extract all files using for loop then it gives me…
I am trying to load multiple rasters (87 in total) into R for analysis. The rasters are being loaded direct to a stack using this code:
filelist <- list.files(path="mypath", pattern="tif$", full.names=TRUE)
stk1 <- raster::stack(filelist)
The data…
I am trying to make a figure that has a boxplot for 14 different rasters. Each raster represents the snow depth surface for a given 100m elevation band, from 1300-2600 masl. I know how to make a boxplot for each raster individually, but cannot…
I have 14 raster files in Tiff format and I want to read values of a series of pixels (same file location). However, when I ran the R code, the expected results did not show up. Could you tell me why?
#set working directory#
path <-…
I am trying to run a multivariate regression with different layers in a RasterStack using focal {raster} or localFun {raster}. With the help of a similar post and the raster reference manual, my code works fine with single RasterLayers as input (see…
I have a raster image that I try to plot using rasterVis package in BuRdTheme. But I find the colors to be dull.
However, what I need is something like following. How can I create this desired pallete in raster or rasterVis or if any other package…