imagewriter¶
Contains functions used to write output files from applier.apply.
- rios.imagewriter.addAutoColorTable(filename, autoColorTableType)[source]¶
If autoColorTable has been set up for this output, then generate a color table of the requested type, and add it to the current file. This is called AFTER the Dataset has been closed, so is performed on the filename. This only applies to thematic layers, so when we open the file and find that the layers are athematic, we do nothing.
- rios.imagewriter.checkForNanOrInf(arr, filename)[source]¶
Check if the given array is float and contains any NaN or Inf elements. If any non-finite is found, then the filename is added to the global nanWarningFiles set.
If the array is not a float (or complex) dtype, then no check is done. If it is float (or complex), then numpy.isfinite is used to check all elements.
If the filename is already in nanWarningFiles, no further check is done.
- rios.imagewriter.closeOutfiles(gdalOutObjCache, outfiles, controls, singlePassMgr, timings)[source]¶
Close all the output files
- rios.imagewriter.deleteIfExisting(filename)[source]¶
Delete the filename if it already exists. If possible, use the appropriate GDAL driver to do so, to ensure that any associated files will also be deleted.
- rios.imagewriter.doubleCheckCreationOptions(drivername, creationoptions, controls, workinggrid)[source]¶
Try to ensure that the given creation options are compatible with RIOS operations. Does not attempt to ensure they are totally valid, as that is GDAL’s job.
If it finds any incompatibility, an exception is raised.
- rios.imagewriter.makeMinMaxList(singlePassMgr, symbolicName, seqNum)[source]¶
Make a list of min/max values per band, for the nominated output file, from values already present on singlePassMgr. Mimicing the list returned by addBasicStatsGDAL, for use with addHistogramsGDAL.
- rios.imagewriter.openOutfile(symbolicName, filename, controls, arr, workinggrid)[source]¶
Open the requested output file
- rios.imagewriter.setDefaultDriver()[source]¶
Sets some default values into global variables, defining what defaults we should use for GDAL driver. On any given output file these can be over-ridden, and can be over-ridden globally using the environment variables
$RIOS_DFLT_DRIVER
$RIOS_DFLT_DRIVEROPTIONS
$RIOS_DFLT_CREOPT_<drivername>
If RIOS_DFLT_DRIVER is set, then it should be a gdal short driver name. If RIOS_DFLT_DRIVEROPTIONS is set, it should be a space-separated list of driver creation options, e.g. “COMPRESS=LZW TILED=YES”, and should be appropriate for the selected GDAL driver. This can also be ‘None’ in which case an empty list of creation options is passed to the driver.
The same rules apply to the driver-specific creation options given using $RIOS_DFLT_CREOPT_<driver>. These options are a later paradigm, and are intended to supercede the previous generic driver defaults.
If not otherwise supplied, the default is to use the HFA driver, with compression.
The code here is more complex than desirable, because it copes with legacy behaviour in the absence of the environment variables, and in the absence of the driver-specific option variables.
- rios.imagewriter.warnNanOrInf(filename)[source]¶
Print a warning message if the given filename is a member of nanWarningFiles set. Clears the filename once the warning is printed.