Skip to content

Error when using annotation_map_tile() layer. Package example plot returns error #130

Open
@EllaSantanaPropper

Description

@EllaSantanaPropper

I noticed that the plots are no longer working if the layer annotation_map_tile is included in the code. To make sure it wasn't my data, I checked with the code example given on the ggspatial homepage (https://paleolimbot.github.io/ggspatial/).

The following code returns this error:
Error in annotation_map_tile():
! Problem while converting geom to grob.
ℹ Error occurred in the 1st layer.
Caused by error in loadNamespace():
! there is no package called 'prettymapr'

# Code from ggspatial package homepage demonstrating how it works

library(ggplot2)
library(ggspatial)
load_longlake_data()

ggplot() +
  # loads background map tiles from a tile source
  annotation_map_tile(zoomin = -1) +
  
  # annotation_spatial() layers don't train the scales, so data stays central
  annotation_spatial(longlake_roadsdf, size = 2, col = "black") +
  annotation_spatial(longlake_roadsdf, size = 1.6, col = "white") +
  
  # raster layers train scales and get projected automatically
  layer_spatial(longlake_depth_raster, aes(colour = after_stat(band1))) +
  # make no data values transparent
  scale_fill_viridis_c(na.value = NA) +
  
  # layer_spatial trains the scales
  layer_spatial(longlake_depthdf, aes(fill = DEPTH_M)) +
  
  # spatial-aware automagic scale bar
  annotation_scale(location = "tl") +
  
  # spatial-aware automagic north arrow
  annotation_north_arrow(location = "br", which_north = "true")

Image

However, when I comment out the annotation_map_tile() layer, the plot does run, but obviously does not include a basemap:

ggplot() +
  # loads background map tiles from a tile source
  #annotation_map_tile(zoomin = -1) +
  
  # annotation_spatial() layers don't train the scales, so data stays central
  annotation_spatial(longlake_roadsdf, size = 2, col = "black") +
  annotation_spatial(longlake_roadsdf, size = 1.6, col = "white") +
  
  # raster layers train scales and get projected automatically
  layer_spatial(longlake_depth_raster, aes(colour = after_stat(band1))) +
  # make no data values transparent
  scale_fill_viridis_c(na.value = NA) +
  
  # layer_spatial trains the scales
  layer_spatial(longlake_depthdf, aes(fill = DEPTH_M)) +
  
  # spatial-aware automagic scale bar
  annotation_scale(location = "tl") +
  
  # spatial-aware automagic north arrow
  annotation_north_arrow(location = "br", which_north = "true")

Image

I am using R version 4.4.2 "Pile of Leaves" and ggspatial 1.1.9

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions