Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
343 views
in Technique[技术] by (71.8m points)

r - Showing Elevation Mapdeck

I require some help in getting my elevation to show in mapdeck. For some reason I cant seem to get the code to work. I can show the points on the map as 2D points using "add_scatterplot" but whenever I try and get it to use the elevation data it does not appear to work and I keep getting the same error. Here is my code and said error:

     mapdeck( token = key, style = mapdeck_style("satellite"), location = c(-2, 57.22),
     zoom = 12,
          pitch = 35) %>% 
     add_scatterplot(
     data = turbines, 
     fill_colour = "Turbine_identifier",
     palette = "green2red") %>% 
     add_trips(
     data = sf_harriers,
     stroke_colour = "TrackId",
     animation_speed = 14,
     trail_length = 80,
     opacity = 1,
     stroke_width = 2,
     palette = colourvalues::get_palette("heat")[6:13, ]) %>% 
   add_column (
   data = turbines,
   lat = "latitude",
   lon = "longitude",
   elevation = "hub_height",
   elevation_scale = 100,
   update_view = FALSE)

The error that spits out is:

""Error in if (nrow(df) != nrow(.data)) { : argument is of length zero""

Which I dont understand as if I plot it without the last layer it plots fine. However when i use "add_column" to then try and get those points to display in 3D using their elevation, it keeps ringing that error. What am I doing wrong?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The error message you're seeing is from tibble::add_column(). Therefore you have a conflict in libraries, which you would have been warned about when loading one or the other

library(tibble)

Attaching package: ‘tibble’

The following object is masked from ‘package:mapdeck’:

    add_column

So it looks like you've loaded tidyerse or tibble AFTER mapdeck, so the add_column() function you're calling is actually tibble::add_column(). Change this to mapdeck::add_column() and your code works.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...