Closed dominicroye closed 8 months ago
I am also having this issue with the newest version of R. My colleague had it running properly on an older version of R from 2022. It must be an incompatibility with R version 4.3 or higher, and/or one of the dependencies.
@16EAGLE - This probably has something to do with all the latest changed in terra - we have systematically gone through some of the other package dependencies that would have likely led to the basemaps not rendering properly - magick, pbapply, slippymath, etc... but terra is the only one that has had some pretty major changes recently. I'd imagine this is where the problem lies. Unfortunately, there doesn't seem to be an easy to way to install an older version of terra as it gives a series of non-zero exit status warnings when you try to install an older version from source
Same problem here. Same code worked a month ago. Maybe this error message is useful: satview <- basemaps::basemap_png( ext = my _sf_object, map_service = "esri", map_type = "world_imagery", map_res = NULL, verbose = TRUE, browse = FALSE ) C:/Users/Apste/AppData/Local/Temp/Rtmpi8SwAu/basemaps/esri_world_imagery_603_361.png: Access window out of range in RasterIO(). Requested (0,0) of size 640x512 on raster of 256x256. (GDAL error 5)
I compiled terra_1.7-29, the previous release, for windows, and all is well again. The compilation did spit out a lot of undefined object warnings for things in other packages and I got a warning that a configuration file might be needed but that did not prevent success.
Has there been any update on this issue? It maybe due to certain institutional limits placed on my workstation, but the archive versions of terra do not compile on my Mac.
Update 8/16/2023 - I was able to leverage other resources in order to get a copy of terra_1.7-29. Specifically, a custom environment was built within a Singularity/Apptainer container and it is working fine.
Maybe a bit off topic, but whilst I can see some nice additional functions and speed benefits of terra, the whole system feels like going from sf to sp. With raster it was clear what each function did and the rasters could be interrogated in the environment or using @ to get nlayers, max min etc..
Almost every week there is some serious bug in terra. Does anyone know of any plans to keep raster alive? I would be a supporter.
@BlaiseKelly I personally know of none. In fact, I have been unsuccessful with installing raster on newer versions of R - even from archived source tarballs.
In a more concerning case, there was recent need for me to rerun some of my older code ran with R 3.x, and I had verified that raster was installed with that R version. However, once the version of R had been switched in my RStudio and some other packages had been updated, raster would no longer load into the session. Double checking, the files for the raster were no longer in my libraries directory. My best guess is that one of the packages which required an update called terra, which over-writ raster.
The only way I have been successful in retaining a version of raster has been with containers, and even then it has been with installing R through Ubuntu instead of CRAN.
Just a note that for me it was working perfectly on R 4.3.0. Then I upgraded to 4.3.1 and I started having the same issues. I downgraded to 4.3.0 but now that version is having the same issue.
A few more notes on this.
Using the rocker/geospatial
Docker container for reproducibility it seems that the issue is related to the terra::mosaic
function in terra
starting with version 1.7.37.
I ran the code below using the same version of basemap (0.0.5) with different versions of terra
and got these results:
When I replace the do.call(terra::mosaic, r)
line in internal.R
in the basemaps
package with do.call(terra::merge, r)
the image it produces seems correct.
This does not necessarily mean it's an issue with terra
-- it could be related to how basemaps
feeds the images to mosaic
and the use of do.call
.
circle <- sf::st_as_sfc("POINT(-76.498361 42.439586)", crs = 4326) |>
sf::st_transform(3857) |>
sf::st_buffer(10000)
basemaps::flush_cache()
png("mymap.png")
basemaps::basemap(circle)
dev.off()
Bad image
Good image
Also having issues with this.
data(ext)
basemaps::basemap_raster(
ext = ext,
map_res = 1, map_type = "terrain_bg")
produces error: "Error: [mosaic] resolution does not match"
@zross your solution worked for me (replacing terra::mosaic with terra::merge). I just installed your fork of the package. Thanks!
Thanks to all for the heads-up, I could not work on this earlier. This should be fixed with the latest CRAN version of basemaps
, 0.0.6. Please reopen the bug persists.
@16EAGLE thanks so much!
I am not sure since when I run into this issue, but the outputs aren't correct anymore. Maybe related to some updates in other packages or dependencies.
Even using other services, they are not correct outputs:
My info session is