An R package to plot the spatial data and create maps, which is specifically designed to work with data in the Spatial* objects.
Questions tagged [ggspatial]
20 questions
11
votes
3 answers
How to truly calculate a spherical voronoi diagram using sf?
I want to make a world map with a voronoi tessellation using the spherical nature of the world (not a projection of it), similar to this using D3.js, but with R.
As I understand ("Goodbye flat Earth, welcome S2 spherical geometry") the sf package is…

Arthur Welle
- 586
- 5
- 15
7
votes
0 answers
How to make geom_sf() point northwards?
I am trying to make a mapping package for R and ggplot that would allow the users to define their data using decimal degrees but would use appropriate projection depending on where the user's data are located. I decided to use the ggspatial package…

Mikko
- 7,530
- 8
- 55
- 92
2
votes
1 answer
Adding rivers to a map with rnaturalearth
I am trying to add river data to this map below
asia_cropped <- st_crop(world, xmin = 100, xmax = 110,
ymin = 7, ymax = 24) #cropping map
SEA <- ggplot() + geom_sf(data = asia_cropped) + theme_bw() + #south east…

Jack Ward
- 21
- 3
2
votes
1 answer
How to customize legend in ggplot for multiple layers in a map?
I'm trying to fix my caption but I'm having trouble creating it. I wanted a caption for the classes (fill), the shape limit (color), the points (color) and the grid (fill=NA). I put them all in aes () but I don't have the expected result. Can…

Igor Cobelo
- 419
- 3
- 12
2
votes
0 answers
Using projected coordinates for axis labels and gridlines in a ggspatial plot?
I'm plotting a map in UTM projection with ggspatial. The map is plotted in the correct projection, but axis labels are still lat-lon degrees. I want to show UTM coordinates on the axes.
Required output:
map of Germany with UTM coordinates in…

user5730487
- 23
- 3
2
votes
2 answers
How to pass Thunderforest API key to the R ggspatial package to create a map
I am creating maps using the rosm and ggspatial R package. The ggosm function is easy to use to extract a base map layer based on the spatial object provided. Here is an example.
library(ggplot2)
library(sp)
library(rosm)
library(ggspatial)
ggosm()…

www
- 38,575
- 12
- 48
- 84
1
vote
1 answer
How to make the Great Lakes the same color as the ocean in R?
I am new to using R to make maps. I am trying to make a map of North America (centered on the US) and would like the Great Lakes to be the same color as the ocean color. My current code defaults to having them the same color as the countries/states.…

tassones
- 891
- 5
- 18
1
vote
0 answers
Replicating Hexagon heatmap in ggmaps [R]
I need to replicate heatmap that can be found in the link: https://rpubs.com/chrisbrunsdon/gwdplyr
I tried the very approach however I cannot replicate final hexagon colored heatmap.
My main issues is that I am having problem with even creating non…

Petr
- 1,606
- 2
- 14
- 39
0
votes
0 answers
Latitude axis labels lost when mapping in ggplot2
I am working on making a map of North America. When I plot the map, the longitude axis labels show up as they are supposed to but for some unknown reason, the latitude axis labels do not show. How can I get the latitude axis labels to…

tassones
- 891
- 5
- 18
0
votes
1 answer
ggplot2 overwrites plot limits
I have two shapefiles, which I would like to plot into a given plot extent. One of the shapefiles exceeds the extent and when plotted it automatically overwrites the limits of the extent. This happens when loading the shapefiles using the terra…

user21816
- 147
- 6
0
votes
1 answer
ggspatial::geom_spatial_path() function not working as intended
I'm currently studying the basics of GIS with R at this link. I'm at Vector Data > Lines section and I'm experiencing something that looks like a bug when trying to plot some LINESTRING objects with ggspatial package.
Below my…

Bezzus
- 69
- 8
0
votes
0 answers
Why isn't my new summarize column showing when I look at the dataframe? (Is it related to ggspatial?)
I am trying to create a new column on a merged dataframe for the per capita value of variable p in different states. Then I am trying to put them onto a ggspatial map. Below is my code.
data(us_states)
#Merge
st_geometry(state_p) <- NULL #bc R…

Sed
- 1
0
votes
0 answers
Scale bar on ggmap and ggplot2 not to scale
I am creating a map on R using ggmplot2 and ggmap, withe ggspatial package to add a north arrow and scale bar. Everything works until I try to add the scale bar with annotation_scale(location = 'tl') and the coord_sf() lines at the end. The scale…
0
votes
1 answer
Add solid colour behind ggspatial scale bar and label
I'm wondering if it is possible to put a box behind the entire scale including the text in ggspatial's annotation scale? I'm creating a series of maps which have some line polygons and the label often falls along or is cut by a line and it just…

Sarah
- 3,022
- 1
- 19
- 40
0
votes
1 answer
ggspatial: geom_sf fails with certain xlim values in coord_sf
What I'm trying to do: plot spatial objects with ggspatial::geom_sf(), using coord_sf() or a combination of ggspatial::layer_spatial() and ggspatial::annotation_spatial() to specify the extent of the of the plot.
This ggplot/ggspatial behavior has…

user5730487
- 23
- 3