Geospatial analysis using tif and xml files

192 Views Asked by At

I'm trying to self-teach myself how to make topographical maps in R using the rayshader package. I tried emulating the code this twitter account shared. I can't quite figure out how to get the tif and xml files to work like how the code shared on twitter used the their RDS file.

For reference, here is from where I am accessing the data. Any assistance would be greatly appreciated!

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)
1

There are 1 best solutions below

0
On

I won't download the data right now because of the email address required, but you probably don't need the xml File. Most of the time elevation tif "images" have the elevation value as each "pixel value". So it's basically just plotting the tif values as height map.

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)