GeoEco.Datasets.GDAL.GDALDataset
- class GeoEco.Datasets.GDAL.GDALDataset(path, updatable=False, decompressedFileToReturn=None, displayName=None, parentCollection=None, queryableAttributeValues=None, lazyPropertyValues=None, cacheDirectory=None)
Bases:
FileDatasetCollectionA 2D raster dataset represented as a
FileDatasetCollectionofGDALRasterBands.The Geospatial Data Abstraction Library (GDAL) is a free open-source library for accessing geospatial data in a variety of raster formats and vector formats through a common interface. The fundamental elements of GDAL’s raster object model are the
osgeo.gdal.Datasetandosgeo.gdal.Bandclasses, wrapped here byGDALDatasetandGDALRasterBand. Aosgeo.gdal.Datasetis an assembly of relatedosgeo.gdal.Bands, typically contained in the same file, and some information common to them all, such as their dimensions, coordinate system, spatial extent, and cell size.Note
The wrapper implemented here may not fully support all of GDAL’s formats. Also, although GDAL provides some support for bands having more than two dimensions and for accessing hierarchical data formats such as HDF and NetCDF, those capabilities are not supported by the wrapper implemented here. Separate GeoEco classes are provided for accessing HDF, NetCDF, and OPeNDAP datasets.
- Parameters:
path (
str) –Path to the file to open.
If there is no parent collection, this is the full path to the file. It will be opened as stand-alone collection.
If there is a parent collection, this path is relative to it. For example, if the parent collection is a
DirectoryTree, this path is relative to a leaf directory of theDirectoryTree. Often, the leaf directory will be the one containing the file, in which case the path provided here will simply be the name of the file.If the path points to compressed file, it will be decompressed automatically. If a cache directory is provided, it will be checked first for an existing decompressed file. If none is found the file will be decompressed there.
If the compressed file is an archive (e.g. .zip or .tar), you must also specify a decompressed file to return.
Minimum length꞉ 1.
updatable (
bool, optional) –Indicates whether the dataset should be opened in update mode, allowing the data within its bands to be changed.
GDAL does not allow all formats to be opened in update mode. For more about this, please see https://www.gdal.org/formats_list.html.
decompressedFileToReturn (
str, optional) –glob()expression that identifies the extracted file to open when the path points to an archive (e.g. a .zip or .tar file).This expression must select exactly one of the extracted files. Be sure to leave it as
Nonewhen the path does not point to an archive.Minimum length꞉ 1.
displayName (
str, optional) – Name for this dataset to be displayed to the user. If a display name is not provided, a generic one will be generated automatically. Minimum length꞉ 1.parentCollection (
DatasetCollection, optional) – ParentDatasetCollectionthat this object is part of (if any).queryableAttributeValues (
dictmappingstrtoobject, optional) – Values of the queryable attributes, expressed as a dictionary mapping the case-insensitive names of queryable attributes to their values.lazyPropertyValues (
dictmappingstrtoobject, optional) – Lazy properties to set when this object is constructed, expressed as a dictionary mapping the names of lazy properties to their values.cacheDirectory (
str, optional) –Directory to cache a copy of the downloaded or decompressed file.
If provided, this directory will be checked for the file prior to download or decompression. If the file is found, the download and decompression will be skipped. Thus, when performing repetitive processing with remote or compressed datasets, you can speed up processing considerably by providing a cache directory.
Minimum length꞉ 1.
- Returns:
GDALDatasetinstance.- Return type:
Properties
- property CacheDirectory
(
strorNone) Directory for caching local copies of remote datasets. Minimum length꞉ 1. If a cache directory is not provided, then after a remote dataset is downloaded it will be kept either only in memory or in a temporary directory on disk, depending on the type of data it is. The temporary directory will be automatically deleted whenClose()is called.If a cache directory is provided, remote datasets will be stored in it when they are downloaded. Before a download is attempted, the cache directory will be checked first for the relevant dataset, and if it is found, the download will be skipped, speeding up execution.
The datasets are organized in the cache directory in an undocumented format that is specific to the collection. Once a dataset is stored in the cache directory, it is never changed or deleted. If the original remote datasets are changed, these changes will not be detected and the cache will not be updated. If the disk fills up, cached datasets will not be automatically deleted to mitigate the problem.
If you determine that the cached datasets are obsolete or the disk is too full, delete the entire cache directory. You may also be able to delete a portion of it, if you can reverse engineer how datasets are stored within it, but the organizational structure is not documented.
- property DecompressedFileToReturn
(
strorNone)glob()expression that identifies the extracted file to open when the path points to an archive (e.g. a .zip or .tar file). Read only. Minimum length꞉ 1. This expression must select exactly one of the extracted files. Be sure to leave it asNonewhen the path does not point to an archive.
- property DisplayName
(
str) Informal name of this object, suitable to be displayed to the user. Read only. Minimum length꞉ 1.
- property IsUpdatable
(
bool) Indicates whether the dataset should be opened in update mode, allowing the data within its bands to be changed. Read only.
- property ParentCollection
(
DatasetCollectionorNone) ParentDatasetCollectionthat this object is part of (if any). Read only.
- property Path
(
str) Path to the file to open. Read only. Minimum length꞉ 1. If there is no parent collection, this is the full path to the file. It will be opened as stand-alone collection.If there is a parent collection, this path is relative to it. For example, if the parent collection is a
DirectoryTree, this path is relative to a leaf directory of theDirectoryTree. Often, the leaf directory will be the one containing the file, in which case the path provided here will simply be the name of the file.If the path points to compressed file, it will be decompressed automatically. If a cache directory is provided, it will be checked first for an existing decompressed file. If none is found the file will be decompressed there.
If the compressed file is an archive (e.g. .zip or .tar), you must also specify a decompressed file to return.
Methods
Closes any open files or connections associated with this object and releases any other resources allocated to access it.
Creates a GDAL raster dataset from a
Grid.Deletes the lazy property with the specified name.
Returns a list of all queryable attributes.
Returns the value of the lazy property with the specified name.
Queries the collection and returns the newest
Datasetthat matches the search expression.Queries the collection and returns the oldest
Datasetthat matches the search expression.Returns the queryable attribute with the specified name.
Returns the value of the queryable attribute with the specified name.
Returns a list queryable attributes having the specified data type.
Opens a GDAL dataset and returns a
GDALRasterBandfor the specified band.Returns True if the specified lazy property has a value.
Copies each
Datasetin alistinto thisDatasetCollection.Queries the collection and returns a
listofDatasets that match a search expression.Sets the lazy property with the specified name to the specified value.
Tests whether a capability is supported by this class or an instance of it.