Comments (2)
Never mind, this works no problem!
token = Sys.getenv("MAPBOX_TOKEN")
terrain_img = "terrain-rgb"
surface_img = "satellite"
elev_map = list(
rScaler = 6553.6,
gScaler = 25.6,
bScaler = 0.1,
offset = -10000
)
props = list(
minZoom = 0,
maxZoom = 23,
strategy = "no-overlap",
elevationDecoder = elev_map,
elevationData = sprintf(
"https://api.mapbox.com/v4/mapbox.%s/{z}/{x}/{y}.png?access_token=%s",
terrain_img, token),
texture = sprintf(
"https://api.mapbox.com/v4/mapbox.%s/{z}/{x}/{y}.png?access_token=%s",
surface_img, token),
wireframe = FALSE,
color = c(255, 255, 255)
)
deckgl(
element_id = "mapgl",
latitude = 13,
longitude =-6,
zoom = 12,
bearing = 140,
pitch = 60,
maxPitch = 89,
height = "360px"
) %>%
add_layer("TerrainLayer",
id = "terrain",
properties = props)
from deckgl.
I'm trying to do a similar thing, but with a downloaded bathymetry raster layer from the marmap
package. See below for reproducible example, I don't understand why deckgl is not rendering the terrain layer, but I suspect it's something with how the png image is produced?
library(marmap)
# noaa bathy
b <- getNOAA.bathy(lon1 = -74.2, lon2 = -73.3, lat1=40.3,
lat2 = 40.7, resolution = 0.1)
# convert to raster and save as png?
r <- as.raster(b)
png(file = "output/bathy_grey.png")
raster::plot(r, maxpixels=ncell(r), col=grey.colors(255),
axes=FALSE, box=FALSE, legend=FALSE)
dev.off()
elevation_data <- normalizePath( "output/bathy_grey.png")
bounds = c(r@extent@xmin, r@extent@ymin, r@extent@xmax, r@extent@ymax)
elevation <- sprintf("data:image/png;base64,%s", base64enc::base64encode(elevation_data))
elev_map = list(
rScaler = 1,
gScaler = 0,
bScaler = 0,
offset = 0
)
props = list(
strategy = "no-overlap",
elevationDecoder = elev_map,
elevationData = elevation,
bounds = bounds
)
deckgl(
latitude = 40.5,
longitude = -74,
zoom = 10,
pitch = 45,
height = "600px") |>
add_basemap() |>
add_layer("TerrainLayer",
id = "terrain",
properties = props)
from deckgl.
Related Issues (20)
- Zoom update is not happening when using deckgl_proxy HOT 6
- update view state HOT 1
- Syntactic sugar section
- Move /inst/examples to /examples
- Rename first parameter in widegt function from deckgl to deck
- Add shiny example to shiny-bindungs in r-docs
- sf layers aren't rendering HOT 5
- Map not rendering HOT 1
- deck gl layers toggle HOT 2
- Highlight Polygons HOT 1
- Lighting effects for R deckgl HOT 1
- Change view from MapView to OrthographicView
- trips Layer HOT 1
- OnClick not working HOT 1
- removing old add_legend in shiny app HOT 3
- Updating deckgl map in shiny removes previous layer HOT 1
- It is possible that Heatmap doesn't work? HOT 2
- Rendering multiple maps in a Quarto doc creates issue with hovering and tooltips HOT 1
- Rendering Rasters
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from deckgl.