Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

should layer_mapbox forward ... to layer_spatial ? #13

Open
MilesMcBain opened this issue Dec 15, 2020 · 2 comments
Open

should layer_mapbox forward ... to layer_spatial ? #13

MilesMcBain opened this issue Dec 15, 2020 · 2 comments

Comments

@MilesMcBain
Copy link
Collaborator

Could this for example be used to set layer opacity?

@anthonynorth
Copy link
Owner

anthonynorth commented Dec 15, 2020

A vector basemap with no background is already transparent.
Edit: forwarding ... to layer_spatial() seems fine to me.

library(sf)
#> Linking to GEOS 3.8.0, GDAL 3.0.4, PROJ 6.3.1
library(ggplot2)
library(snapbox)

area <- st_bbox(
  c(xmin = 147, ymin = -43, xmax = 147.7, ymax = -42.65),
  crs = 4326
)

ggplot() +
  layer_mapbox(
    area, 
    map_style = mapbox_satellite(), 
    scale_ratio = 0.5
  ) +
  layer_mapbox(
    area, 
    map_style = "mapbox://styles/anthony-north/ckipret4b09ap18ofyrw4yea7", 
    scale_ratio = 0.5
  )
#> Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO", prefer_proj
#> = prefer_proj): Discarded ellps WGS 84 in CRS definition: +proj=merc +a=6378137
#> +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null
#> +wktext +no_defs +type=crs
#> Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO", prefer_proj =
#> prefer_proj): Discarded datum World Geodetic System 1984 in CRS definition
#> Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO", prefer_proj
#> = prefer_proj): Discarded ellps WGS 84 in CRS definition: +proj=merc +a=6378137
#> +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null
#> +wktext +no_defs +type=crs
#> Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO", prefer_proj =
#> prefer_proj): Discarded datum World Geodetic System 1984 in CRS definition
#> Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO", prefer_proj
#> = prefer_proj): Discarded ellps WGS 84 in CRS definition: +proj=merc +a=6378137
#> +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null
#> +wktext +no_defs +type=crs
#> Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO", prefer_proj =
#> prefer_proj): Discarded datum World Geodetic System 1984 in CRS definition
#> Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO", prefer_proj
#> = prefer_proj): Discarded ellps WGS 84 in CRS definition: +proj=merc +a=6378137
#> +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null
#> +wktext +no_defs +type=crs
#> Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO", prefer_proj =
#> prefer_proj): Discarded datum World Geodetic System 1984 in CRS definition

Created on 2020-12-15 by the reprex package (v0.3.0)

@noamross
Copy link

Yup, can confirm this works well with other raster layers:

library(ggplot)
#> Error in library(ggplot): there is no package called 'ggplot'
library(sf)
#> Linking to GEOS 3.8.0, GDAL 3.0.4, PROJ 6.3.1
library(ggspatial)
library(snapbox)
library(raster)
#> Warning: package 'raster' was built under R version 4.0.3
#> Loading required package: sp

worldclim <- raster::getData('worldclim', var='prec', res=2.5, lon = 142.61, lat = -23.64)

area <- st_bbox(
  c(xmin = 101.03, ymin = -44.82, xmax = 168.23, ymax = -9.09),
  crs = 4326
)

rast <- raster::crop(worldclim[[1]], extent(area))
ggplot() +
  layer_spatial(rast) +
  layer_mapbox(area,
               map_style = "mapbox://styles/noamross/ckipi0rfl3ybv17p9dnom27ir/draft",
               scale_ratio = 1)
#> Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO", prefer_proj
#> = prefer_proj): Discarded ellps WGS 84 in CRS definition: +proj=merc +a=6378137
#> +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null
#> +wktext +no_defs +type=crs
#> Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO", prefer_proj =
#> prefer_proj): Discarded datum World Geodetic System 1984 in CRS definition

Created on 2020-12-15 by the reprex package (v0.3.0)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants