Home > Blockchain >  When I Call Open Topography GET, it installs a .tif file, but R is unable to create a raster image f
When I Call Open Topography GET, it installs a .tif file, but R is unable to create a raster image f

Time:10-18

library(raster)
library(rgdal)
library(elevatr)
library(rgeos)
library(leaflet)
library(RColorBrewer)
library(rgl)

r1 <- raster()
s1 <- stack()
base <- 'https://portal.opentopography.org/API/globaldem?demtype=AW3D30'
api_key <- '<API-KEY>'
tmp_south <- 36.738884
tmp_north <- 38.091337
tmp_west <- -120.168457
tmp_east <- -118.465576
url <- paste0(base, '&south=', tmp_south, '&north=', tmp_north, '&west=', tmp_west, '&east=', tmp_east, '&API_Key=', api_key)
download.file(url, "./display.tif", mode = "wb")
r1 <- raster(system.file("display.tif"), package="raster")
image(r1)

The Error:

Error in .rasterObjectFromFile(x, band = band, objecttype = "RasterLayer", : Cannot create a RasterLayer object from this file.

CodePudding user response:

The problem is your call to system.file().

I notice in the enter image description here

  • Related