16EAGLE / basemaps

A lightweight package for accessing basemaps from open sources in R 🗺️
https://jakob.schwalb-willmann.de/basemaps
GNU General Public License v3.0
57 stars 15 forks source link

How to change the defaut ext to lon lat? #28

Closed lm-costa closed 6 months ago

lm-costa commented 6 months ago

I'm trying to use this library to make a basemap for brazil. Therefore, I need to make my spatial plots in degree and, I'm struggling to change the default "Web Mercator" projection from the default. Following is the warming that I'm receiving: "Transforming 'ext' to Web Mercator (EPSG: 3857), since 'ext' has a different CRS. The CRS of the returned basemap will be Web Mercator, which is the default CRS used by the supported tile services".

Is there any way to change this? following is the code I'm using

brazil_biomes <- sf::read_sf(file_name)

brazil_biomes
brazil_biomes |> sf::st_crs()

brazil_biomes_new <- sf::st_transform(brazil_biomes, "+proj=lonlat +datum=WGS84")

basemaps::get_maptypes()
basemaps::set_defaults(map_service = 'esri',
                       map_type = 'world_dark_gray_base')

basemaps::basemap_magick(ext=brazil_biomes_new)  

ggplot2::ggplot()+
  basemaps::basemap_gglayer(brazil_biomes_new)+
  ggplot2::scale_fill_identity()+
  ggplot2::coord_sf()