Issue connecting to Landsat raster in a STAC API
I'm having trouble connecting to a COGs in the LandsatLook STAC API. When I run the following code I get the following results:
# Sorry, it's an ugly string
url <- 'https:\landsatlook.usgs.gov\tile\collection02\etm\2018\CU\011\016\LE07_CU_011016_20180411_20210503_02\LE07_CU_011016_20180411_20210503_02_QA_PIXEL.TIF'
terra::rast(paste0('/vsicurl/', url))
Error: [rast] cannot open file: /vsicurl/https://landsatlook.usgs.gov/tile/collection02/etm/2018/CU/011/016/LE07_CU_011016_20180411_20210503_02/LE07_CU_011016_20180411_20210503_02_QA_PIXEL.TIF
In addition: Warning message:
Line 49: </head> doesn't have matching <head>. (GDAL error 1)
I've corresponded with EROS customer service about it and, while they did find an issue with the file headers on their side, they don't believe that caused this issue. They said they had no experience doing this with R, but figure it must be a problem with my script.
I have successfully connected to other rasters. For example, I can connect to this Sentinel image:
terra::rast(paste0('/vsicurl/',
'https://sentinel-cogs.s3.us-west-2.amazonaws.com/sentinel-s2-l2a-cogs/30/K/UE/2022/7/S2B_30KUE_20220712_0_L2A/B01.tif'))
class : SpatRaster
dimensions : 1830, 1830, 1 (nrow, ncol, nlyr)
resolution : 60, 60 (x, y)
extent : 3e+05, 409800, 7890220, 8000020 (xmin, xmax, ymin, ymax)
coord. ref. : WGS 84 / UTM zone 30S (EPSG:32730)
source : B01.tif
name : B01
I assume this is an issue with an XML header, or maybe something in their metadata but I can't see where in the process it's failing. I've investigated the GDAL error 1 a little, but what I found pertained to CRSs, not file headers. Unfortunately, I'm at a loss on how troubleshoot this further. Any suggestions? Thanks!
I have the same error in QGIS 3.22: ERROR 1: Line 49: </head> doesn't have matching <head>.
Isn't this URL only for web browsers and you have to be logged in?
This file doesn't look like it could be loaded by GDAL:
url <- "https://landsatlook.usgs.gov/tile/collection02/etm/2018/CU/011/016/LE07_CU_011016_20180411_20210503_02/LE07_CU_011016_20180411_20210503_02_QA_PIXEL.TIF"
tmp <- tempfile(fileext = ".TIF")
download.file(url, tmp)
readLines(tmp)
I'd second @kadyb's question about the URL. TIF downloads successfully in browser (and can be then loaded w/ rast() after manual download)
Authentication is an issue here, and even when logged in the parent directory gives 403 forbidden : https://landsatlook.usgs.gov/tile/collection02/etm/2018/CU/011/016/LE07_CU_011016_20180411_20210503_02/
I have also encountered issues trying to read TIFF files w/ GDAL under these circumstances where parent directory and other auxiliary files may not be accessible.