Questions tagged [r-raster]

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

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

It accomplishes reading, writing, manipulating, analyzing and modeling of gridded spatial data. The package implements basic and high-level functions and processing of very large files is supported.

Other resources

Related tags

946 questions
52
votes
1 answer

How to make R's 'raster' package distinguish between positive and negative rotation matrices in GeoTIFFs?

It appears that the raster package in R doesn't distinguish between positive and negative rotations of GeoTIFFs. I have a feeling that it is because R is ignoring the negative signs in the rotation matrix. I'm not quite savvy enough to dig down…
Tedward
  • 1,512
  • 13
  • 18
22
votes
2 answers

Interactive plotting with R raster: values on mouseover

I'd like to do a small program in R for interactive visualization and modification of some raster datasets, seen as colored images. The user should open a file (from the terminal it's OK), plot it, select the points to edit with mouse clicks, and…
AF7
  • 2,561
  • 20
  • 51
18
votes
2 answers

R: Handling of sf objects in raster package

Previously I was using raster::crop and raster::mask with shapefiles of class Spatial*, read in using rgal::readOGR. I am just "upgrading" my scripts to use sf for reading and manipulating polygons. raster::crop raster::crop expects an 'extent'…
pat-s
  • 4,656
  • 1
  • 27
  • 49
17
votes
2 answers

R - convert SpatialLines into raster

In R, we can take a raster and turn it into a SpatialLinesDataFrame with the function rasterToCountour: library(raster) f <- system.file("external/test.grd", package="raster") r <- raster(f) x <- rasterToContour(r) class(x) [1]…
Rich Pauloo
  • 5,424
  • 3
  • 22
  • 50
12
votes
1 answer

How to extrapolate a raster using in R

I am trying to downscale climatic conditions using the methodology in this article using the R software. I am almost there, but I am missing a couple of steps Packages and data needed For this example I uploaded some data to the archive.org website…
Derek Corcoran
  • 3,358
  • 1
  • 19
  • 37
11
votes
2 answers

image raster R package - raster printing without background and border and legend

I am using raster function as shown on lines below. My last line produces some output. That output has a line that says dimensions : 240, 320, 76800 (nrow, ncol, ncell). I would like reprint that image but say only first 200 rows and first 300…
user2543622
  • 4,682
  • 20
  • 62
  • 117
9
votes
4 answers

R: Detect a "main" Path and remove or filter the GPS trace maybe using a kernel?

Is there a way to filter out those parts which don't belong to the main path? As you can see in the picture i would like to remove the crossed out part while keeping the main path. I already tried using zoo/rolling median but without success. I…
Andreas
  • 417
  • 3
  • 16
  • 32
9
votes
2 answers

Sum nlayers of a rasterStack in R

I am working with daily observation of climate data organized in .nc files. I read them using the stack command of the raster package. Each file (corresponding to a year) is a RasterStack element with the following characteristics: class :…
Nemesi
  • 634
  • 10
  • 24
9
votes
3 answers

If raster value NA search and extract the nearest non-NA pixel

On extracting values of a raster to points I find that I have several NA's, and rather than use a buffer and fun arguments of extract function, instead I'd like to extract the nearest non-NA Pixel to a point that overlaps NA. I am using the basic…
Joe
  • 307
  • 3
  • 17
8
votes
1 answer

calculate and plot vector field of an arbitrary rasterLayer

Problem statement: With ggquiver::geom_quiver() we can plot vector fields, provided we know x, y, xend, and yend. How can I calculate these parameters for an arbitrary RasterLayer of elevations? How can I ensure that the size of these arrows…
Rich Pauloo
  • 5,424
  • 3
  • 22
  • 50
8
votes
1 answer

Is there a way in R to plot a legend with two axes?

I would like to plot a legend with two axes. Specifically, I have combined two spatial objects that have been classified, the first showing intensity of an event and the second showing the probability of the event at that location. I want to create…
dee_2_dee
  • 81
  • 1
8
votes
2 answers

time and geographical subset of netcdf raster stack or raster brick using R

For the following netcdf file with daily global sea surface temperatures for 2016, I'm trying to (i) subset temporally, (ii) subset geographically, (iii) then take long-term means for each pixel and create a basic plot. Link to file:…
Peter Houk
  • 97
  • 1
  • 5
8
votes
0 answers

coord_map() combined with geom_tile() is very slow

I'm plotting some hemispheric fields with ggplot2 and when I try to project them into a stereographic projection it takes ages to render. This is a minimal example: lat <- seq(-87.159, -2, by = 3.7) lon <- seq(0, 360, by = 3.75) month <- 1:12 gdata…
Elio Campitelli
  • 1,158
  • 7
  • 16
8
votes
1 answer

"Globe"-shaped map of Russia

I draw a map of regions of Russia using GADM data: setwd("~/Desktop/Master thesis/") library(sp) library(RColorBrewer) library(raster) data <- getData('GADM', country='RUS', level=1) #exclude columns I don't need data <-…
MariaBee
  • 83
  • 3
8
votes
1 answer

Identify position of a click on a raster in leaflet, in R

I am plotting a large lat-lon NetCDF raster over an R leaflet map using shinydashboard. When I click on the map, a popup comes out and shows row, column, lat-lon position and value of the clicked raster point. (See reproducible code below) The…
AF7
  • 2,561
  • 20
  • 51
1
2 3
63 64