GeoEco.Datasets.GDAL.GDALDataset.CreateRaster
- classmethod GDALDataset.CreateRaster(path, grid, overwriteExisting=False, **options)
Creates a GDAL raster dataset from a
Grid.This is a convenience function that is equivalent to:
from GeoEco.Datasets.Collections import DirectoryTree from GeoEco.Datasets.GDAL import GDALDataset dirTree = DirectoryTree(path=os.path.dirname(path), datasetType=GDALDataset, pathCreationExpressions=[os.path.basename(path)]) dirTree.ImportDatasets(datasets=[grid], mode='Replace' if overwriteExisting else 'Add', reportProgress=False, options=options)
- Parameters:
path (
str) – Path to the GDAL raster dataset to create. Minimum length꞉ 1.grid (
Grid) –Gridto write to the raster. It must be two dimensional.overwriteExisting (
bool, optional) – If True and path exists, it will be overwritten. If False and path exists, an error will be raised.options (
dictmappingstrtoobject) –Additional options, which can include:
blockSize(int) - Number of bytes to read at a time from the grid and write to the raster. The default is 32*1024*1024 bytes (32 MB).calculateStatistics(bool) - If True, statistics and a histogram will be calculated using GDAL and written along with the raster in the appropriate format. Depending on the raster’s format, the statistics and histogram may be present in the raster file itself, or a “sidecar” file with the extension.aux.xml.gdalCreateOptions(listofstr) - List of options to be passed toosgeo.gdal.Driver.Create()to create the raster.gdalDriverName(str) - GDAL driver name to use, to be passed toosgeo.gdal.GetDriverByName()to retrieve the driver.overviewResamplingMethod(str) and'overviewList'(listofint) - The resampling method and list of overview levels (decimation factors) to use to build overviews (known as “pyramids” in ArcGIS terminology) usingosgeo.gdal.Dataset.BuildOverviews(). Both must be specified.useArcGISSpatialReference(bool) - If True, the ArcGIS-compatible WKT string will be used when defining the raster’s spatial reference. Additionally, theFORCETOPESTRING=YEScreation option will be set if the output is ERDAS IMAGINE (.img) format.useUnscaledData(bool) - If True and grid has a scaling equation, the underlying unscaled data will be written out, rather than the scaled data that are normally of interest.