R语言 使用tif和xml文件进行地理空间分析

6yoyoihd  于 2023-01-10  发布在  其他
关注(0)|答案(1)|浏览(216)

我试着自学如何使用rayshader包在R中制作地形图,我试着模拟共享的this twitter account代码,但我不知道如何让tif和xml文件像twitter上共享的代码使用RDS文件那样工作。
作为参考,here是从我访问数据的地方。任何帮助将不胜感激!

str_name<-'AM_AMS_NH2903L.tif' 
imported_raster=raster(str_name)
map_file <- xmlParse(file = "AM_AMS_NH2903L.xml")
get_elev_raster(map_file, z=6) -> dem
mask(dem, map_file) -> map_file_dem
rayshader::raster_to_matrix(map_file_dem) -> map_file_mat
rayshader::resize_matrix(map_file_mat, 0.7) -> map_file_mat_reduced
map_file_mat_reduced %>%
  sphere_shade(texture = "imhof3") %>%
  plot_3d(map_file_mat, windowsize = c(1200,1200),
          zscale = 20, zoom = 0.75, phi = 89, theta = 0, fov = 0, background = "black")
render_highquality(filename = "map.png", samples = 100, width = 6000, height = 6000)
33qvvth1

33qvvth11#

我不会马上下载数据,因为需要电子邮件地址,但你可能不需要xml文件。大多数时候,海拔tif“图像”有海拔值作为每个“像素值”。所以它基本上只是绘制tif值作为高度图。

imported_raster=raster('AM_AMS_NH2903L.tif')
mat = raster_to_matrix(imported_raster)
mat = resize_matrix(mat, scale=0.7)
map_file_mat_reduced %>%
    sphere_shade(texture = "imhof3") %>%
    plot_3d(map_file_mat, windowsize = c(1200,1200),
    zscale = 20, zoom = 0.75, phi = 89, theta = 0, fov = 0, background = "black")
render_highquality(filename = "map.png", samples = 100, width = 6000, height = 6000)

相关问题