我正在尝试创建一个基于美国地图的stl文件,该地图具有不同的位置,如点,基于数据值的不同高度。
我可以相对容易地创建点部分。
library(ggplot2)
library(data.table)
library(rayshader)
myPoints <- structure(list(N = c(7.34e+20, 1e+18, 1.471e+21, 1.35e+21, 2.096e+21
), latitude = c(35.060137, 42.151816, 34.420986, 39.713209, 32.445652
), longitude = c(-93.133718, -71.77203, -92.530547, -75.661478,
-93.739031)), row.names = c(NA, -5L),
class = c("data.table", "data.frame"), .internal.selfref = <pointer: 0x0000000006431ef0>)
gg1 <- ggplot() +
geom_map(data = us, map = us, aes(x = long, y = lat, map_id = region),
fill = "#ffffff", color = "#ffffff", size = 0.15) +
geom_point(data = test, aes(x = longitude, y = latitude, color = N), inherit.aes = F) +
theme(legend.position = "none")
gg1
plot_gg(gg1, multicore = TRUE, width = 5, height = 5, scale = 250, windowsize = c(1400,866),
zoom = 0.55, phi = 30)但是,当我使用rayshader保存到stl时,美国部分是平坦的。

换句话说,它基本上是一个平坦的表面,有一些尖峰出现。因此,我想我应该尝试添加一些基于here的州级数据,这将为美国部分增加一些高程。
但发生的是,美国部分的提升抹去了点数数据。
us <- map_data("state")
arr <- USArrests %>%
rownames_to_column("region") %>%
mutate(region = tolower(region))
arr$Murder <- 0.01
gg2 <- ggplot() +
geom_map(data = us, map = us, aes(x = long, y = lat, map_id = region),
fill = "#ffffff", color = "#ffffff", size = 0.15) +
geom_map(data = arr, map = us, aes(fill = Murder, map_id = region), color = "#ffffff") +
geom_point(data = test, aes(x = longitude, y = latitude, color = N), inherit.aes = F) +
theme(legend.position = "none")
gg2
plot_gg(gg2, multicore = TRUE, width = 5, height = 5, scale = 250, windowsize = c(1400,866),
zoom = 0.55, phi = 30)

最终,我想要的是美国部分略微提高,然后我的点数据高于这一点。我试了很多次让这些点变得更大,等等,但是我不能得到它。
我想知道我是否需要放弃rayshader ggplot函数,并尝试使用矩阵,但我仍在学习使用空间数据我不知道如何将美国地图数据转换为矩阵并正确标记所述矩阵上的点。
我对任何建议都持开放态度。
发布于 2020-01-05 14:27:58
我花了一些时间来学习这个很酷的软件包,因为直到我看到这个问题我才知道它。据我从目前的CRAN手册(版本0.13.2)所理解,我认为您不能生成您所要求的图形。在CRAN手册(第15页)中,您可以看到有一个名为height_aes的参数。
默认为‘NULL’。是否应该对高度值使用“填充”或“颜色”美学,用户可以通过向此参数传递“填充”或“颜色”来指定高度值。自动检测到。如果‘填充’和‘颜色’美学都存在,那么‘填充’就是默认的。
如您所见,您可以使用fill或color在图形中创建高度。默认情况下,plot_gg()选择fill作为高度。因此,您可以看到多边形正在升高,而点没有。目前,我认为当你制作图形时,你必须选择任何一种美学。让我们拭目以待,看看我们是否能够同时创建多边形和条形图。
https://stackoverflow.com/questions/59569521
复制相似问题