paleolimbot / ggspatial

Enhancing spatial visualization in ggplot2
https://paleolimbot.github.io/ggspatial
368 stars 34 forks source link

Error when setting lazy = TRUE for annotation_spatial.stars() #85

Closed qdread closed 2 years ago

qdread commented 3 years ago

Thanks for this amazing package! This issue may be related to #73 -- I've experienced a similar issue with not being able to render stars objects with a high enough resolution. I attempted to use the combination of arguments lazy = TRUE and dpi = a high number but this returns an error, see the below example.

library(ggspatial)
library(stars)
library(ggplot2)

r <- read_stars(system.file('longlake/longlake.tif', package = 'ggspatial'))

# Works
ggplot() +
  layer_spatial(r, lazy = FALSE)

# Also works but does not change the result from the above
ggplot() +
  layer_spatial(r, lazy = FALSE, dpi = 400)

# Doesn't work
ggplot() +
  layer_spatial(r, lazy = TRUE, dpi = 400)

Error message returned:

Error in (function (classes, fdef, mtable)  : 
  unable to find an inherited method for function ‘extent’ for signature ‘"NULL"’
In addition: Warning messages:
1: In min(ceiling(width_in * dpi_x * x$bbox_scale[1]), x$max_pixels[1]) :
  no non-missing arguments to min; returning Inf
2: In min(ceiling(height_in * dpi_y * x$bbox_scale[2]), x$max_pixels[2]) :
  no non-missing arguments to min; returning Inf

This is R 4.0.5

Linking to GEOS 3.9.0, GDAL 3.2.1, PROJ 7.2.1

ggplot2_3.3.3 stars_0.5-3 sf_0.9-8 abind_1.4-5 ggspatial_1.1.5