Questions tagged [r-raster]

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

Other resources

Related tags

1217 questions
0
votes
1 answer

How to retrieve eigenvalues & eigenvectors from Raster PCA in R?

After conducting a PCA on a stack of rasters (similar to this & in the 2014 Raster Package documentation), I'd like to review my eigenvalues, eigenvectors, and loadings... Typical calls for princomp which return the scree plot, proportion of…
lorena
  • 25
  • 1
  • 5
0
votes
1 answer

How can I save multiple jpegs from raster data in R?

I have about 40 spatial rasters in the .tiff format in a folder. I'm trying to generate histograms from each of the rasters in R, and save each histogram as a jpeg in a separate folder. I wrote code to loop through each of the raster, create a…
small_world
  • 139
  • 5
  • 13
0
votes
1 answer

Convert Raster object into Shapefile

Basically, I have a spLines Object with a bunch of lines, and after I am rasterizing it - rast2 <- rasterize(spLines, rast, fun='count') - in order to get a grid frequency map. However, I'd like to convert and save that rast2 Object into a…
Thalles
  • 272
  • 3
  • 14
0
votes
1 answer

Crop a RasterLayer with a SpatialPolygonDataFrame

I have a raster grid I want to crop according to land borders of the world map provided by the data of the package 'maptools'. By doing some reasearch, I found that I have to use the crop() function and then the mask() function, but I get an error…
Remssssss
  • 89
  • 1
  • 9
0
votes
0 answers

R compare rasters of land use

I am using the raster package to display a textile that I have converted into an ASCII file. I have no problem displaying the map using ggplot2. The map I have contains a grid 506 * 608. Each grid cell has a value associated with it. This is the…
0
votes
1 answer

Relative computational burdens of the matrix and raster in R

I'm surprised to discover that a matrix I've created from a large raster allegedly takes up a stomping 35k times more memory than the parent. This code demonstrates: > # comparison with R's built-in volcano data > object.size(volcano) 42656 bytes >…
geotheory
  • 22,624
  • 29
  • 119
  • 196
0
votes
2 answers

How to produce NAs in reproducible data in r

library(raster) r <- raster(nrow=5, ncol=5) s <- stack( sapply(1:5, function(i) setValues(r, rnorm(ncell(r), i, 3)))) Will produce rasterstack that has values in every pixel. How could I produce a rasterstack that contain NA values?
Eddie
  • 783
  • 4
  • 12
  • 24
0
votes
1 answer

Raster package, substitute

I'm trying to reclassify a RasterLayer to turn all 0's to NA. I've tried: Reclassify: con1RC<-reclassify(con2, matrix(c(0, 0, NA)) ERROR: cannot allocate vector of size 160.1 Mb Subs: con1Sub<-subs(con2, df, by=1, which=2) ERROR: error in…
RichT
  • 304
  • 1
  • 3
  • 13
-1
votes
2 answers

Reading in a subset of rasters based on filenames in a csv in R

I have around 4000 rasters (tif) all in a single folder. Each tif shows the distribution of a species. The filename of the tif is the species name. I want to make species richness maps from subsets of the species in the folder. I have a csv file…
JoeG
  • 1
  • 1
-1
votes
3 answers

How can I automize raster processing in R

I have 90 rasters that I need to clip and ressample to match my template raster. Is there a way for me to "automize this"? (i.e., only have to run the process once, so that I can, for instance, leave it running overnight) I know that the answer is…
Spectron
  • 11
  • 1
-1
votes
1 answer

How to create a raster from zonal statistics (i.e. r::zonal) output?

library(raster) library(fasterize) library(sf) #Template raster roadtif <- 'roads.tif' cropExtent <- extent(ras2) ##Zonal Raster ws <- sf::st_read(dsn = "tv_inputs.gdb", layer = "assessment_watersheds_diss") wsraster <-…
iaianmcd
  • 117
  • 1
  • 4
  • 13
-1
votes
1 answer

Plotting lat/long coordinates into a Formal Class Raster Layer (factor) map with aea projection in R?

I am quite new to working with spatial dataframes, and have what I thought was a relatively simple task: take a dataframe of 6 points, with x and y columns representing the lat/long positions of those points, and project them so that they can be…
Cameron
  • 164
  • 14
-1
votes
1 answer

How can I plot and overlay density plot of several rasters?

I have several rasters (effectively resulted calculated from digital elevation models) (created using the raster package) and I would like to compare the distribution of the values. One possible way is to plot a density plot and overlay them on a…
user1778351
  • 143
  • 7
-1
votes
1 answer

The extent in UTM and the projection in lat lon

I have a raster with 4 layers and I want to convert the extent into lon/lat, in order to make the extract, but the points and the raster projection or extent doesn't match. Can you please help me ? pp.an class : RasterBrick dimensions :…
Alex.V
  • 45
  • 8
-1
votes
1 answer

Extraction of data from multiple netcdf files at five coordinates files and writing them to five separate csv files

I have 365 .nc files located in a folder containing daily soil moisture information. I want to extract data at five-coordinate locations for the whole year and write them into five separate csv files. My code is attached below. However, I am getting…