Questions tagged [raster]

A rectangular array of pixels. A Raster defines values for pixels occupying a particular rectangular area of the plane, not necessarily including (0, 0).

A rectangular array of pixels. A Raster defines values for pixels occupying a particular rectangular area of the plane, not necessarily including (0, 0).

3658 questions
9
votes
1 answer

How to create a raster brick with rasters of different extents?

I am new in R so this question is very basic but I have been struggling with it and could not find a solution that worked. I want to create a raster brick from some landsat images of the same area. They were downloaded in HDF-EOS format, and I used…
user3127517
  • 147
  • 1
  • 2
  • 8
9
votes
5 answers

R Crop no-data of a raster

I would like to crop the no-data part of some rasters (example of the image in 1 where no-data is in black) without defining the extent manually. Any idea?
Wraf
  • 747
  • 2
  • 10
  • 24
9
votes
1 answer

Controlling legend and colors for raster values in R?

I'm trying to plot an ESRI Grid as a raster image of a surface. I've figured out how to make the plot, but not how to control R's color scale. # open necessary libraries library("raster") library("rgdal") library("ncdf") # goal: select an ESRI Grid…
Sam Zipper
  • 642
  • 1
  • 7
  • 19
9
votes
1 answer

Shapefile to raster conversion in R?

I have a shapefile downloaded from the worldwildlife.org for the terrestrial ecoregions of the world. The file can be loaded here: http://worldwildlife.org/publications/terrestrial-ecoregions-of-the-world. It comes as a standard shape file and I…
I Del Toro
  • 913
  • 4
  • 15
  • 36
8
votes
3 answers

How to improve a spatial raster map using ggplot when compared to spplot?

How can I improve the legend of spatial raster map plot using ggplot when compared to a spplot() legend? I would like plot spatial maps using ggplot() instead of ssplot() however there are a few things that I would like to improve when compared to…
Janvb
  • 1,290
  • 2
  • 16
  • 17
8
votes
1 answer

Understanding raster::extract and terra:extract

I'm having issues fully understanding terra:extract. I wish to extract average raster values for administrative GADM polygons. My raster has one single value per country. I would expect that each administrative polygon within a particular country…
Cecile
  • 527
  • 5
  • 22
8
votes
1 answer

Make raster stack with different extent

I am in trouble making raster stack which have slightly different extent. The answer (1st one) given here is useful but did not help in my case. For example, I want to make a raster stack using bio2 raster for Australia and this Australian raster.…
Tiny_hopper
  • 380
  • 1
  • 4
  • 15
8
votes
4 answers

how to efficiently import multiple raster (.tif) files into R

I am an R novice, especially when it comes to spatial data. I am trying to find a way to efficiently import multiple (~600) single-band raster (.tif) files into R, all stored in the same folder. Not sure if this matters but note that, when viewed in…
Dorothy
  • 523
  • 1
  • 5
  • 17
8
votes
3 answers

Cropping a raster file using GDAL w/ Python

EDIT: PARTIAL SOLUTION Using gdal_translate in the command line seems to do the trick, even though the Python binding doesn't work. This worked to crop a GeoTiff removing 300 pixel padding from top and left and keeping the next 2000x2000 pixels.…
PAL
  • 81
  • 1
  • 1
  • 4
8
votes
4 answers

Raster path following algorithms

I've got a raster grid of values that looks something like the image below (white is high values, the black background value is zero). I'm trying to write some kind of path-following code to start at the end of one of the lines and trace to the…
robintw
  • 27,571
  • 51
  • 138
  • 205
8
votes
1 answer

Change raster values using spatial polygons

To change raster values under SpatialPoints you can simply use [ . r <- raster(system.file("external/test.grd", package="raster")) rTp <- rasterToPoints(r, spatial = T) set.seed(666) rTpS <- rTp[sample(1:length(rTp), 500),] plot(r) plot(rTpS, add…
loki
  • 9,816
  • 7
  • 56
  • 82
8
votes
4 answers

A faster function to lower the resolution of a raster R

I am using the raster package to lower the resolution of big rasters, using the function aggregate like this require(raster) x <- matrix(rpois(1000000, 2),1000) a <-raster(x) plot(a) agg.fun <- function(x,...) if(sum(x)==0){ …
Leosar
  • 2,010
  • 4
  • 21
  • 32
8
votes
2 answers

raster and ggplot map not quite lining up in R

I am trying to plot a spatial raster using ggplot2. require(raster) require(ggplot2) Download data, load as a raster using the raster package. More details about this data product can be found here. Then convert the raster to points so it plays…
colin
  • 2,606
  • 4
  • 27
  • 57
8
votes
2 answers

Parallel processing of big rasters in R (windows)

I'm using the doSNOW package and more specifically the parLapply function to perform reclassification (and subsequently other operations) on a list of big raster datasets (OS: Windows x64). The code looks a little like this minimalistic…
Val
  • 6,585
  • 5
  • 22
  • 52
8
votes
1 answer

Relassify continuous raster data into binned classes with discrete colors

I would like to: Reclassify the raster ras into nine classes using reclassify Provide a colorkey with values written beside each colour (see sample plot below). The colorkey should not be split, as in the sample plot, but rather shown as a single…
code123
  • 2,082
  • 4
  • 30
  • 53