I'm trying to read Triplesat imagery into R. However there seems to be a problem with the coordinate reference in the .tif file as the crs, extent and resolution are not loaded. I tried two ways of loading the data with raster() from the raster package and readGDAL() from rgdal. Both have the same problem, other .tif files work fine. QGIS however does open the .tif and displays it properly because it finds the extents in a text file that is located in the same folder.
R information on raster object:
class : RasterLayer band : 1 (of 4 bands) dimensions : 7775, 7810, 60722750 (nrow, ncol, ncell) resolution : 1, 1 (x, y) extent : 0, 7810, 0, 7775 (xmin, xmax, ymin, ymax) coord. ref. : NA data source : D:\\Triplesat\\MyRaster.tif names : TRIPLESAT_3_MS_L1_20170802093353_001097VI_006_20170630001001_030 values : 0, 65535 (min, max)
My question is, how can I open the .tif in R so that the coordinate reference is properly loaded? Either by getting the values from a metadata-file or by defining the coordinate reference after that. If possible I would like to stay within R.
What I have tried:
- Assigning a crs and extent with
r <- raster("D:\\Triplesat\\MyRaster.tif") crs(r) <- "+init=epsg:4326" extent(r) <- extent(reference_raster) # reference raster has the same spatial boundaries
This however does not work because the extent is based on the min.x, min.y, max.x, max.y values which creates a rectangle bounding box with the x-axis in east-west direction. The raster however is not so straight, see:
Loading the data in QGIS and exporting it so R can open it. This works for a few files but I need to perform the same procedure dozens of times so this method is too time consuming.
Using ESA's SNAP Desktop. However also SNAP does not load the coordinate references.
WeTransfer download link to files: https://we.tl/WdwNMhvqFH
Included in the files is also a browser file that is used for quick viewing the data. This does load properly in R and gives me the correct crs information. Also in QGIS the projection is displayed in lattirude longitude. See the R result:
browser <- raster("D:\\Triplesat\\MyBrowserRaster.tif") crs(browser) CRS arguments: +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0