Questions tagged [r-raster]

raster is an R package for geographic data analysis and modeling.

Other resources

Related tags

1217 questions
5
votes
2 answers

R: over-write xy coordinates of raster layer

I have a raster with XY pixel coordinates which I want to convert to lat and long. class : RasterLayer dimensions : 1617, 1596, 2580732 (nrow, ncol, ncell) resolution : 1, 1 (x, y) extent : 0, 1596, 0, 1617 (xmin, xmax, ymin,…
G. Gip
  • 337
  • 1
  • 4
  • 10
5
votes
2 answers

Calculate line density within a buffer from a raster

Is there a way to calculate road density (km/km²) within a buffer around spatial lines? The roads are represented by pixels (1 pixel = 625 m²) in a raster. So I began to convert the road pixels into polylines by using the function rasterToContour…
Marine
  • 521
  • 1
  • 4
  • 23
5
votes
0 answers

Map accuracy assessment by moving window

I would like to make accuracy assessment using confusion matrix between classified Landsat image and reference dataset. Maps have the same resolution and extent. I would like to evaluate the agreement by pixel-by-pixel. In many studies I have found…
maycca
  • 3,848
  • 5
  • 36
  • 67
4
votes
2 answers

Terra R - Speed up aggregate() of raster data with custom function

I would like to use aggregate function from the terra R package to aggregate raster with a quantiles approach as aggregation function. Here below, I used the quantile function from R base to compute 50th percentile (i.e. the median) using a raster…
Adrien
  • 157
  • 8
4
votes
4 answers

Suddenly error 'Cannot create a RasterLayer object from this file.' in script that worked before

I have a script where I read a raster stored as .tif : f_treecover <- raster('Landcover_data/treecover_res_100_q.tif') The script used to run fine a few months ago, but now I get the following error message: Error in…
Lena
  • 311
  • 2
  • 10
4
votes
1 answer

How to convert RGB image to CIELAB using raster package in R?

I have read an RGB image using the following code library(raster) #Load an image logo <- stack(system.file("external/rlogo.grd", package="raster")) plot(logo) Now, I want to convert the RGB image to CIELAB image. How to do it using raster R…
UseR10085
  • 7,120
  • 3
  • 24
  • 54
4
votes
1 answer

stars package: how to define additional dimensions based on an attribute (filename)?

I have a set of raster files (in this case downloaded from http://www.paleoclim.org/) that I am reading into R using the stars package. library("tidyverse") library("fs") library("stars") data_path <- "./paleoclim" (data_files <-…
Joe Roe
  • 626
  • 3
  • 12
4
votes
1 answer

How to delete temporary files in parallel task in R

Is it possible to delete temporary files from within a parallelized R task? I rely on parallelization with doParallel and foreach in R to perform various calculations on small subsets of a huge raster file. This involves cropping a subset of the…
tAlbert
  • 41
  • 2
4
votes
2 answers

Since update of sp package i get a warning by calling a sp::CRS definition

Since update of sp package i get a warning i did not get before: 1: In showSRID(uprojargs, format = "PROJ", multiline = "NO") : Discarded ellps unknown in CRS definition: +proj=stere +lat_0=90 +lon_0=10 +k=0.93301270189 +x_0=0 +y_0=0 +R=6370040…
Andreas
  • 397
  • 4
  • 18
  • 37
4
votes
1 answer

fastest way to conduct arithmetic on large rasters

I have a large number of large rasters (global extent, 250 m resolution; around 1e10 floating point cells)-- the filenames are in a vector deltaX.files. I want to add each of these to another raster, filename X.tif. Since this operation could take…
dww
  • 30,425
  • 5
  • 68
  • 111
4
votes
1 answer

Order of dplyr summarize operations affects output

Noticed some curious behavior I can't figure out. Given the following dataset: "Well" "PlateID" "SourceFile" "Frequency" "SI" "Description" "341" "H10" 1 "94: DDG-00005, HVTN505 CC, Plate1_H10_H10_094.fcs" 24.5 9867 "PBS…
r3vdev
  • 315
  • 3
  • 10
4
votes
1 answer

Modifications of raster extent and resolution change the total sum of pixel values

I wish to change the resolution and extent of a raster. I have tried to combine in different ways extend, aggregate, resample but unsuccessfully… below is a code I wrote to get the right resolution and extent, but as a consequence, the total pixel…
Cecile
  • 527
  • 5
  • 22
4
votes
1 answer

How to plot GeoTIFF using tmap in R?

A simple plotRGB leads to the original image while plotting with tmap returns only a blue-shaded image. What am I doing wrong? original image blue-shaded image Code snippet: library(raster) library(tmap) library(rnaturalearth) ne_download(scale =…
shar0n
  • 41
  • 1
4
votes
1 answer

How to subset (classify ) raster based on another raster grid cells values?

How to reclassify (subset) a raster r1 ( of the same dimension and extent as r2) based on following conditions in r2 in the given example. Conditions: If the grid cells values of r2 are >0.5, retain corresponding value and adjacent 2 grids cells…
Lily Nature
  • 613
  • 7
  • 18
4
votes
1 answer

What's the most efficient way to use movingFun in large rasters time series?

I have to smooth a large time series and I'm using the movingFun function from the 'raster' package. I tested few options based on previous posts (see my options below). The first 2 work, but are very slow when using the real data (all MOD13Q1 time…
LuluPor
  • 165
  • 1
  • 11