GeoEco.Datasets.ArcGIS.ArcGISWorkspace

class GeoEco.Datasets.ArcGIS.ArcGISWorkspace(path, datasetType, pathParsingExpressions=None, pathCreationExpressions=None, cacheTree=False, queryableAttributes=None, queryableAttributeValues=None, lazyPropertyValues=None, cacheDirectory=None)

Bases: DatasetCollectionTree, Database

A DatasetCollectionTree and Database representing an ArcGIS workspace, such as a geodatabase or file system directory.

Requires: ArcGIS Pro 3.2.0 or later or ArcGIS Server equivalent to ArcGIS Pro 3.2.0 or later.

Parameters:
  • path (str) – ArcGIS catalog path to the workspace. Minimum length꞉ 1. Must exist.

  • datasetType (object) – The class specifying the type of datasets to access in the workspace, either ArcGISTable or ArcGISRaster.

  • pathParsingExpressions (list of str, optional) –

    List of regular expressions used for finding datasets in the tree and parsing queryable attribute values from their paths. One expression per path level. Use Python Regular Expression Syntax.

    Queryable attributes are represented by “named groups” in the regular expressions. For example, if your collection is an ArcGIS geodatabase that contains feature classes and tables that you want to query by name, you could provide [r'(?P<TableName>.+)'] for this parameter. This defines a single path level (because the list has one element), which contains a single queryable attribute (because there is one named group), which is named TableName, which must be at least one character long (because .+ means “one or more characters”). Then, for queryableAttributes, provide (QueryableAttribute('TableName', 'Table name', UnicodeStringTypeMetadata()),). Finally, when calling QueryDatasets(), use an expression like "TableName = 'Foo'".

    Minimum length꞉ 1.

  • pathCreationExpressions (list of str, optional) – List of printf-style formatters used when importing datasets into this tree. Used to create destination path names from queryable attribute values. One formatter per path level. Minimum length꞉ 1.

  • cacheTree (bool, optional) – If True, the contents of the workspace will be cached when it is first accessed, to improve performance on future accesses. If False, the contents will be obtained each time the workspace is accessed.

  • queryableAttributes (tuple of QueryableAttribute, optional) – Queryable attributes defined for this object.

  • queryableAttributeValues (dict mapping str to object, optional) – Values of the queryable attributes, expressed as a dictionary mapping the case-insensitive names of queryable attributes to their values.

  • lazyPropertyValues (dict mapping str to object, 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 for caching local copies of remote datasets. Minimum length꞉ 1.

Returns:

ArcGISWorkspace instance.

Return type:

ArcGISWorkspace

Properties

property CacheDirectory

(str or None) 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 when Close() 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 CacheTree

(bool) If True, the contents of the workspace will be cached when it is first accessed, to improve performance on future accesses. If False, the contents will be obtained each time the workspace is accessed. Read only.

property DatasetType

(object) The class specifying the type of datasets to access in the workspace, either ArcGISTable or ArcGISRaster. Read only.

property DisplayName

(str) Informal name of this object, suitable to be displayed to the user. Read only. Minimum length꞉ 1.

property ParentCollection

(DatasetCollection or None) Parent DatasetCollection that this object is part of (if any). Read only.

property Path

(str) ArcGIS catalog path to the workspace. Read only. Minimum length꞉ 1. Must exist.

property PathCreationExpressions

(list of str or None) List of printf-style formatters used when importing datasets into this tree. Used to create destination path names from queryable attribute values. One formatter per path level. Read only. Minimum length꞉ 1.

property PathParsingExpressions

(list of str or None) List of regular expressions used for finding datasets in the tree and parsing queryable attribute values from their paths. One expression per path level. Use Python Regular Expression Syntax.

Queryable attributes are represented by “named groups” in the regular expressions. For example, if your collection is an ArcGIS geodatabase that contains feature classes and tables that you want to query by name, you could provide [r'(?P<TableName>.+)'] for this parameter. This defines a single path level (because the list has one element), which contains a single queryable attribute (because there is one named group), which is named TableName, which must be at least one character long (because .+ means “one or more characters”). Then, for queryableAttributes, provide (QueryableAttribute('TableName', 'Table name', UnicodeStringTypeMetadata()),). Finally, when calling QueryDatasets(), use an expression like "TableName = 'Foo'". Read only. Minimum length꞉ 1.

Methods

Close

Closes any open files or connections associated with this object and releases any other resources allocated to access it.

CreateTable

Creates a table.

CreateTableFromTemplate

Creates a table and adds to it the fields present another table (the template).

DeleteLazyPropertyValue

Deletes the lazy property with the specified name.

DeleteTable

Deletes a table.

GetAllQueryableAttributes

Returns a list of all queryable attributes.

GetLazyPropertyValue

Returns the value of the lazy property with the specified name.

GetNewestDataset

Queries the collection and returns the newest Dataset that matches the search expression.

GetOldestDataset

Queries the collection and returns the oldest Dataset that matches the search expression.

GetQueryableAttribute

Returns the queryable attribute with the specified name.

GetQueryableAttributeValue

Returns the value of the queryable attribute with the specified name.

GetQueryableAttributesWithDataType

Returns a list queryable attributes having the specified data type.

HasLazyPropertyValue

Returns True if the specified lazy property has a value.

ImportDatasets

Copies each Dataset in a list into this DatasetCollection.

ImportTable

Creates a new table from an existing Table, copying some or all of its fields and rows.

QueryDatasets

Queries the collection and returns a list of Datasets that match a search expression.

SetLazyPropertyValue

Sets the lazy property with the specified name to the specified value.

TableExists

Returns True if the specified table exists.

TestCapability

Tests whether a capability is supported by this class or an instance of it.