27 questions
1
vote
1
answer
65
views
Scale colours in spatraster maps
I'm trying to plot multiple geographical maps in SpatRaster using terra, eg.:
> library(tidyterra)
> library(terra)
> library(ggplot2)
> str(edata)
S4 class 'SpatRaster' \[package "...
-4
votes
1
answer
122
views
I have a very long list of cities across many countries. How can I add geographical information such as municipality, state, region, etc.? [closed]
I have a column that contains the place of residence of participants. Some reported as "city/village, country", "postcode city, country", "region, country", etc. There ...
2
votes
1
answer
137
views
Robinson projection of two global raster data from two sources
I tried to access global elevation raster data from two sources:
Source 1 (Natural earth):
I downloaded raster data of world elevation from here: https://www.naturalearthdata.com/downloads/10m-raster-...
2
votes
2
answers
135
views
After projecting, world elevation raster is not visible in plot even though values exist
I downloaded raster data of world elevation from here: https://www.naturalearthdata.com/downloads/10m-raster-data/10m-cross-blend-hypso/ --> Cross Blended Hypso with Relief, Water, Drains, and ...
2
votes
1
answer
194
views
Customizing legend when plotting geom_spatraster and geom_spatvector in R
Using R, I am attempting to create a plot that contains both geom_spatraster and geom_spatvector objects, and I am running into issues with the legend. Using the repex at the bottom below, the legend ...
1
vote
2
answers
131
views
Misalignment of coordinate systems when using terra::as.data.frame instead of tidyterra::geom_spraster with ggplot2
When I was working on the visualisation of spatial data (vector and raster), I ran into some tricky issues: Involves projection conversion of coordinate systems, range conversion of data, and ggplot::...
0
votes
1
answer
129
views
Stop projected data from double-wrapping around map in particular projections (tidyterra)
When plotting global data using tidyterra, I'm experiencing a weird issue with the way the data wraps around the edges of the map (e.g. the -180/180 boundary). As shown in the example below, ...
1
vote
1
answer
87
views
Control rescaling when binning continuous values in tidyterra
I'm trying to use tidyterra's scale_*_whitebox_b() to bin continuous values using custom breaks that are unevenly distributed, to emphasize the difference in the low values. I'm having trouble because ...
1
vote
1
answer
72
views
Problems with facet_* when nulls occur in multilayer rasters
When using tidyterra for multi-layer raster plotting, the facet_* function doesn't seem to work effectively when one of the layers has the null value “NA”. I'm not sure if this is a bug or if there is ...
0
votes
1
answer
112
views
White dots on SpatRaster when plotting with tidyterra::geom_spatraster_RGB() and not terra::plotRGB()?
I'm making a map of this island and whenever I try to plot it using tidyterra::geom_spatraster_RGB() there are these white dots and the graph is more pale than when I use terra::plot_RGB(). I ...
1
vote
1
answer
103
views
How to combine SST contour lines and polygons of reef distribution on a world map showing oceans bathymetry?
I would like to create a world map showing the global distribution of coral reefs in combination with the two 20°C isotherms. I have managed to plot them individually, but not in a single graph. The ...
0
votes
2
answers
386
views
How to extract the density population of specific longitude and latitude points from the GHSL population data?
I have a data frame with about 20,000 rows containing the latitude and longitude of points spread across the world. I need to determine the population density at those points, so I considered using ...
1
vote
1
answer
205
views
In tidyterra for R, could facet_grid be implemented?
In R, package tidyterra allows use of facet_wrap(~lyr) to plot multiple spatial raster layers in one figure.
library(terra)
library(ggplot2)
library(tidyterra)
x <- rast(array(data = rnorm(120,0,1),...
0
votes
2
answers
86
views
issues plotting cropped raster DEM in ggplot
It's probably a stupid mistake but I can't figure out what I am doing wrong. I have a DEM raster I can visualize using plot() and ggplot() just fine. But when I try to crop and mask it to a smaller ...
3
votes
1
answer
402
views
Using coord_sf with geom_spatraster changes the resolution
I am trying to plot a subregion of a large raster (e.g., just Arizona out of a raster that covers North America) using tidyterra and ggplot2. I have tried setting the limits of the plot by setting the ...
2
votes
1
answer
1k
views
Basemap in basemaps_gglayer() not working
I'm trying to add a basemap to some of my figures. It seems like the basemaps package is the best way to go, but I haven't been able to get it to work.
Here's the original code for the figure, which ...
0
votes
2
answers
90
views
Add Spatrastermap to existing Spatrastermap
I would like to combine the map p with the map x in the following way:
at those points where the plot x is white, I would like to see plot p (as first layer), and for the colored points the plot x, as ...
1
vote
1
answer
331
views
Cowplot sizing issue with a 3 x 3 grid plot of rasters with differing parameters for each cell
I have been trying to solve a sizing issue with 3x3 grid of plots with ggplot, cowplot and tidyterra. The plots are spatial rasters, that need a shared legend for each row, a title in the first row, ...
0
votes
1
answer
310
views
Changing color categories and scale in rasters in ggplot2 in R
I would like to modify the colors across which my palette operate, to expand the yellow region so that extreme values in my figure stand out more dramatically. I can't figure out how to change this, ...
0
votes
1
answer
201
views
plotting multiple attribute columns of shapefile in panel
I have a GIS vector file containing multiple attribute columns, such as t1, t2, t3, up to t8. My objective is to create individual plots for each attribute column within a panel display. Despite my ...
0
votes
1
answer
503
views
How to visualize the continuous raster data by quantile colors in R
I have a raster list (raster data with 6 layers) with Continuous values. Now I would like to visualize them using R::tidyterra. I have two questions:
1、How to represent the continuous values by ...
3
votes
2
answers
505
views
Show grid lines above `geom_spatraster` but below data points in `ggplot2`?
I am drawing a raster map with points on it in ggplot2 using tidyterra:
library(ggplot2)
library(rnaturalearth)
library(terra)
library(tidyterra)
backmap <- ne_download(scale=50, type="...
1
vote
1
answer
842
views
truncate colour pallete with ggplot2 and geom_spatraster() in different layers
I want to be able truncate the colour pallete for certain values of a raster using ggplot, which I am able to do using basic plotting of the terra object, but not with ggplot2.
This is what I have ...
0
votes
1
answer
193
views
ggplot of raster maps: Horizontal / vertical grid cells distortion
I am plotting multiple projected raster objects (SpatRaster or raster stack; equal area projection; EPSG:3035), all having the same extent. Example map
However, the mapped grid cells are distorted, ...
0
votes
1
answer
193
views
How to visualise a map using more color-blind safe composite instead of rgb (red, green, blue)?
This question came up after getting the answer to the question.
Basically, I have a dataframe (please see reproducible data below) with columns that I want to visualise with rgb color-composite (the ...
1
vote
1
answer
377
views
How to visualise rgb color maps using tidyterra?
I have a dataframe df (please see reproducible data below) with x, y, a, b, c columns. I compute rgb (red, greeb, blue) color composite:
# compute rgb
df$rgb = rgb(df$a, df$b, df$c)
Then, I want to ...
2
votes
2
answers
297
views
pretty_breaks not working with geom_spatraster
I am trying to use scales::pretty_breaks with geom_spatraster like
library(terra)
library(ggplot2)
library(tidyterra)
r1 <- rast(system.file("ex/elev.tif", package="terra"))
r2 ...