-
|
I am afraid this is more question related to gdal than gdalraster, feel free to delete if it doesnt fit here. I am wondering if it is possible to query the compression type of overviews of GeoTIFF/COG images? library(gdalraster)
infile <- "/vsicurl/https://dgm.s3.eu-de.cloud-object-storage.appdomain.cloud/325735712/2016-04-04/dgm1_32_573_5712_1_ni_2016.tif"
ds <- new(GDALRaster, infile)
ds$getOverviewCount(band = 1)
outfile <- tempfile(fileext = ".tif")
temp_raster <- createCopy(
src_filename = infile,
dst_filename = outfile,
format = "COG",
options = c("COMPRESS=LZW", "OVERVIEWS=IGNORE_EXISTING", "OVERVIEW_COMPRESS=DEFLATE")
)
ds <- new(GDALRaster, outfile)
ds$getOverviewCount(band = 1)
ds$getMetadataItem(band = 0, mdi_name = "COMPRESSION", domain = "IMAGE_STRUCTURE")Is there a way we could see that its DEFLATE in this case? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
|
Yes, GDAL has a dataset open option:
Also:
You'll need to use the constructor for library(gdalraster)
#> GDAL 3.9.3 (released 2024-10-07), GEOS 3.12.2, PROJ 9.4.1
infile <- "/vsicurl/https://dgm.s3.eu-de.cloud-object-storage.appdomain.cloud/325735712/2016-04-04/dgm1_32_573_5712_1_ni_2016.tif"
ds <- new(GDALRaster, infile)
ds$getOverviewCount(band = 1)
#> [1] 1
ds$close()
outfile <- tempfile(fileext = ".tif")
temp_raster <- createCopy(
src_filename = infile,
dst_filename = outfile,
format = "COG",
options = c("COMPRESS=LZW", "OVERVIEWS=IGNORE_EXISTING", "OVERVIEW_COMPRESS=DEFLATE")
)
#> 0...10...20...30...40...50...60...70...80...90...100 - done.
ds <- new(GDALRaster, outfile)
ds$getOverviewCount(band = 1)
#> [1] 1
ds$getMetadataItem(band = 0, mdi_name = "COMPRESSION", domain = "IMAGE_STRUCTURE")
#> [1] "LZW"
# use the OVERVIEW_LEVEL open option to open an overview as a dataset, level index starts at 0
ds_ovr <- new(GDALRaster, outfile, read_only = TRUE, open_options = "OVERVIEW_LEVEL=0")
ds_ovr$getMetadataItem(band = 0, mdi_name = "COMPRESSION", domain = "IMAGE_STRUCTURE")
#> [1] "DEFLATE"
ds_ovr$close()
ds$close()Created on 2025-03-18 with reprex v2.1.1 |
Beta Was this translation helpful? Give feedback.
-
|
In this case it was a "general" dataset open option that applies to all formats. Usually though, dataset open options are format-specific. So when working with a certain format it may worth checking the driver documentation page to see what options are available, e.g., https://gdal.org/en/stable/drivers/raster/gtiff.html#open-options The OVERVIEW_LEVEL open option is more hidden. It is in the API documentation at: down under Parameters: papszOpenOptions. I'm not sure if it appears elsewhere in the GDAL docs. It may be worth adding to the gdalraster documentation, and adding it somewhere in the GDAL docs if confirmed that it's not covered other than in the API. |
Beta Was this translation helpful? Give feedback.
Yes, GDAL has a dataset open option:
Also:
You'll need to use the constructor for
GDALRasterthat includesopen_options, i.e., all arguments are required up to that one (see Constructors under Usage at https://usdaforestservice.github.io/gdalraster/reference/GDALRaster-class.html). With your example above: