Closed SymbolixAU closed 5 years ago
It is totally valid. Think of z
values in the polygon
array the "base" elevation and getElevation
the amount of extrusion. This question has came up before and we should clarify it in the docs.
Excellent.
Think of z values in the polygon array the "base" elevation and getElevation the amount of extrusion.
This is a key point of clarification and would be useful in the docs.
@Pessimistress is extrusion then relative to each base vertex, so also tited at the top for a triangle? And a bit nonsensical for non triangle polygons, or does triangulation get applied implicitly?
@mdsumner I had the same question - hopefully this helps
Setting up some data (in R)
poly1<- matrix(c(0,0,0,0,1,1000,1,1,50000,1,0,25000,0,0,0), ncol = 3, byrow = T)
poly2<- matrix(c(0,0,0,0,-1,1000,-1,-1,50000,-1,0,25000,0,0,0), ncol = 3, byrow = T)
poly1 <- sf::st_sfc( sf::st_polygon( x = list( poly1 ) ) )
poly2 <- sf::st_sfc( sf::st_polygon( x = list( poly2 ) ) )
poly1 <- sf::st_sf( geometry = poly1 )
poly2 <- sf::st_sf( geometry = poly2 )
sf <- rbind( poly1, poly2 )
sf$id <- 1:2
The polygons have a Z attribute. I'm making two plots, one using the extrusion
, and one without
Just using the Z
attribute on the data
mapdeck() %>%
add_polygon(
data = sf
, fill_colour = "id"
)
uses getElevation
to extrude the polygon from the map
mapdeck() %>%
add_polygon(
data = sf
, elevation = 100000
, fill_colour = "id"
)
So the Z
is applied for each vertex. The extrusion is applied to the whole polygon, while respecting the initial Z
elevation (as both the base and top surfaces are tilted)
Thanks! (nice!!!)
Those top-faces do look like implicitly triangulated quads to me, see how it's kind of saddle-looking? I bet there's an earcut triangulation going on, I'll try with more complex polys
This is a key point of clarification and would be useful in the docs.
@SymbolixAU May the documentation use the lovely example image in your original issue?
@Pessimistress of course it can. Would you like me to send a higher-res version, or are you happy grabbing the gif directly from the original post? And would you like the underlying data?
(@mdsumner - assuming this is OK with you as it's your example originally)
No problem!
Background
Polygon layer coordinate specification
The documentation for polygon layer specifies the following data format
I've just generated an example which has coordinates in the form of
Where the elevation is specified as the 3rd value in each coordinate array (as per GeoJSON).
Which gives
Should the documentation reflect that you can specify the elevation in the coordinate array, as well as in the getElevation prop?
And is this a valid way to supply the elevation?
Related issue from my mapdeck library
Update
The same works for
pathLayer
too, where you can specify the elevation in thecoordinates [ ]
arrayTo Do List