Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
10 votes
1 answer
3k views

Limiting memory that raster package uses in R?

What's the easiest way to limit the memory the raster package uses in R to 5GB of RAM? Ideally I want any raster that exceeds this size to be written to the hard drive and analysed from a temporary ...
JPD's user avatar
  • 1,678
10 votes
1 answer
11k views

How to assign colors to specific raster values using R

I am using the levelplot function of the awesome rasterVis package to create a map whose values diverge around zero. I am plotting a raster file using a red to blue palette, but I am trying to assign ...
thiagoveloso's user avatar
10 votes
2 answers
5k views

How to rasterize SpatialPolygons in R?

I'm trying to extract the bathymetry values of my area of interest from a world bathymetry raster layer using the 'rasterize' function in the {sp} package. *Edits: I found the 'extract' function which ...
GodinA's user avatar
  • 489
9 votes
3 answers
6k views

How parallelize the extract function for raster files in R?

I´m trying to parallelize a simple "extract" operation like this: UseCores<-detectCores() -1 cl<- makeCluster(UseCores) registerDoParallel(cl) all.test.poly_period.test<-extract(stack.ts, ...
Bindini's user avatar
  • 419
9 votes
3 answers
7k views

Efficiently reading and reclassifying many rasters in R?

I've been tasked to create a suitability analysis of wave conditions in the Gulf of Mexico. I have 2 thousand or so raster files that are about 8 MB each (2438 columns, 1749 rows, 1km cell size). ...
Nigel's user avatar
  • 91
9 votes
3 answers
7k views

Per-pixel (statistical) calculations on a raster stack using GDAL

In R, it's relatively trivial to perform per pixel calculations based on a raster stack (e.g., get std.dev for each pixel on a 12 layer GeoTIFF). Unfortunately, the speed is less than desirable when ...
Prophet60091's user avatar
9 votes
2 answers
6k views

Re-projecting raster in R: gives warning that projected point(s) not finite?

1. Question I have encountered a warning using the projectRaster() function in the raster package in R. A full reproducible example is pasted below. Warning message: In rgdal::rawTransform(...
mike's user avatar
  • 143
9 votes
4 answers
9k views

Getting count of non-NA raster cells within polygon using R

I've been running into all sorts of issues using ArcGIS ZonalStats and thought R could be a great way. I'm fairly new to R but I have a coding background. The situation is that I have several rasters ...
Hubert's user avatar
  • 257
9 votes
3 answers
6k views

Using sampleRandom() from large raster without NA values in R?

I have a number of vary large rasters which need to be randomly sampled with the return value being a matrix of x, y, and value. The raster package sampleRandom(raster,n, na.rm=TRUE, xy=TRUE) will do ...
Mr.ecos's user avatar
  • 471
9 votes
2 answers
2k views

How to create a solar intensity map for a garden plot?

I'm interested in creating a raster surface that depicts the average solar intensity per unit area for a small garden plot. I imagine the inputs into the model would be the following: Plot area--for ...
Aaron's user avatar
  • 51.8k
9 votes
1 answer
3k views

Understanding the values from transition layers produced by the R package `gdistance`

Background and Aim I would like to create a cumulative raster representing walking time across a surface. For my purposes, the cost to be accumulated has to be the walking time as influenced by ...
NewAtGis's user avatar
  • 1,546
9 votes
1 answer
10k views

Spearman correlation between two rasters in R [closed]

I have two rasters of the same area. The only difference is that they were created using two different methods. I would like to compare them and see how correlated they are pixel by pixel. Any ideas ...
Jaber Belkhiria's user avatar
9 votes
1 answer
592 views

Packing squares polygons in a raster grid

In the green area of the raster I have to fit as many square polygons as possible, of three different sizes: 3x3 cell size 2x2 cell size 1x1 cell size With the fact that the approach should be ...
Dragana's user avatar
  • 91
9 votes
1 answer
3k views

Crop raster based on another raster R

library(raster) How can one clip one raster based on another raster? RasA: class : RasterLayer dimensions : 459, 533, 244647 (nrow, ncol, ncell) resolution : 10000, 10000 (x, y) extent ...
code123's user avatar
  • 345
8 votes
3 answers
20k views

Remove NA from Raster Layer

I have a RasterLayer and a SpatialPolygonDataFrame. I used the mask function to create a new RasterLayer. The output is correct but it does include lot's of NA values. Now I want to get rid of ...
obrob's user avatar
  • 887
8 votes
3 answers
21k views

Function (sample code) to extract raster value per polygon in R

I have a raster image (Sentinel-2 band 4) and a shapefile covering the same area than the image (same projection and extension). The shapefile has different polygons which are agricultural fields. I ...
GCGM's user avatar
  • 1,138
8 votes
2 answers
4k views

Sum rasters with different extent in R

I need to sum several rasters (.tiff) with different extent but the same resolution in R. How can I do it?
Joan Gimenez's user avatar
8 votes
1 answer
12k views

Plotting map resulted from kriging in R

I want to plot a map weighted by prices. I got a data frame of latitudes, longitudes and prices: > str(data) 'data.frame': 1253 obs. of 3 variables: $ lon : num 11.2 11.1 11 11 11.3 ... $ ...
Benedict Ernst's user avatar
8 votes
3 answers
14k views

Stack rasters with different origin, dimensions and resolution in R

I have three raster files with the same extent and CRS, but with different origin, dimensions and resolution. r1 class : RasterLayer dimensions : 3020, 3043, 9189860 (nrow, ncol, ncell) ...
Elena's user avatar
  • 83
8 votes
2 answers
19k views

How are kappa and overall accuracy related with respect to thematic raster data?

I recently calculated kappa (using confusionMatrix{caret} in R) between a thematic raster dataset at 1m spatial resolution and another at 30m spatial resolution. I was interested in quantifying the ...
Aaron's user avatar
  • 51.8k
8 votes
1 answer
12k views

Saving (converting) raster objects in R?

I want to save my raster plot that produced with R to ArcGIS raster (.img, .tif and ASCII) file.
user19516's user avatar
8 votes
5 answers
10k views

In R, set NA cells in one raster where another raster has values

I have two rasters in R. I want to set values to NA in the first raster where the second raster has values. I think this should be simple, using the raster package, with two RasterLayer objects ...
Amadou Kone's user avatar
8 votes
1 answer
14k views

Plotting a raster stack with ggplot2

My aim is to plot a rasterstack as a single image using ggplot2. First, I apply ggplot on a single layer raster using the following code: #Load packages library(raster) library(ggplot2) #Create a ...
SA Khan's user avatar
  • 307
8 votes
2 answers
5k views

Change a raster from longitude display (-180, 180) to (0, 360)

Using R software, I want to modify the attached raster in order to visualize it centered on the Pacific Ocean. Indeed, I need to show the entire Oceania: in my opinion I have to shift from (-180,180) ...
Marco's user avatar
  • 365
8 votes
3 answers
7k views

Open JPEG2000 (Sentinel 2) in R

Is there any way I can open Sentinel 2 JPEG2000 file (.jp2) using R? Or more specifically with the {raster} package in R? I keep getting the Error message that .jp2 is: not recognised as a ...
maRtin's user avatar
  • 213
8 votes
2 answers
5k views

How to calculate distance on large raster in R?

I'm trying to do some raster algebra and one of my layers is a distance from a coastline layer. I'm using rasters with 12.5m resolution and when I use the distance function, I seem to run into memory ...
alaybourn's user avatar
  • 440
8 votes
1 answer
5k views

R raster Package Moran's I interpretation

I am using raster package to calculate the local Moran's I . The example gives the range of Moran's I between - 1 to 2.47. On my own data I have see the value range -3.070423 - 7.228558 How can Moran'...
Arihant's user avatar
  • 330
8 votes
1 answer
3k views

How do I get rid of edge effects while using focal in R to smooth a raster?

I am trying to use R with the focal function from the raster package to smooth raster images. I am working with Radar images that have already been preprocessed. As part of that, some calculations ...
weis_fn's user avatar
  • 83
8 votes
2 answers
7k views

Filling NA gaps in raster with R?

I have soil data rasters from SoilGrids.org that have some small holes with NA cells (White spaces in the image) that I want to fill using some interpolation method to get a more spatially continuous ...
Guido A. Herrera's user avatar
8 votes
3 answers
6k views

R raster predict using lm() time series

I try to make a prediction in raster using linear regression based on past rasters but I can not capture the lm() model in order to feed it to predict(). # # calculate regression in a raster stack (...
jim's user avatar
  • 191
8 votes
1 answer
2k views

How do I tile raster input to speed up display in R Shiny programs?

Disclaimer: I have very little GIS experience I've been working on a project in R that involves displaying large raster maps in an R Shiny interface. I am using the leaflet package for display. The ...
zach's user avatar
  • 183
8 votes
1 answer
1k views

Warning message using writeRaster() - not updated for proj >= 6

Using the code below to write a raster to disk: library('raster') r <- raster(nrow = 5856, ncol = 9141) r[] <- 1:ncell(r) writeRaster(r, tempfile(fileext = ".tif"), ...
Corbjn's user avatar
  • 359
8 votes
1 answer
5k views

Setting CRS of raster to EPSG 3035 using R

I am trying to set the CRS of a raster file with the following code: library(raster) r<-raster(xmn=0,xmx=10,ymn=0,ymx=10) crs(r)<-CRS("+init=epsg:3035") The warning message is: ...
Funkwecker's user avatar
8 votes
1 answer
4k views

Clipping raster brick object in R

I have MODIS NDVI TIFF files for a year I want to first clip it with a irregular polygon (not by its extent only) of my study area and save it as a multi band raster in TIFF format The TIFF image are ...
Bhoj Raj's user avatar
8 votes
0 answers
1k views

Cellular Automata Markov for forecast LULC in R software

I would like to forecast land use changes by implementing the Cellular Automata (CA) Markov Chain models in R software. I have the classified LULC maps from 3 times periods (1992,2003,2014), and also ...
Nery's user avatar
  • 99
7 votes
3 answers
1k views

Find maximum extent out of list of shapefiles (in projected coordinate system) in R

I have a script where I crop a list of rasters by the extent of one of many shapefiles. So far all of by shapefiles have been such that I could manually select the one with the largest extent (i.e. ...
ENIAC-6's user avatar
  • 916
7 votes
2 answers
5k views

Transforming geostationary satellite image to lon/lat

The ICARE Data and Services Center distributes the SEV_AERUS-AEROSOL-D3 product in HDF5 format (http://www.icare.univ-lille1.fr/archive/?dir=GEO/MSG+0000/SEV_AERUS-AEROSOL-D3.v1.03/). The main ...
Michael Dorman's user avatar
7 votes
2 answers
4k views

Creating a raster of the residuals of a regression between two rasters

I am trying to create a raster of the residuals of a regression between two rasters. i.e. I would like to carry out a regression of one raster against another of the same extent and plot the residual ...
M Hudson's user avatar
7 votes
1 answer
999 views

To project, or not to project? Extracting raster values with R

I have a raster from which I need to extract values at point locations using raster::extract(raster_stack, points_sf). The raster is at 30 arc-second resolution and came from WorldClim with ...
Gregory's user avatar
  • 1,671
7 votes
2 answers
21k views

Save WMS layer to TIFF raster

In QGIS, I have a WMS layer. I am saving it to my hard drive by right click > "Save As...". Just like in HDunn's answer here. This is about my understanding of the topic, already this code is strange ...
Contemplavit's user avatar
7 votes
2 answers
5k views

Generating random points inside raster boundary using R?

I have a projected raster shown in the image below (left). I want to generate random points inside the raster like the middle image. However, the result I am getting is the same as the image on the ...
GISnew's user avatar
  • 359
7 votes
2 answers
11k views

How to write every raster from a list of rasters?

I have created a list of rasters - "norm" and run a several loops. Now I would like to write every created raster from "norm" (containing 1 layer) into one raster, having its specific name. # I can ...
maycca's user avatar
  • 3,386
7 votes
1 answer
9k views

Adding title beside raster spplot legend

After studying for a while how to create a chart from a raster object, I got almost everything I needed except to add a title to spplot's legend. What I tried: To use mtext("XXX (m)", side=...
Andre Silva's user avatar
  • 10.3k
7 votes
5 answers
13k views

Reproduce raster with same extent, and same number of columns and rows?

I have two raster A and B. A and B have the same grid size but different extent. How can I make A have the same number of columns and rows, as well as the spatial extent of B?
Seen's user avatar
  • 2,215
7 votes
4 answers
7k views

R Raster package: write NetCDF with time dimension

I am writing a rasterbrick with multiple layers to a netcdf file using the raster package in R: writeRaster(gridfile, "Data", "CDF", overwrite=TRUE, varname="Data",varunit="mm.d-1",longname="...
Dom's user avatar
  • 71
7 votes
2 answers
2k views

Calculating block statistics from land cover raster using R?

I have a raster (5 x 5 m resolution) representing land cover. Each cell contains a integer value (from 1 to 10) representing a total of ten land cover classes (e.g. 1-forest; 2-agricultural areas; 3-...
André Lourenço's user avatar
7 votes
1 answer
6k views

Importing raster with R from File Geodatabase?

How can I import a raster file from a gdb into R? Name of raster file: Cont_maturite in gdb : CAROPER_04151.gdb In wd: c:\test\caroper
dthib65's user avatar
  • 71
7 votes
1 answer
8k views

Using a fixed palette range to plot an NDVI raster in R

I would like to plot an NDVI raster with rasterVis packages using the normalized colors from red to green. I don't understand how fix the color scale from 0 to 1 even if my raster value are between 0....
delaye's user avatar
  • 729
7 votes
3 answers
3k views

Kriging with barriers in R?

I wonder if there is a way to interpolate xyz points in a raster within certain bounds using R? In ArcGIS this is called interpolation with barriers. I wonder if there is something similar in R? I ...
Camilo Mora's user avatar
7 votes
1 answer
740 views

Getting a raster into GRASS and back out again: `rgrass7` readRAST not preserving dimensions

I am trying to get a raster into GRASS from R and back out again using the rgrass7 package. Getting the raster in seems to be no problem. However, when I try to get it out with the readRAST function ...
jsta's user avatar
  • 1,370

1
2
3 4 5
36