Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

infoAsJSON() calculates stats #317

Closed
mdsumner opened this issue Apr 20, 2024 · 3 comments
Closed

infoAsJSON() calculates stats #317

mdsumner opened this issue Apr 20, 2024 · 3 comments

Comments

@mdsumner
Copy link
Contributor

I'm just posting this as a note, I intend to explore it and make suggestions and PR.

Don't run this, it runs with -stats which is undersirable for very large sources and will take a long time.

#dsn <- "/vsicurl/https://gebco2023.s3.valeria.science/gebco_2023_land_cog.tif"
#info <- new(GDALRaster, dsn)$infoAsJSON()
@ctoney
Copy link
Collaborator

ctoney commented May 27, 2024

#376
The documentation adds information for the read/write fields, and setting ds$infoOptions for info() and infoAsJSON():
https://usdaforestservice.github.io/gdalraster/reference/GDALRaster-class.html

This works well without -stats and -hist:

dsn <- "/vsicurl/https://gebco2023.s3.valeria.science/gebco_2023_land_cog.tif" 
ds <- new(GDALRaster, dsn)
ds$infoOptions <- ""
info <- ds$infoAsJSON()
json <- yyjsonr::read_json_str(info)
json$metadata$IMAGE_STRUCTURE
#> $COMPRESSION
#> [1] "DEFLATE"
#> 
#> $INTERLEAVE
#> [1] "BAND"
#> 
#> $LAYOUT
#> [1] "COG"

ds$close()

@mdsumner
Copy link
Contributor Author

Oh wow, I see thank you!

Still, don't you think stats and hist should not be on by default? I think generally the defaults should be the same as the library, but I appreciate there's different usage-assumptions (and already established default here). 🙏

@ctoney
Copy link
Collaborator

ctoney commented May 27, 2024

Good point, I agree. As of #376 yesterday, the default was actually c("-norat", "-noct") since both info() and infoAsJSON() now use the new infoOptions field, so there was already a behavior change for infoAsJSON().

Done in #377. It is documented in the Changelog as a behavior change, and will be described that way in the release notes for gdalraster 1.11.

BTW, the fields on GDALRaster are now initialized to default values in the class definition in the header file, rather than using the initializer list. They have been moved up in front of the class methods there, as well as in the documentation at:
https://usdaforestservice.github.io/gdalraster/reference/GDALRaster-class.html

This is consistent with Rccp metadata for a class or object instance, e.g.,

str(ds)
Reference class 'Rcpp_GDALRaster' [package "gdalraster"] with 3 fields
 $ infoOptions  : chr(0) 
 $ quiet        : logi FALSE
 $ readByteAsRaw: logi FALSE
 and 75 methods, of which 61 are  possibly relevant:
   bbox, buildOverviews, clearStatistics, close, deleteNoDataValue, dim,
   fillRaster, finalize, flushCache, get_pixel_line, getActualBlockSize,
   getBlockSize, getChecksum, getColorTable, getDataTypeName,
   getDefaultHistogram, getDefaultRAT, getDescription, getDriverLongName,
   getDriverShortName, getFileList, getFilename, getGeoTransform, getHistogram,
   getMetadata, getMetadataDomainList, getMetadataItem, getMinMax,
   getNoDataValue, getOffset, getOverviewCount, getPaletteInterp,
   getProjection, getProjectionRef, getRasterColorInterp, getRasterCount,
   getRasterXSize, getRasterYSize, getScale, getStatistics, getUnitType, info,
   infoAsJSON, initialize, isOpen, open, read, res, setColorTable,
   setDefaultRAT, setDescription, setFilename, setGeoTransform,
   setMetadataItem, setNoDataValue, setOffset, setProjection,
   setRasterColorInterp, setScale, setUnitType, write

@ctoney ctoney closed this as completed May 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants