GRASS GIS logo

Note: A new GRASS GIS stable version has been released: GRASS GIS 7.4. Go directly to the new manual page here

temporal package

Submodules

temporal.abstract_dataset module

The abstract_dataset module provides the AbstractDataset class that is the base class for all map layer and Space Time Datasets.

(C) 2011-2013 by the GRASS Development Team This program is free software under the GNU General Public License (>=v2). Read the file COPYING that comes with GRASS for details.

authors:Soeren Gebbert
class temporal.abstract_dataset.AbstractDataset[source]

Bases: temporal.spatial_topology_dataset_connector.SpatialTopologyDatasetConnector, temporal.temporal_topology_dataset_connector.TemporalTopologyDatasetConnector

This is the base class for all datasets (raster, vector, raster3d, strds, stvds, str3ds)

check_relative_time_unit(unit)[source]

Check if unit is of type year(s), month(s), day(s), hour(s), minute(s) or second(s)

Parameters:unit – The unit string
Returns:True if success, False otherwise
delete()[source]

Delete dataset from database if it exists

get_absolute_time()[source]

Returns the start time, the end time of the map as tuple

The start time is of type datetime.

The end time is of type datetime in case of interval time, or None on case of a time instance.

Returns:A tuple of (start_time, end_time)
get_id()[source]

Return the unique identifier of the dataset :return: The id of the dataset “name(:layer)@mapset” as string

get_mapset()[source]

Return the mapset :return: The mapset in which the dataset was created as string

get_name()[source]

Return the name :return: The name of the dataset as string

get_new_instance(ident)[source]

Return a new instance with the type of this class

Parameters:ident – The identifier of the new dataset instance
Returns:A new instance with the type of this object
get_number_of_relations()[source]

Return a dictionary in which the keys are the relation names and the value are the number of relations.

The following relations are available:

Spatial relations:

  • equivalent
  • overlap
  • in
  • contain
  • meet
  • cover
  • covered

Temporal relations:

  • equal
  • follows
  • precedes
  • overlaps
  • overlapped
  • during (including starts, finishes)
  • contains (including started, finished)
  • starts
  • started
  • finishes
  • finished

To access topological information the spatial, temporal or booth topologies must be build first using the SpatioTemporalTopologyBuilder.

Returns:The dictionary with relations as keys and number as values or None in case the topology wasn’t build
get_relative_time()[source]

Returns the start time, the end time and the temporal unit of the dataset as tuple

The start time is of type integer.

The end time is of type integer in case of interval time, or None on case of a time instance.

Returns:A tuple of (start_time, end_time, unit)
get_relative_time_unit()[source]

Returns the relative time unit :return: The relative time unit as string, None if not present

get_spatial_extent()[source]

Return the spatial extent

get_spatial_extent_as_tuple()[source]

Return the spatial extent as tuple

Top and bottom are set to 0 in case of a two dimensional spatial extent.

Returns:A the spatial extent as tuple (north, south, east, west, top, bottom)
get_temporal_extent()[source]

Return the temporal extent of the correct internal type

get_temporal_extent_as_tuple()[source]

Returns a tuple of the valid start and end time

Start and end time can be either of type datetime or of type integer, depending on the temporal type.

Returns:A tuple of (start_time, end_time)
get_temporal_type()[source]

Return the temporal type of this dataset

The temporal type can be absolute or relative

Returns:The temporal type of the dataset as string
get_type()[source]

Return the type of this class as string

The type can be “vector”, “raster”, “raster3d”, “stvds”, “strds” or “str3ds”

Returns:“vector”, “raster”, “raster3d”, “stvds”, “strds” or “str3ds”
insert(dbif=None, execute=True)[source]

Insert dataset into database

Parameters:
  • dbif – The database interface to be used
  • execute – If True the SQL statements will be executed. If False the prepared SQL statements are returned and must be executed by the caller.
Returns:

The SQL insert statement in case execute=False, or an empty string otherwise

is_in_db(dbif=None)[source]

Check if the dataset is registered in the database

Parameters:dbif – The database interface to be used
Returns:True if the dataset is registered in the database
is_stds()[source]

Return True if this class is a space time dataset

Returns:True if this class is a space time dataset, False otherwise
is_time_absolute()[source]

Return True in case the temporal type is absolute

Returns:True if temporal type is absolute, False otherwise
is_time_relative()[source]

Return True in case the temporal type is relative

Returns:True if temporal type is relative, False otherwise
is_topology_build()[source]

Check if the spatial and temporal topology was build

Returns:A dictionary with “spatial” and “temporal” as keys that have boolen values
print_info()[source]

Print information about this class in human readable style

print_self()[source]

Print the content of the internal structure to stdout

print_shell_info()[source]

Print information about this class in shell style

print_topology_info()[source]
print_topology_shell_info()[source]
reset(ident)[source]

Reset the internal structure and set the identifier

This method creates the dataset specific internal objects that store the base information, the spatial and temporal extent and the metadata. It must be implemented in the dataset specific subclasses. This is the code for the vector dataset:

self.base = VectorBase(ident=ident)
self.absolute_time = VectorAbsoluteTime(ident=ident)
self.relative_time = VectorRelativeTime(ident=ident)
self.spatial_extent = VectorSpatialExtent(ident=ident)
self.metadata = VectorMetadata(ident=ident)
Parameters:ident – The identifier of the dataset that “name@mapset” or in case of vector maps “name:layer@mapset”
reset_topology()[source]

Reset any information about temporal topology

select(dbif=None)[source]

Select temporal dataset entry from database and fill the internal structure

The content of every dataset is stored in the temporal database. This method must be used to fill this object with the content from the temporal database.

Parameters:dbif – The database interface to be used
set_id(ident)[source]

Set the identifier of the dataset

set_topology_build_false()[source]

Use this method when the spatio-temporal topology was not build

set_topology_build_true()[source]

Use this method when the spatio-temporal topology was build

spatial_disjoint_union(dataset)[source]

Return the spatial union as spatial_extent object.

Parameters:dataset – The abstract dataset to create a union with
Returns:The union spatial extent
spatial_intersection(dataset)[source]

Return the spatial intersection as spatial_extent object or None in case no intersection was found.

Parameters:dataset – The abstract dataset to intersect with
Returns:The intersection spatial extent
spatial_overlapping(dataset)[source]

Return True if the spatial extents overlap

Parameters:dataset – The abstract dataset to check spatial overlapping
Returns:True if self and the provided dataset spatial overlap
spatial_relation(dataset)[source]

Return the spatial relationship between self and dataset

Parameters:dataset – The abstract dataset to compute the spatial relation with self
Returns:The spatial relationship as string
spatial_union(dataset)[source]

Return the spatial union as spatial_extent object or None in case the extents does not overlap or meet.

Parameters:dataset – The abstract dataset to create a union with
Returns:The union spatial extent
temporal_disjoint_union(dataset)[source]

Creates a union with the provided dataset and return a new temporal extent with the new start and end time.

Parameters:dataset – The abstract dataset to create temporal union with
Returns:The new temporal extent with start and end time
temporal_extent

Return the temporal extent of the correct internal type

temporal_intersection(dataset)[source]

Intersect self with the provided dataset and return a new temporal extent with the new start and end time

Parameters:dataset – The abstract dataset to temporal intersect with
Returns:The new temporal extent with start and end time, or None in case of no intersection
temporal_relation(dataset)[source]

Return the temporal relation of self and the provided dataset

Returns:The temporal relation as string
temporal_union(dataset)[source]

Creates a union with the provided dataset and return a new temporal extent with the new start and end time.

Parameters:dataset – The abstract dataset to create temporal union with
Returns:The new temporal extent with start and end time, or None in case of no intersection
update(dbif=None, execute=True, ident=None)[source]

Update the dataset entry in the database from the internal structure excluding None variables

Parameters:
  • dbif – The database interface to be used
  • execute – If True the SQL statements will be executed. If False the prepared SQL statements are returned and must be executed by the caller.
  • ident – The identifier to be updated, useful for renaming
Returns:

The SQL update statement in case execute=False, or an empty string otherwise

update_all(dbif=None, execute=True, ident=None)[source]

Update the dataset entry in the database from the internal structure and include None variables.

Parameters:
  • dbif – The database interface to be used
  • execute – If True the SQL statements will be executed. If False the prepared SQL statements are returned and must be executed by the caller.
  • ident – The identifier to be updated, useful for renaming
Returns:

The SQL update statement in case execute=False, or an empty string otherwise

class temporal.abstract_dataset.AbstractDatasetComparisonKeyEndTime(obj, *args)[source]

Bases: object

This comparison key can be used to sort lists of abstract datasets by end time

Example:

# Return all maps in a space time raster dataset as map objects
map_list = strds.get_registered_maps_as_objects()

# Sort the maps in the list by end time
sorted_map_list = sorted(map_list, key=AbstractDatasetComparisonKeyEndTime)
class temporal.abstract_dataset.AbstractDatasetComparisonKeyStartTime(obj, *args)[source]

Bases: object

This comparison key can be used to sort lists of abstract datasets by start time

Example:

# Return all maps in a space time raster dataset as map objects
map_list = strds.get_registered_maps_as_objects()

# Sort the maps in the list by start time
sorted_map_list = sorted(map_list, key=AbstractDatasetComparisonKeyStartTime)

temporal.abstract_map_dataset module

The abstract_map_dataset module provides the AbstractMapDataset class that is the base class for all map layer.

(C) 2011-2013 by the GRASS Development Team This program is free software under the GNU General Public License (>=v2). Read the file COPYING that comes with GRASS for details.

authors:Soeren Gebbert
class temporal.abstract_map_dataset.AbstractMapDataset[source]

Bases: temporal.abstract_dataset.AbstractDataset

This is the base class for all maps (raster, vector, raster3d).

The temporal extent, the spatial extent and the metadata of maps are stored in the temporal database. Maps can be registered in the temporal database, updated and deleted.

This class provides all functionalities that are needed to manage maps in the temporal database. That are:

  • insert() to register the map and therefore its spatio-temporal extent and metadata in the temporal database
  • update() to update the map spatio-temporal extent and metadata in the temporal database
  • unregister() to unregister the map from each space time dataset in which this map is registered
  • delete() to remove the map from the temporal database
  • Methods to set relative and absolute time stamps
  • Abstract methods that must be implemented in the map specific subclasses
add_stds_to_register(stds_id, dbif=None, execute=True)[source]

Add a new space time dataset to the register

Parameters:
  • stds_id – The id of the space time dataset to be registered
  • dbif – The database interface to be used
  • execute – If True the SQL INSERT table statements will be executed. If False the prepared SQL statements are returned and must be executed by the caller.
Returns:

The SQL statements if execute=False, else an empty string

static build_id(name, mapset, layer=None)[source]

Convenient method to build the unique identifier

Existing layer and mapset definitions in the name string will be reused

Parameters:
  • name – The name of the map
  • mapset – The mapset in which the map is located
  • layer – The layer of the vector map, use None in case no layer exists
Returns:

the id of the map as “name(:layer)@mapset” while layer is optional

check_for_correct_time()[source]

Check for correct time

check_resolution_with_current_region()[source]

Check if the raster or voxel resolution is finer than the current resolution

  • Return “finer” in case the raster/voxel resolution is finer than the current region
  • Return “coarser” in case the raster/voxel resolution is coarser than the current region

Vector maps have no resolution, since they store the coordinates directly.

Returns:“finer” or “coarser”
delete(dbif=None, update=True, execute=True)[source]

Delete a map entry from database if it exists

Remove dependent entries:

  • Remove the map entry in each space time dataset in which this map is registered
  • Remove the space time dataset register table
Parameters:
  • dbif – The database interface to be used
  • update – Call for each unregister statement the update from registered maps of the space time dataset. This can slow down the un-registration process significantly.
  • execute – If True the SQL DELETE and DROP table statements will be executed. If False the prepared SQL statements are returned and must be executed by the caller.
Returns:

The SQL statements if execute=False, else an empty string, None in case of a failure

get_layer()[source]

Return the layer of the map

Returns:the layer of the map or None in case no layer is defined
get_map_id()[source]

Return the map id. The map id is the unique identifier in grass and must not be equal to the primary key identifier (id) of the map in the database. Since vector maps may have layer information, the unique id is a combination of name, layer and mapset.

Use get_map_id() every time your need to access the grass map in the file system but not to identify map information in the temporal database.

Returns:The map id “name@mapset
get_new_stds_instance(ident)[source]

Return a new space time dataset instance that store maps with the type of this map object (raster, raster_3d or vector)

:param ident The identifier of the space time dataset :return: The new space time dataset instance

get_registered_stds(dbif=None)[source]

Return all space time dataset ids in which this map is registered as as a list of strings, or None if this map is not registered in any space time dataset.

Parameters:dbif – The database interface to be used
Returns:A list of ids of all space time datasets in which this map is registered
has_grass_timestamp()[source]

Check if a grass file based time stamp exists for this map.

Returns:True is the grass file based time stamped exists for this map
insert(dbif=None, execute=True)[source]

Insert the map content into the database from the internal structure

This functions assures that the timestamp is written to the grass file system based database in addition to the temporal database entry. The stds register table will be created as well. Hence maps can only be registered in a space time dataset, when they were inserted in the temporal database beforehand.

Parameters:
  • dbif – The database interface to be used
  • execute – If True the SQL statements will be executed. If False the prepared SQL statements are returned and must be executed by the caller.
Returns:

The SQL insert statement in case execute=False, or an empty string otherwise

load()[source]

Load the content of this object from the grass file system based database

map_exists()[source]

Return True in case the map exists in the grass spatial database

Returns:True if map exists, False otherwise
print_info()[source]

Print information about this object in human readable style

print_self()[source]

Print the content of the internal structure to stdout

print_shell_info()[source]

Print information about this object in shell style

read_timestamp_from_grass()[source]

Read the timestamp of this map from the map metadata in the grass file system based spatial database and set the internal time stamp that should be insert/updated in the temporal database.

remove_stds_from_register(stds_id, dbif=None, execute=True)[source]

Remove a space time dataset from the register

Parameters:
  • stds_id – The id of the space time dataset to removed from the registered
  • dbif – The database interface to be used
  • execute – If True the SQL INSERT table statements will be executed. If False the prepared SQL statements are returned and must be executed by the caller.
Returns:

The SQL statements if execute=False, else an empty string

remove_timestamp_from_grass()[source]

Remove the timestamp from the grass file system based spatial database

set_absolute_time(start_time, end_time=None)[source]

Set the absolute time with start time and end time

The end time is optional and must be set to None in case of time instance.

This method only modifies this object and does not commit the modifications to the temporal database.

Parameters:
  • start_time – A datetime object specifying the start time of the map
  • end_time – A datetime object specifying the end time of the map, None in case or time instance
Returns:

True for success and False otherwise

set_relative_time(start_time, end_time, unit)[source]

Set the relative time interval

The end time is optional and must be set to None in case of time instance.

This method only modifies this object and does not commit the modifications to the temporal database.

Parameters:
  • start_time – An integer value
  • end_time – An integer value, None in case or time instance
  • unit – The unit of the relative time. Supported units: year(s), month(s), day(s), hour(s), minute(s), second(s)
Returns:

True for success and False otherwise

set_spatial_extent(spatial_extent)[source]

Set the spatial extent of the map

This method only modifies this object and does not commit the modifications to the temporal database.

param spatial_extent:
 An object of type SpatialExtent or its subclasses
set_spatial_extent_from_values(north, south, east, west, top=0, bottom=0)[source]

Set the spatial extent of the map from values

This method only modifies this object and does not commit the modifications to the temporal database.
Parameters:
  • north – The northern edge
  • south – The southern edge
  • east – The eastern edge
  • west – The western edge
  • top – The top edge
  • bottom – The bottom edge
set_temporal_extent(extent)[source]

Convenient method to set the temporal extent from a temporal extent object

Parameters:temporal_extent – The temporal extent that should be set for this object
set_time_to_absolute()[source]

Set the temporal type to absolute

set_time_to_relative()[source]

Set the temporal type to relative

spatial_buffer(size, update=False, dbif=None)[source]

Buffer the spatial extent by a given size in all spatial directions.

Parameters:size – The buffer size, using the unit of the grass region
spatial_buffer_2d(size, update=False, dbif=None)[source]

Buffer the spatial extent by a given size in 2d spatial directions.

Parameters:size – The buffer size, using the unit of the grass region
temporal_buffer(increment, update=False, dbif=None)[source]

Create a temporal buffer based on an increment

For absolute time the increment must be a string of type “integer unit” Unit can be year, years, month, months, day, days, hour, hours, minute, minutes, day or days.

Parameters:
  • increment – This is the increment, a string in case of absolute time or an integer in case of relative time
  • update – Perform an immediate database update to store the modified temporal extent, otherwise only this object will be modified

Usage:

unregister(dbif=None, update=True, execute=True)[source]

Remove the map entry in each space time dataset in which this map is registered

Parameters:
  • dbif – The database interface to be used
  • update – Call for each unregister statement the update from registered maps of the space time dataset. This can slow down the un-registration process significantly.
  • execute – If True the SQL DELETE and DROP table statements will be executed. If False the prepared SQL statements are returned and must be executed by the caller.
Returns:

The SQL statements if execute=False, else an empty string

update(dbif=None, execute=True)[source]

Update the map content in the database from the internal structure excluding None variables

This functions assures that the timestamp is written to the grass file system based database in addition to the temporal database entry.

Parameters:
  • dbif – The database interface to be used
  • execute – If True the SQL statements will be executed. If False the prepared SQL statements are returned and must be executed by the caller.
Returns:

The SQL insert statement in case execute=False, or an empty string otherwise

update_absolute_time(start_time, end_time=None, dbif=None)[source]

Update the absolute time

The end time is optional and must be set to None in case of time instance.

This functions assures that the timestamp is written to the grass file system based database in addition to the temporal database entry.

Parameters:
  • start_time – A datetime object specifying the start time of the map
  • end_time – A datetime object specifying the end time of the map, None in case or time instance
  • dbif – The database interface to be used
update_all(dbif=None, execute=True)[source]

Update the map content in the database from the internal structure including None variables

This functions assures that the timestamp is written to the grass file system based database in addition to the temporal database entry.

Parameters:
  • dbif – The database interface to be used
  • execute – If True the SQL statements will be executed. If False the prepared SQL statements are returned and must be executed by the caller.
Returns:

The SQL insert statement in case execute=False, or an empty string otherwise

update_relative_time(start_time, end_time, unit, dbif=None)[source]

Update the relative time interval

The end time is optional and must be set to None in case of time instance.

This functions assures that the timestamp is written to the grass file system based database in addition to the temporal database entry.

Parameters:
  • start_time – An integer value
  • end_time – An integer value, None in case or time instance
  • unit – The relative time unit
  • dbif – The database interface to be used
write_timestamp_to_grass()[source]

Write the timestamp of this map into the map metadata in the grass file system based spatial database.

temporal.abstract_space_time_dataset module

The abstract_space_time_dataset module provides the AbstractSpaceTimeDataset class that is the base class for all space time datasets.

(C) 2011-2013 by the GRASS Development Team This program is free software under the GNU General Public License (>=v2). Read the file COPYING that comes with GRASS for details.

authors:Soeren Gebbert
class temporal.abstract_space_time_dataset.AbstractSpaceTimeDataset(ident)[source]

Bases: temporal.abstract_dataset.AbstractDataset

Abstract space time dataset class

Base class for all space time datasets.

This class represents an abstract space time dataset. Convenient functions to select, update, insert or delete objects of this type in the SQL temporal database exists as well as functions to register or unregister raster maps.

Parts of the temporal logic are implemented in the SQL temporal database, like the computation of the temporal and spatial extent as well as the collecting of metadata.

check_temporal_topology(maps=None, dbif=None)[source]

Check the temporal topology of all maps of the current space time dataset or of an optional list of maps

Correct topology means, that time intervals are not overlap or that intervals does not contain other intervals. Equal time intervals are not allowed.

The optional map list must be ordered by start time

Allowed and not allowed temporal relationships for correct topology:

  • after -> allowed
  • precedes -> allowed
  • follows -> allowed
  • precedes -> allowed
  • equal -> not allowed
  • during -> not allowed
  • contains -> not allowed
  • overlaps -> not allowed
  • overlapped -> not allowed
  • starts -> not allowed
  • finishes -> not allowed
  • started -> not allowed
  • finished -> not allowed
Parameters:
  • maps – An optional list of AbstractDataset objects, in case of None all maps of the space time dataset are checked
  • dbif – The database interface to be used
Returns:

True if topology is correct

count_gaps(maps=None, dbif=None)[source]

Count the number of gaps between temporal neighbors

Parameters:
  • maps – A sorted (start_time) list of AbstractDataset objects
  • dbif – The database interface to be used
Returns:

The numbers of gaps between temporal neighbors

count_temporal_relations(maps=None, dbif=None)[source]

Count the temporal relations between the registered maps.

The map list must be ordered by start time. Temporal relations are counted by analysing the sparse upper right side temporal relationships matrix.

Parameters:
  • maps – A sorted (start_time) list of AbstractDataset objects
  • dbif – The database interface to be used
Returns:

A dictionary with counted temporal relationships

count_temporal_types(maps=None, dbif=None)[source]

Return the temporal type of the registered maps as dictionary

The map list must be ordered by start time

The temporal type can be:

  • point -> only the start time is present
  • interval -> start and end time
  • invalid -> No valid time point or interval found
Parameters:
  • maps – A sorted (start_time) list of AbstractDataset objects
  • dbif – The database interface to be used
create_command_string()[source]

Create the command string that was used to create this space time dataset.

The command string should be set with self.metadata.set_command()

Returns:The command string
create_map_register_name()[source]

Create the name of the map register table of this space time dataset

A uuid and the map type are used to create the table name

ATTENTION: It must be assured that the base object has selected its content from the database.

Returns:The name of the map register table
delete(dbif=None, execute=True)[source]

Delete a space time dataset from the temporal database

This method removes the space time dataset from the temporal database and drops its map register table

Parameters:
  • dbif – The database interface to be used
  • execute – If True the SQL DELETE and DROP table statements will be executed. If False the prepared SQL statements are returned and must be executed by the caller.
Returns:

The SQL statements if execute == False, else an empty string

get_granularity()[source]

Return the granularity of the space time dataset

Granularity can be of absolute time or relative time. In case of absolute time a string containing an integer value and the time unit (years, months, days, hours, minuts, seconds). In case of relative time an integer value is expected.

Returns:The granularity
get_initial_values()[source]

Return the initial values: temporal_type, semantic_type, title, description

get_map_register()[source]

Return the name of the map register table :return: The map register table name

get_map_time()[source]

Return the type of the map time, interval, point, mixed or invalid

get_new_map_instance(ident=None)[source]

Return a new instance of a map which is associated with the type of this object

Parameters:ident – The unique identifier of the new object
get_registered_maps(columns=None, where=None, order=None, dbif=None)[source]

Return SQL rows of all registered maps.

In case columns are not specified, each row includes all columns specified in the datatype specific view.

Parameters:
  • columns – Columns to be selected as SQL compliant string
  • where – The SQL where statement to select a subset of the registered maps without “WHERE”
  • order – The SQL order statement to be used to order the objects in the list without “ORDER BY”
  • dbif – The database interface to be used
Returns:

SQL rows of all registered maps, In case nothing found None is returned

get_registered_maps_as_objects(where=None, order='start_time', dbif=None)[source]

Return all or a subset of the registered maps as ordered object list for spatio-temporal topological operations that require the spatio-temporal extent only

The objects are initialized with their id’s‘ and the spatio-temporal extent (temporal type, start time, end time, west, east, south, north, bottom and top). In case more map information are needed, use the select() method for each listed object.

Parameters:
  • where – The SQL where statement to select a subset of the registered maps without “WHERE”
  • order – The SQL order statement to be used to order the objects in the list without “ORDER BY”
  • dbif – The database interface to be used
Returns:

The ordered map object list, In case nothing found None is returned

get_registered_maps_as_objects_by_granularity(gran=None, dbif=None)[source]

Return all registered maps as ordered (by start_time) object list with “gap” map objects (id==None) for spatio-temporal topological operations that require the temporal extent only.

Each list entry is a list of AbstractMapDatasets objects which are potentially equal the actual granule, contain the actual granule or are located in the actual granule. Hence for each granule a list of AbstractMapDatasets can be expected.

Maps that overlap the granule are ignored.

The granularity of the space time dataset is used as increment in case the granule is not user defined.

A valid temporal topology (no overlapping or inclusion allowed) is needed to get correct results.

Space time datasets with interval time, time instances and mixed time are supported.

Gaps between maps are identified as unregistered maps with id==None.

The objects are initialized with their id’s‘ and the spatio-temporal extent (temporal type, start time, end time, west, east, south, north, bottom and top). In case more map information are needed, use the select() method for each listed object.

Parameters:
  • gran – The granularity string to be used, if None the granularity of the space time dataset is used. Absolute time has the format “number unit”, relative time has the format “number”. The unit in case of absolute time can be one of “second, seconds, minute, minutes, hour, hours, day, days, week, weeks, month, months, year, years”. The unit of the relative time granule is always the space time dataset unit and can not be changed.
  • dbif – The database interface to be used
Returns:

ordered list of map lists. Each list represents a single granule, or None in case nothing found

get_registered_maps_as_objects_with_gaps(where=None, dbif=None)[source]

Return all or a subset of the registered maps as ordered (by start_time) object list with “gap” map objects (id==None) for spatio-temporal topological operations that require the spatio-temporal extent only.

Gaps between maps are identified as maps with id==None

The objects are initialized with their id’s‘ and the spatio-temporal extent (temporal type, start time, end time, west, east, south, north, bottom and top). In case more map information are needed, use the select() method for each listed object.

Parameters:
  • where – The SQL where statement to select a subset of the registered maps without “WHERE”
  • dbif – The database interface to be used
Returns:

ordered object list, in case nothing found None is returned

get_registered_maps_as_objects_with_temporal_topology(where=None, order='start_time', dbif=None)[source]

Return all or a subset of the registered maps as ordered object list with spatio-temporal topological relationship information.

The objects are initialized with their id’s‘ and the spatio-temporal extent (temporal type, start time, end time, west, east, south, north, bottom and top). In case more map information are needed, use the select() method for each listed object.

Parameters:
  • where – The SQL where statement to select a subset of the registered maps without “WHERE”
  • order – The SQL order statement to be used to order the objects in the list without “ORDER BY”
  • dbif – The database interface to be used
Returns:

The ordered map object list, In case nothing found None is returned

get_semantic_type()[source]

Return the semantic type of this dataset :return: The semantic type

insert(dbif=None, execute=True)[source]

Insert the space time dataset content into the database from the internal structure

The map register table will be created, so that maps can be registered.

Parameters:
  • dbif – The database interface to be used
  • execute – If True the SQL statements will be executed. If False the prepared SQL statements are returned and must be executed by the caller.
Returns:

The SQL insert statement in case execute=False, or an empty string otherwise

is_map_registered(map_id, dbif=None)[source]

Check if a map is registered in the space time dataset

Parameters:
  • map_id – The map id
  • dbif – The database interface to be used
Returns:

True if success, False otherwise

print_history()[source]

Print history information about this class in human readable shell style

print_info()[source]

Print information about this class in human readable style

print_self()[source]

Print the content of the internal structure to stdout

print_shell_info()[source]

Print information about this class in shell style

print_spatio_temporal_relationships(maps=None, spatial=None, dbif=None)[source]

Print the spatio-temporal relationships for each map of the space time dataset or for each map of the optional list of maps

Parameters:
  • maps – a ordered by start_time list of map objects, if None the registered maps of the space time dataset are used
  • spatial – This indicates if the spatial topology is created as well: spatial can be None (no spatial topology), “2D” using west, east, south, north or “3D” using west, east, south, north, bottom, top
  • dbif – The database interface to be used
register_map(map, dbif=None)[source]

Register a map in the space time dataset.

This method takes care of the registration of a map in a space time dataset.

In case the map is already registered this function will break with a warning and return False.

This method raises a FatalError exception in case of a fatal error

Parameters:
  • map – The AbstractMapDataset object that should be registered
  • dbif – The database interface to be used
Returns:

True if success, False otherwise

rename(ident, dbif=None)[source]

Rename the space time dataset

This method renames the space time dataset, the map register table and updates the entries in registered maps stds register.

Renaming does not work with Postgresql yet.

Parameters:
  • ident – The new identifier “name@mapset
  • dbif – The database interface to be used
static resample_maplist_by_granularity(maps, start, end, gran)[source]

Resample a list of AbstractMapDatasets by a given granularity

The provided map list must be sorted by start time. A valid temporal topology (no overlapping or inclusion allowed) is needed to receive correct results.

Maps with interval time, time instances and mixed time are supported.

The temporal topology search order is as follows:

  1. Maps that are equal to the actual granule are used
  2. If no euqal found then maps that contain the actual granule are used
  3. If no maps are found that contain the actual granule then maps are used that overlaps the actual granule
  4. If no overlaps maps found then overlapped maps are used
  5. If no overlapped maps are found then maps are used that are durin the actual granule

Each entry in the resulting list is a list of AbstractMapDatasets objects. Hence for each granule a list of AbstractMapDatasets can be expected.

Gaps between maps are identified as unregistered maps with id==None.

Parameters:
  • maps – An ordered list (by start time) of AbstractMapDatasets objects. All maps must have the same temporal type and the same unit in case of relative time.
  • start – The start time of the provided map list
  • end – The end time of the provided map list
  • gran – The granularity string to be used, if None the granularity of the space time dataset is used. Absolute time has the format “number unit”, relative time has the format “number”. The unit in case of absolute time can be one of “second, seconds, minute, minutes, hour, hours, day, days, week, weeks, month, months, year, years”. The unit of the relative time granule is always the space time dataset unit and can not be changed.
Returns:

ordered list of map lists. Each list represents a single granule, or None in case nothing found

Usage:

>>> import grass.temporal as tgis
>>> maps = []
>>> for i in xrange(3):
...     map = tgis.RasterDataset("map%i@PERMANENT"%i)
...     check = map.set_relative_time(i + 2, i + 3, "days")
...     maps.append(map)
>>> grans = tgis.AbstractSpaceTimeDataset.resample_maplist_by_granularity(maps,0,8,1)
>>> for map_list in grans:
...    print(map_list[0].get_id(), map_list[0].get_temporal_extent_as_tuple())
None (0, 1)
None (1, 2)
map0@PERMANENT (2, 3)
map1@PERMANENT (3, 4)
map2@PERMANENT (4, 5)
None (5, 6)
None (6, 7)
None (7, 8)

>>> maps = []
>>> map1 = tgis.RasterDataset("map1@PERMANENT")
>>> check = map1.set_relative_time(2, 6, "days")
>>> maps.append(map1)
>>> map2 = tgis.RasterDataset("map2@PERMANENT")
>>> check = map2.set_relative_time(7, 13, "days")
>>> maps.append(map2)
>>> grans = tgis.AbstractSpaceTimeDataset.resample_maplist_by_granularity(maps,0,16,2)
>>> for map_list in grans:
...    print(map_list[0].get_id(), map_list[0].get_temporal_extent_as_tuple())
None (0, 2)
map1@PERMANENT (2, 4)
map1@PERMANENT (4, 6)
map2@PERMANENT (6, 8)
map2@PERMANENT (8, 10)
map2@PERMANENT (10, 12)
map2@PERMANENT (12, 14)
None (14, 16)

>>> maps = []
>>> map1 = tgis.RasterDataset("map1@PERMANENT")
>>> check = map1.set_relative_time(2, None, "days")
>>> maps.append(map1)
>>> map2 = tgis.RasterDataset("map2@PERMANENT")
>>> check = map2.set_relative_time(7, None, "days")
>>> maps.append(map2)
>>> grans = tgis.AbstractSpaceTimeDataset.resample_maplist_by_granularity(maps,0,16,2)
>>> for map_list in grans:
...    print(map_list[0].get_id(), map_list[0].get_temporal_extent_as_tuple())
None (0, 2)
map1@PERMANENT (2, 4)
None (4, 6)
map2@PERMANENT (6, 8)
None (8, 10)
None (10, 12)
None (12, 14)
None (14, 16)

>>> maps = []
>>> map1 = tgis.RasterDataset("map1@PERMANENT")
>>> check = map1.set_absolute_time(datetime(2000, 4,1), datetime(2000, 6, 1))
>>> maps.append(map1)
>>> map2 = tgis.RasterDataset("map2@PERMANENT")
>>> check = map2.set_absolute_time(datetime(2000, 8,1), datetime(2000, 12, 1))
>>> maps.append(map2)
>>> grans = tgis.AbstractSpaceTimeDataset.resample_maplist_by_granularity(maps,datetime(2000,1,1),datetime(2001,4,1),"1 month")
>>> for map_list in grans:
...    print(map_list[0].get_id(), map_list[0].get_temporal_extent_as_tuple())
None (datetime.datetime(2000, 1, 1, 0, 0), datetime.datetime(2000, 2, 1, 0, 0))
None (datetime.datetime(2000, 2, 1, 0, 0), datetime.datetime(2000, 3, 1, 0, 0))
None (datetime.datetime(2000, 3, 1, 0, 0), datetime.datetime(2000, 4, 1, 0, 0))
map1@PERMANENT (datetime.datetime(2000, 4, 1, 0, 0), datetime.datetime(2000, 5, 1, 0, 0))
map1@PERMANENT (datetime.datetime(2000, 5, 1, 0, 0), datetime.datetime(2000, 6, 1, 0, 0))
None (datetime.datetime(2000, 6, 1, 0, 0), datetime.datetime(2000, 7, 1, 0, 0))
None (datetime.datetime(2000, 7, 1, 0, 0), datetime.datetime(2000, 8, 1, 0, 0))
map2@PERMANENT (datetime.datetime(2000, 8, 1, 0, 0), datetime.datetime(2000, 9, 1, 0, 0))
map2@PERMANENT (datetime.datetime(2000, 9, 1, 0, 0), datetime.datetime(2000, 10, 1, 0, 0))
map2@PERMANENT (datetime.datetime(2000, 10, 1, 0, 0), datetime.datetime(2000, 11, 1, 0, 0))
map2@PERMANENT (datetime.datetime(2000, 11, 1, 0, 0), datetime.datetime(2000, 12, 1, 0, 0))
None (datetime.datetime(2000, 12, 1, 0, 0), datetime.datetime(2001, 1, 1, 0, 0))
None (datetime.datetime(2001, 1, 1, 0, 0), datetime.datetime(2001, 2, 1, 0, 0))
None (datetime.datetime(2001, 2, 1, 0, 0), datetime.datetime(2001, 3, 1, 0, 0))
None (datetime.datetime(2001, 3, 1, 0, 0), datetime.datetime(2001, 4, 1, 0, 0))
sample_by_dataset(stds, method=None, spatial=False, dbif=None)[source]

Sample this space time dataset with the temporal topology of a second space time dataset

In case spatial is True, the spatial overlap between temporal related maps is performed. Only temporal related and spatial overlapping maps are returned.

Return all registered maps as ordered (by start_time) object list. Each list entry is a list of map objects which are potentially located in temporal relation to the actual granule of the second space time dataset.

Each entry in the object list is a dict. The actual sampler map and its temporal extent (the actual granule) and the list of samples are stored:

list = self.sample_by_dataset(stds=sampler, method=[
    "during","overlap","contains","equal"])
for entry in list:
    granule = entry["granule"]
    maplist = entry["samples"]
    for map in maplist:
        map.select()
        map.print_info()

A valid temporal topology (no overlapping or inclusion allowed) is needed to get correct results in case of gaps in the sample dataset.

Gaps between maps are identified as unregistered maps with id==None.

The objects are initialized with their id’s‘ and the spatio-temporal extent (temporal type, start time, end time, west, east, south, north, bottom and top). In case more map information are needed, use the select() method for each listed object.

Parameters:
  • stds – The space time dataset to be used for temporal sampling
  • method
    This option specifies what sample method should be
    used. In case the registered maps are of temporal point type, only the start time is used for sampling. In case of mixed of interval data the user can chose between:
    • Example [“start”, “during”, “equals”]
    • start: Select maps of which the start time is located in the selection granule:
      map    :        s
      granule:  s-----------------e
      
      map    :        s--------------------e
      granule:  s-----------------e
      
      map    :        s--------e
      granule:  s-----------------e
      
    • contains: Select maps which are temporal
      during the selection granule:
      map    :     s-----------e
      granule:  s-----------------e
      
    • overlap: Select maps which temporal overlap the selection granule, this includes overlaps and overlapped:
      map    :     s-----------e
      granule:        s-----------------e
      
      map    :     s-----------e
      granule:  s----------e
      
    • during: Select maps which temporally contains the selection granule:
      map    :  s-----------------e
      granule:     s-----------e
      
    • equals: Select maps which temporally equal to the selection granule:
      map    :  s-----------e
      granule:  s-----------e
      
    • follows: Select maps which temporally follow the selection granule:
      map    :              s-----------e
      granule:  s-----------e
      
    • precedes: Select maps which temporally precedes the selection granule:
      map    :  s-----------e
      granule:              s-----------e
      

    All these methods can be combined. Method must be of type tuple including the identification strings.

  • spatial – If set True additional the 2d spatial overlapping is used for selection -> spatio-temporal relation. The returned map objects will have temporal and spatial extents
  • dbif – The database interface to be used
Returns:

A list of lists of map objects or None in case nothing was found None

sample_by_dataset_sql(stds, method=None, spatial=False, dbif=None)[source]

Sample this space time dataset with the temporal topology of a second space time dataset using SQL queries.

This function is very slow for huge large space time datasets but can run several times in the same process without problems.

The sample dataset must have “interval” as temporal map type, so all sample maps have valid interval time.

In case spatial is True, the spatial overlap between temporal related maps is performed. Only temporal related and spatial overlapping maps are returned.

Return all registered maps as ordered (by start_time) object list with “gap” map objects (id==None). Each list entry is a list of map objects which are potentially located in temporal relation to the actual granule of the second space time dataset.

Each entry in the object list is a dict. The actual sampler map and its temporal extent (the actual granule) and the list of samples are stored:

list = self.sample_by_dataset(stds=sampler, method=[
    "during","overlap","contain","equal"])
for entry in list:
    granule = entry["granule"]
    maplist = entry["samples"]
    for map in maplist:
        map.select()
        map.print_info()

A valid temporal topology (no overlapping or inclusion allowed) is needed to get correct results in case of gaps in the sample dataset.

Gaps between maps are identified as unregistered maps with id==None.

The objects are initialized with their id’s‘ and the spatio-temporal extent (temporal type, start time, end time, west, east, south, north, bottom and top). In case more map information are needed, use the select() method for each listed object.

Parameters:
  • stds – The space time dataset to be used for temporal sampling
  • method
    This option specifies what sample method should be
    used. In case the registered maps are of temporal point type, only the start time is used for sampling. In case of mixed of interval data the user can chose between:
    • Example [“start”, “during”, “equals”]
    • start: Select maps of which the start time is located in the selection granule:
      map    :        s
      granule:  s-----------------e
      
      map    :        s--------------------e
      granule:  s-----------------e
      
      map    :        s--------e
      granule:  s-----------------e
      
    • contains: Select maps which are temporal during the selection granule:
      map    :     s-----------e
      granule:  s-----------------e
      
    • overlap: Select maps which temporal overlap the selection granule, this includes overlaps and overlapped:
      map    :     s-----------e
      granule:        s-----------------e
      
      map    :     s-----------e
      granule:  s----------e
      
    • during: Select maps which temporally contains the selection granule:
      map    :  s-----------------e
      granule:     s-----------e
      
    • equals: Select maps which temporally equal to the selection granule:
      map    :  s-----------e
      granule:  s-----------e
      
    • follows: Select maps which temporally follow the selection granule:
      map    :              s-----------e
      granule:  s-----------e
      
    • precedes: Select maps which temporally precedes the selection granule:
      map    :  s-----------e
      granule:              s-----------e
      

    All these methods can be combined. Method must be of type tuple including the identification strings.

  • spatial – If set True additional the 2d spatial overlapping is used for selection -> spatio-temporal relation. The returned map objects will have temporal and spatial extents
  • dbif – The database interface to be used
Returns:

A list of lists of map objects or None in case nothing was found None

set_aggregation_type(aggregation_type)[source]

Set the aggregation type of the space time dataset

Parameters:aggregation_type – The aggregation type of the space time dataset
set_granularity(granularity)[source]

Set the granularity

The granularity is usually computed by the space time dataset at runtime.

Granularity can be of absolute time or relative time. In case of absolute time a string containing an integer value and the time unit (years, months, days, hours, minuts, seconds). In case of relative time an integer value is expected.

This method only modifies this object and does not commit the modifications to the temporal database.

Parameters:granularity – The granularity of the dataset
set_initial_values(temporal_type, semantic_type=None, title=None, description=None)[source]

Set the initial values of the space time dataset

In addition the command creation string is generated an inserted into the metadata object.

This method only modifies this object and does not commit the modifications to the temporal database.

The insert() function must be called to commit this content into the temporal database.

Parameters:
  • temporal_type – The temporal type of this space time dataset (absolute or relative)
  • semantic_type – The semantic type of this dataset
  • title – The title
  • description – The description of this dataset
set_map_register(name)[source]

Set the name of the map register table

This table stores all map names which are registered in this space time dataset.

This method only modifies this object and does not commit the modifications to the temporal database.

Parameters:name – The name of the register table
set_relative_time_unit(unit)[source]

Set the relative time unit which may be of type: years, months, days, hours, minutes or seconds

All maps registered in a (relative time) space time dataset must have the same unit

This method only modifies this object and does not commit the modifications to the temporal database.

Parameters:unit – The relative time unit
shift(gran, dbif=None)[source]

Temporally shift each registered map with the provided granularity

Parameters:
  • gran – The granularity to be used for shifting
  • dbif – The database interface to be used
Returns:

True something to shift, False if nothing to shift or wrong granularity

static shift_map_list(maps, gran)[source]

Temporally shift each map in the list with the provided granularity

This method does not perform any temporal database operations.

Parameters:
  • maps – A list of maps with initialized temporal extent
  • gran – The granularity to be used for shifting
Returns:

The modified map list, None if nothing to shift or wrong granularity

>>> import grass.temporal as tgis
>>> maps = []
>>> for i in range(5):
...   map = tgis.RasterDataset(None)
...   if i%2 == 0:
...       check = map.set_relative_time(i, i + 1, 'years')
...   else:
...       check = map.set_relative_time(i, None, 'years')
...   maps.append(map)
>>> for map in maps:
...   map.temporal_extent.print_info()
 +-------------------- Relative time -----------------------------------------+
 | Start time:................. 0
 | End time:................... 1
 | Relative time unit:......... years
 +-------------------- Relative time -----------------------------------------+
 | Start time:................. 1
 | End time:................... None
 | Relative time unit:......... years
 +-------------------- Relative time -----------------------------------------+
 | Start time:................. 2
 | End time:................... 3
 | Relative time unit:......... years
 +-------------------- Relative time -----------------------------------------+
 | Start time:................. 3
 | End time:................... None
 | Relative time unit:......... years
 +-------------------- Relative time -----------------------------------------+
 | Start time:................. 4
 | End time:................... 5
 | Relative time unit:......... years
>>> maps = tgis.AbstractSpaceTimeDataset.shift_map_list(maps, 5)
>>> for map in maps:
...   map.temporal_extent.print_info()
 +-------------------- Relative time -----------------------------------------+
 | Start time:................. 5
 | End time:................... 6
 | Relative time unit:......... years
 +-------------------- Relative time -----------------------------------------+
 | Start time:................. 6
 | End time:................... None
 | Relative time unit:......... years
 +-------------------- Relative time -----------------------------------------+
 | Start time:................. 7
 | End time:................... 8
 | Relative time unit:......... years
 +-------------------- Relative time -----------------------------------------+
 | Start time:................. 8
 | End time:................... None
 | Relative time unit:......... years
 +-------------------- Relative time -----------------------------------------+
 | Start time:................. 9
 | End time:................... 10
 | Relative time unit:......... years
snap(dbif=None)[source]

For each registered map snap the end time to the start time of its temporal nearest neighbor in the future

Maps with equal time stamps are not snapped

Parameters:dbif – The database interface to be used
static snap_map_list(maps)[source]

For each map in the list snap the end time to the start time of its temporal nearest neighbor in the future.

Maps with equal time stamps are not snapped.

The granularity of the map list will be used to create the end time of the last map in case it has a time instance as timestamp.

This method does not perform any temporal database operations.

Parameters:maps – A list of maps with initialized temporal extent
Returns:The modified map list, None nothing to shift or wrong granularity

Usage:

>>> import grass.temporal as tgis
>>> maps = []
>>> for i in range(5):
...   map = tgis.RasterDataset(None)
...   if i%2 == 0:
...       check = map.set_relative_time(i, i + 1, 'years')
...   else:
...       check = map.set_relative_time(i, None, 'years')
...   maps.append(map)
>>> for map in maps:
...   map.temporal_extent.print_info()
 +-------------------- Relative time -----------------------------------------+
 | Start time:................. 0
 | End time:................... 1
 | Relative time unit:......... years
 +-------------------- Relative time -----------------------------------------+
 | Start time:................. 1
 | End time:................... None
 | Relative time unit:......... years
 +-------------------- Relative time -----------------------------------------+
 | Start time:................. 2
 | End time:................... 3
 | Relative time unit:......... years
 +-------------------- Relative time -----------------------------------------+
 | Start time:................. 3
 | End time:................... None
 | Relative time unit:......... years
 +-------------------- Relative time -----------------------------------------+
 | Start time:................. 4
 | End time:................... 5
 | Relative time unit:......... years
>>> maps = tgis.AbstractSpaceTimeDataset.snap_map_list(maps)
>>> for map in maps:
...   map.temporal_extent.print_info()
 +-------------------- Relative time -----------------------------------------+
 | Start time:................. 0
 | End time:................... 1
 | Relative time unit:......... years
 +-------------------- Relative time -----------------------------------------+
 | Start time:................. 1
 | End time:................... 2
 | Relative time unit:......... years
 +-------------------- Relative time -----------------------------------------+
 | Start time:................. 2
 | End time:................... 3
 | Relative time unit:......... years
 +-------------------- Relative time -----------------------------------------+
 | Start time:................. 3
 | End time:................... 4
 | Relative time unit:......... years
 +-------------------- Relative time -----------------------------------------+
 | Start time:................. 4
 | End time:................... 5
 | Relative time unit:......... years
unregister_map(map, dbif=None, execute=True)[source]

Unregister a map from the space time dataset.

This method takes care of the un-registration of a map from a space time dataset.

Parameters:
  • map – The map object to unregister
  • dbif – The database interface to be used
  • execute – If True the SQL DELETE and DROP table statements will be executed. If False the prepared SQL statements are returned and must be executed by the caller.
Returns:

The SQL statements if execute == False, else an empty string, None in case of a failure

update_command_string(dbif=None)[source]

Append the current command string to any existing command string in the metadata class and calls metadata update

Parameters:dbif – The database interface to be used
update_from_registered_maps(dbif=None)[source]

This methods updates the modification time, the spatial and temporal extent as well as type specific metadata. It should always been called after maps are registered or unregistered/deleted from the space time dataset.

The update of the temporal extent checks if the end time is set correctly. In case the registered maps have no valid end time (None) the maximum start time will be used. If the end time is earlier than the maximum start time, it will be replaced by the maximum start time.

Parameters:dbif – The database interface to be used

temporal.aggregation module

Aggregation methods for space time raster datasets

Usage:

import grass.temporal as tgis

tgis.aggregate_raster_maps(dataset, mapset, inputs, base, start, end, count, method, register_null, dbif)

(C) 2012-2013 by the GRASS Development Team This program is free software under the GNU General Public License (>=v2). Read the file COPYING that comes with GRASS for details.

author:Soeren Gebbert
temporal.aggregation.aggregate_by_topology(granularity_list, granularity, map_list, topo_list, basename, time_suffix, offset=0, method='average', nprocs=1, spatial=None, dbif=None, overwrite=False, file_limit=1000)[source]

Aggregate a list of raster input maps with r.series

Parameters:
  • granularity_list – A list of AbstractMapDataset objects. The temporal extents of the objects are used to build the spatio-temporal topology with the map list objects
  • granularity – The granularity of the granularity list
  • map_list – A list of RasterDataset objects that contain the raster maps that should be aggregated
  • topo_list – A list of strings of topological relations that are used to select the raster maps for aggregation
  • basename – The basename of the new generated raster maps
  • time_suffix – Use the granularity truncated start time of the actual granule to create the suffix for the basename
  • offset – Use a numerical offset for suffix generation (overwritten by time_suffix)
  • method – The aggregation method of r.series (average,min,max, ...)
  • nprocs – The number of processes used for parallel computation
  • spatial – This indicates if the spatial topology is created as well: spatial can be None (no spatial topology), “2D” using west, east, south, north or “3D” using west, east, south, north, bottom, top
  • dbif – The database interface to be used
  • overwrite – Overwrite existing raster maps
  • file_limit – The maximum number of raster map layers that should be opened at once by r.series
Returns:

A list of RasterDataset objects that contain the new map names and the temporal extent for map registration

temporal.aggregation.aggregate_raster_maps(inputs, base, start, end, count, method, register_null, dbif, offset=0)[source]

Aggregate a list of raster input maps with r.series

Parameters:
  • inputs – The names of the raster maps to be aggregated
  • base – The basename of the new created raster maps
  • start – The start time of the sample interval, may be relative or absolute
  • end – The end time of the sample interval, may be relative or absolute
  • count – The number to be attached to the basename of the new created raster map
  • method – The aggreation method to be used by r.series
  • register_null – If true null maps will be registered in the space time raster dataset, if false not
  • dbif – The temporal database interface to use
  • offset – Offset to be added to the map counter to create the map ids
temporal.aggregation.collect_map_names(sp, dbif, start, end, sampling)[source]

Gather all maps from dataset using a specific sample method

Parameters:
  • sp – The space time raster dataset to select aps from
  • dbif – The temporal database interface to use
  • start – The start time of the sample interval, may be relative or absolute
  • end – The end time of the sample interval, may be relative or absolute
  • sampling – The sampling methods to use

temporal.base module

This packages includes all base classes to store basic information like id, name, mapset creation and modification time as well as sql serialization and de-serialization and the sql database interface.

Usage:

>>> import grass.temporal as tgis
>>> tgis.init()
>>> rbase = tgis.RasterBase(ident="soil@PERMANENT")
>>> vbase = tgis.VectorBase(ident="soil:1@PERMANENT")
>>> r3base = tgis.Raster3DBase(ident="soil@PERMANENT")
>>> strdsbase = tgis.STRDSBase(ident="soil@PERMANENT")
>>> stvdsbase = tgis.STVDSBase(ident="soil@PERMANENT")
>>> str3dsbase = tgis.STR3DSBase(ident="soil@PERMANENT")

(C) 2011-2013 by the GRASS Development Team This program is free software under the GNU General Public License (>=v2). Read the file COPYING that comes with GRASS for details.

author:Soeren Gebbert
class temporal.base.AbstractSTDSRegister(table=None, ident=None, registered_stds=None)[source]

Bases: temporal.base.SQLDatabaseInterface

This is the base class for all maps to store the space time datasets as comma separated string in which they are registered

Usage:

>>> init()
>>> t = AbstractSTDSRegister("raster", "soil@PERMANENT", "A@P,B@P,C@P")
>>> t.id
'soil@PERMANENT'
>>> t.registered_stds
'A@P,B@P,C@P'
get_id()[source]

Convenient method to get the unique identifier (primary key)

Returns:None if not found
get_registered_stds()[source]

Get the comma separated list of space time datasets ids in which this map is registered

Returns:None if not found
id

Convenient method to get the unique identifier (primary key)

Returns:None if not found
registered_stds

Get the comma separated list of space time datasets ids in which this map is registered

Returns:None if not found
set_id(ident)[source]

Convenient method to set the unique identifier (primary key)

Parameters:ident – The unique identifier must be a combination of the dataset name, layer name and the mapset “name@mapset” or “name:layer@mapset”
set_registered_stds(registered_stds)[source]

Get the comma separated list of space time datasets ids in which this map is registered

Parameters:registered_stds – A comma separated list of space time dataset ids in which this map is registered
class temporal.base.DatasetBase(table=None, ident=None, name=None, mapset=None, creator=None, ctime=None, ttype=None)[source]

Bases: temporal.base.SQLDatabaseInterface

This is the base class for all maps and spacetime datasets storing basic identification information

Usage:

>>> init()
>>> t = DatasetBase("raster", "soil@PERMANENT", creator="soeren", ctime=datetime(2001,1,1), ttype="absolute")
>>> t.id
'soil@PERMANENT'
>>> t.name
'soil'
>>> t.mapset
'PERMANENT'
>>> t.creator
'soeren'
>>> t.ctime
datetime.datetime(2001, 1, 1, 0, 0)
>>> t.ttype
'absolute'
>>> t.print_info()
 +-------------------- Basic information -------------------------------------+
 | Id: ........................ soil@PERMANENT
 | Name: ...................... soil
 | Mapset: .................... PERMANENT
 | Creator: ................... soeren
 | Temporal type: ............. absolute
 | Creation time: ............. 2001-01-01 00:00:00
>>> t.print_shell_info()
id=soil@PERMANENT
name=soil
mapset=PERMANENT
creator=soeren
temporal_type=absolute
creation_time=2001-01-01 00:00:00
creator

Get the creator of the dataset :return: None if not found

ctime

Get the creation time of the dataset, datatype is datetime :return: None if not found

get_creator()[source]

Get the creator of the dataset :return: None if not found

get_ctime()[source]

Get the creation time of the dataset, datatype is datetime :return: None if not found

get_id()[source]

Convenient method to get the unique identifier (primary key)

Returns:None if not found
get_layer()[source]

Convenient method to get the layer of the map (part of primary key)

Layer are currently supported for vector maps

Returns:None if not found
get_map_id()[source]

Convenient method to get the unique map identifier without layer information

Returns:the name of the vector map as “name@mapset” or None in case the id was not set
get_mapset()[source]

Get the name of mapset of this dataset :return: None if not found

get_name()[source]

Get the name of the dataset :return: None if not found

get_ttype()[source]

Get the temporal type of the map :return: None if not found

id

Convenient method to get the unique identifier (primary key)

Returns:None if not found
map_id

Convenient method to get the unique map identifier without layer information

Returns:the name of the vector map as “name@mapset” or None in case the id was not set
mapset

Get the name of mapset of this dataset :return: None if not found

name

Get the name of the dataset :return: None if not found

print_info()[source]

Print information about this class in human readable style

print_shell_info()[source]

Print information about this class in shell style

set_creator(creator)[source]

Set the creator of the dataset

Parameters:creator – The name of the creator
set_ctime(ctime=None)[source]

Set the creation time of the dataset, if nothing set the current time is used

Parameters:ctime – The current time of type datetime
set_id(ident)[source]

Convenient method to set the unique identifier (primary key)

Parameters:ident – The unique identifier must be a combination of the dataset name, layer name and the mapset “name@mapset” or “name:layer@mapset”
set_layer(layer)[source]

Convenient method to set the layer of the map (part of primary key)

Layer are supported for vector maps

Parameters:layer – The layer of the map
set_mapset(mapset)[source]

Set the mapset of the dataset

Parameters:mapset – The name of the mapset in which this dataset is stored
set_name(name)[source]

Set the name of the dataset

Parameters:name – The name of the dataset
set_ttype(ttype)[source]

Set the temporal type of the dataset: absolute or relative, if nothing set absolute time will assumed

Parameters:ttype – The temporal type of the dataset “absolute or relative”
ttype

Get the temporal type of the map :return: None if not found

class temporal.base.DictSQLSerializer[source]

Bases: object

clear()[source]

Initialize the internal storage

deserialize(row)[source]

Convert the content of the dbmi dictionary like row into the internal dictionary

Parameters:row – The dictionary like row to store in the internal dict
print_self()[source]

Print the content of the internal dictionary to stdout

serialize(type, table, where=None)[source]

Convert the internal dictionary into a string of semicolon separated SQL statements The keys are the column names and the values are the row entries

Usage:

>>> init()
>>> t = DictSQLSerializer()
>>> t.D["id"] = "soil@PERMANENT"
>>> t.D["name"] = "soil"
>>> t.D["mapset"] = "PERMANENT"
>>> t.D["creator"] = "soeren"
>>> t.D["creation_time"] = datetime(2001,1,1)
>>> t.D["modification_time"] = datetime(2001,1,1)
>>> t.serialize(type="SELECT", table="raster_base")
('SELECT  name  , creator  , creation_time  , modification_time  , mapset  , id  FROM raster_base ;\n', ())
>>> t.serialize(type="INSERT", table="raster_base")
('INSERT INTO raster_base ( name  ,creator  ,creation_time  ,modification_time  ,mapset  ,id ) VALUES (? ,? ,? ,? ,? ,?) ;\n', ('soil', 'soeren', datetime.datetime(2001, 1, 1, 0, 0), datetime.datetime(2001, 1, 1, 0, 0), 'PERMANENT', 'soil@PERMANENT'))
>>> t.serialize(type="UPDATE", table="raster_base")
('UPDATE raster_base SET  name = ?  ,creator = ?  ,creation_time = ?  ,modification_time = ?  ,mapset = ?  ,id = ? ;\n', ('soil', 'soeren', datetime.datetime(2001, 1, 1, 0, 0), datetime.datetime(2001, 1, 1, 0, 0), 'PERMANENT', 'soil@PERMANENT'))
>>> t.serialize(type="UPDATE ALL", table="raster_base")
('UPDATE raster_base SET  name = ?  ,creator = ?  ,creation_time = ?  ,modification_time = ?  ,mapset = ?  ,id = ? ;\n', ('soil', 'soeren', datetime.datetime(2001, 1, 1, 0, 0), datetime.datetime(2001, 1, 1, 0, 0), 'PERMANENT', 'soil@PERMANENT'))

:param type: must be SELECT. INSERT, UPDATE
:param table: The name of the table to select, insert or update
:param where: The optional where statement
:return: a tuple containing the SQL string and the arguments
class temporal.base.Raster3DBase(ident=None, name=None, mapset=None, creator=None, creation_time=None, temporal_type=None)[source]

Bases: temporal.base.DatasetBase

Time stamped 3D raster map base information class

class temporal.base.Raster3DSTDSRegister(ident=None, registered_stds=None)[source]

Bases: temporal.base.AbstractSTDSRegister

Time stamped 3D raster map base information class

class temporal.base.RasterBase(ident=None, name=None, mapset=None, creator=None, creation_time=None, temporal_type=None)[source]

Bases: temporal.base.DatasetBase

Time stamped raster map base information class

class temporal.base.RasterSTDSRegister(ident=None, registered_stds=None)[source]

Bases: temporal.base.AbstractSTDSRegister

Time stamped raster map base information class

class temporal.base.SQLDatabaseInterface(table=None, ident=None)[source]

Bases: temporal.base.DictSQLSerializer

This class represents the SQL database interface

Functions to insert, select and update the internal structure of this class in the temporal database are implemented. This is the base class for raster, raster3d, vector and space time datasets data management classes:

  • Identification information (base)
  • Spatial extent
  • Temporal extent
  • Metadata

Usage:

>>> init()
>>> t = SQLDatabaseInterface("raster", "soil@PERMANENT")
>>> t.mapset = get_current_mapset()
>>> t.D["name"] = "soil"
>>> t.D["mapset"] = "PERMANENT"
>>> t.D["creator"] = "soeren"
>>> t.D["creation_time"] = datetime(2001,1,1)
>>> t.get_delete_statement()
"DELETE FROM raster WHERE id = 'soil@PERMANENT';\n"
>>> t.get_is_in_db_statement()
"SELECT id FROM raster WHERE id = 'soil@PERMANENT';\n"
>>> t.get_select_statement()
("SELECT  creation_time  , mapset  , name  , creator  FROM raster WHERE id = 'soil@PERMANENT';\n", ())
>>> t.get_select_statement_mogrified()
"SELECT  creation_time  , mapset  , name  , creator  FROM raster WHERE id = 'soil@PERMANENT';\n"
>>> t.get_insert_statement()
('INSERT INTO raster ( creation_time  ,mapset  ,name  ,creator ) VALUES (? ,? ,? ,?) ;\n', (datetime.datetime(2001, 1, 1, 0, 0), 'PERMANENT', 'soil', 'soeren'))
>>> t.get_insert_statement_mogrified()
"INSERT INTO raster ( creation_time  ,mapset  ,name  ,creator ) VALUES ('2001-01-01 00:00:00' ,'PERMANENT' ,'soil' ,'soeren') ;\n"
>>> t.get_update_statement()
("UPDATE raster SET  creation_time = ?  ,mapset = ?  ,name = ?  ,creator = ? WHERE id = 'soil@PERMANENT';\n", (datetime.datetime(2001, 1, 1, 0, 0), 'PERMANENT', 'soil', 'soeren'))
>>> t.get_update_statement_mogrified()
"UPDATE raster SET  creation_time = '2001-01-01 00:00:00'  ,mapset = 'PERMANENT'  ,name = 'soil'  ,creator = 'soeren' WHERE id = 'soil@PERMANENT';\n"
>>> t.get_update_all_statement()
("UPDATE raster SET  creation_time = ?  ,mapset = ?  ,name = ?  ,creator = ? WHERE id = 'soil@PERMANENT';\n", (datetime.datetime(2001, 1, 1, 0, 0), 'PERMANENT', 'soil', 'soeren'))
>>> t.get_update_all_statement_mogrified()
"UPDATE raster SET  creation_time = '2001-01-01 00:00:00'  ,mapset = 'PERMANENT'  ,name = 'soil'  ,creator = 'soeren' WHERE id = 'soil@PERMANENT';\n"
delete(dbif=None)[source]

Delete the entry of this object from the temporal database

Parameters:dbif – The database interface to be used, if None a temporary connection will be established
get_delete_statement()[source]

Return the delete string :return: The DELETE string

get_insert_statement()[source]

Return the sql statement and the argument list in database specific style :return: The INSERT string

get_insert_statement_mogrified(dbif=None)[source]

Return the insert statement as mogrified string

Parameters:dbif – The database interface to be used, if None a temporary connection will be established
Returns:The INSERT string
get_is_in_db_statement()[source]

Return the selection string that checks if this object is registered in the temporal database :return: The SELECT string

get_select_statement()[source]

Return the sql statement and the argument list in database specific style :return: The SELECT string

get_select_statement_mogrified(dbif=None)[source]

Return the select statement as mogrified string

Parameters:dbif – The database interface to be used, if None a temporary connection will be established
Returns:The SELECT string
get_table_name()[source]

Return the name of the table in which the internal data are inserted, updated or selected :return: The name of the table

get_update_all_statement(ident=None)[source]

Return the sql statement and the argument list in database specific style

Parameters:ident – The identifier to be updated, useful for renaming
Returns:The UPDATE string
get_update_all_statement_mogrified(dbif=None, ident=None)[source]

Return the update all statement as mogrified string

Parameters:
  • dbif – The database interface to be used, if None a temporary connection will be established
  • ident – The identifier to be updated, useful for renaming
Returns:

The UPDATE string

get_update_statement(ident=None)[source]

Return the sql statement and the argument list in database specific style

Parameters:ident – The identifier to be updated, useful for renaming
Returns:The UPDATE string
get_update_statement_mogrified(dbif=None, ident=None)[source]

Return the update statement as mogrified string

Parameters:
  • dbif – The database interface to be used, if None a temporary connection will be established
  • ident – The identifier to be updated, useful for renaming
Returns:

The UPDATE string

insert(dbif=None)[source]

Serialize the content of this object and store it in the temporal database using the internal identifier

Parameters:dbif – The database interface to be used, if None a temporary connection will be established
is_in_db(dbif=None)[source]

Check if this object is present in the temporal database

Parameters:dbif – The database interface to be used, if None a temporary connection will be established
Returns:True if this object is present in the temporal database, False otherwise
select(dbif=None)[source]

Select the content from the temporal database and store it in the internal dictionary structure

Parameters:dbif – The database interface to be used, if None a temporary connection will be established
update(dbif=None, ident=None)[source]

Serialize the content of this object and update it in the temporal database using the internal identifier

Only object entries which are exists (not None) are updated

Parameters:
  • dbif – The database interface to be used, if None a temporary connection will be established
  • ident – The identifier to be updated, useful for renaming
update_all(dbif=None, ident=None)[source]

Serialize the content of this object, including None objects, and update it in the temporal database using the internal identifier

param dbif:The database interface to be used, if None a temporary connection will be established
param ident:The identifier to be updated, useful for renaming
class temporal.base.STDSBase(table=None, ident=None, name=None, mapset=None, semantic_type=None, creator=None, ctime=None, ttype=None, mtime=None)[source]

Bases: temporal.base.DatasetBase

Base class for space time datasets

This class adds the semantic type member variable to the dataset base class.

Usage:

>>> init()
>>> t = STDSBase("stds", "soil@PERMANENT", semantic_type="average", creator="soeren", ctime=datetime(2001,1,1), ttype="absolute", mtime=datetime(2001,1,1))
>>> t.semantic_type
'average'
>>> t.print_info()
 +-------------------- Basic information -------------------------------------+
 | Id: ........................ soil@PERMANENT
 | Name: ...................... soil
 | Mapset: .................... PERMANENT
 | Creator: ................... soeren
 | Temporal type: ............. absolute
 | Creation time: ............. 2001-01-01 00:00:00
 | Modification time:.......... 2001-01-01 00:00:00
 | Semantic type:.............. average
>>> t.print_shell_info()
id=soil@PERMANENT
name=soil
mapset=PERMANENT
creator=soeren
temporal_type=absolute
creation_time=2001-01-01 00:00:00
modification_time=2001-01-01 00:00:00
semantic_type=average
get_mtime()[source]

Get the modification time of the space time dataset, datatype is datetime

Returns:None if not found
get_semantic_type()[source]

Get the semantic type of the space time dataset :return: None if not found

print_info()[source]

Print information about this class in human readable style

print_shell_info()[source]

Print information about this class in shell style

semantic_type

Get the semantic type of the space time dataset :return: None if not found

set_mtime(mtime=None)[source]

Set the modification time of the space time dataset, if nothing set the current time is used

set_semantic_type(semantic_type)[source]

Set the semantic type of the space time dataset

class temporal.base.STR3DSBase(ident=None, name=None, mapset=None, semantic_type=None, creator=None, ctime=None, ttype=None)[source]

Bases: temporal.base.STDSBase

Space time 3D raster dataset base information class

class temporal.base.STRDSBase(ident=None, name=None, mapset=None, semantic_type=None, creator=None, ctime=None, ttype=None)[source]

Bases: temporal.base.STDSBase

Space time raster dataset base information class

class temporal.base.STVDSBase(ident=None, name=None, mapset=None, semantic_type=None, creator=None, ctime=None, ttype=None)[source]

Bases: temporal.base.STDSBase

Space time vector dataset base information class

class temporal.base.VectorBase(ident=None, name=None, mapset=None, layer=None, creator=None, creation_time=None, temporal_type=None)[source]

Bases: temporal.base.DatasetBase

Time stamped vector map base information class

class temporal.base.VectorSTDSRegister(ident=None, registered_stds=None)[source]

Bases: temporal.base.AbstractSTDSRegister

Time stamped vector map base information class

temporal.c_libraries_interface module

Fast and exit-safe interface to GRASS C-library functions using ctypes and multiprocessing

(C) 2013 by the GRASS Development Team This program is free software under the GNU General Public License (>=v2). Read the file COPYING that comes with GRASS for details.

authors:Soeren Gebbert
class temporal.c_libraries_interface.CLibrariesInterface[source]

Bases: grass.pygrass.rpc.base.RPCServerBase

Fast and exit-safe interface to GRASS C-libraries functions

This class implements a fast and exit-safe interface to the GRASS gis, raster, 3D raster and vector C-libraries functions.

The C-libraries functions are called via ctypes in a subprocess using a pipe (multiprocessing.Pipe) to transfer the text messages. Hence, the process that uses the CLibrariesInterface will not be exited, if a G_fatal_error() was invoked in the subprocess. In this case the CLibrariesInterface object will simply start a new subprocess and restarts the pipeline.

Usage:

>>> import grass.script as gscript
>>> import grass.temporal as tgis
>>> gscript.use_temp_region()
>>> gscript.run_command("g.region", n=80.0, s=0.0, e=120.0, w=0.0,
... t=1.0, b=0.0, res=10.0, res3=10.0)
0
>>> tgis.init()
>>> gscript.run_command("r.mapcalc", expression="test = 1", overwrite=True, quiet=True)
0
>>> gscript.run_command("r3.mapcalc", expression="test = 1", overwrite=True, quiet=True)
0
>>> gscript.run_command("v.random", output="test", n=10, overwrite=True, quiet=True)
0
>>> gscript.run_command("r.timestamp", map="test", date='12 Mar 1995 10:34:40', overwrite=True, quiet=True)
0
>>> gscript.run_command("r3.timestamp", map="test", date='12 Mar 1995 10:34:40', overwrite=True, quiet=True)
0
>>> gscript.run_command("v.timestamp", map="test", date='12 Mar 1995 10:34:40', overwrite=True, quiet=True)
0

# Check mapsets
>>> ciface = tgis.CLibrariesInterface()
>>> mapsets = ciface.available_mapsets()
>>> mapsets[0] == tgis.get_current_mapset()
True

# Raster map
>>> ciface = tgis.CLibrariesInterface()
>>> check = ciface.raster_map_exists("test", tgis.get_current_mapset())
>>> print check
True
>>> ciface.read_raster_info("test", tgis.get_current_mapset())
{'rows': 12, 'north': 80.0, 'min': 1, 'datatype': 'CELL', 'max': 1, 'ewres': 10.0, 'cols': 8, 'west': 0.0, 'east': 120.0, 'nsres': 10.0, 'south': 0.0}

>>> info = ciface.read_raster_full_info("test", tgis.get_current_mapset())
>>> info           
{u'tbres': 1.0, ... 'keyword': 'generated by r.mapcalc',
 u'bottom': 0.0, 'end_time': None, 'title': 'test', u'south': 0.0}

>>> info["start_time"]
datetime.datetime(1995, 3, 12, 10, 34, 40)
>>> info["end_time"]

>>> check = ciface.has_raster_timestamp("test", tgis.get_current_mapset())
>>> print check
True
>>> if check:
...     res = ciface.read_raster_timestamp("test", tgis.get_current_mapset())
...     if res[0]:
...         print str(res[1][0]), str(res[1][0])
...         ciface.remove_raster_timestamp("test", tgis.get_current_mapset())
1995-03-12 10:34:40 1995-03-12 10:34:40
1
>>> ciface.has_raster_timestamp("test", tgis.get_current_mapset())
False
>>> ciface.write_raster_timestamp("test", tgis.get_current_mapset(), "13 Jan 1999 14:30:05")
1
>>> ciface.has_raster_timestamp("test", tgis.get_current_mapset())
True


# 3D raster map
>>> check = ciface.raster3d_map_exists("test", tgis.get_current_mapset())
>>> print check
True
>>> ciface.read_raster3d_info("test", tgis.get_current_mapset())
{'tbres': 1.0, 'rows': 12, 'north': 80.0, 'bottom': 0.0, 'datatype': 'DCELL', 'max': 1.0, 'top': 1.0, 'min': 1.0, 'cols': 8, 'depths': 1, 'west': 0.0, 'ewres': 10.0, 'east': 120.0, 'nsres': 10.0, 'south': 0.0}
>>> check = ciface.has_raster3d_timestamp("test", tgis.get_current_mapset())
>>> print check
True
>>> if check:
...     res = ciface.read_raster3d_timestamp("test", tgis.get_current_mapset())
...     if res[0]:
...         print str(res[1][0]), str(res[1][0])
...         ciface.remove_raster3d_timestamp("test", tgis.get_current_mapset())
1995-03-12 10:34:40 1995-03-12 10:34:40
1
>>> ciface.has_raster3d_timestamp("test", tgis.get_current_mapset())
False
>>> ciface.write_raster3d_timestamp("test", tgis.get_current_mapset(), "13 Jan 1999 14:30:05")
1
>>> ciface.has_raster3d_timestamp("test", tgis.get_current_mapset())
True


# Vector map
>>> check = ciface.vector_map_exists("test", tgis.get_current_mapset())
>>> print check
True
>>> kvp = ciface.read_vector_info("test", tgis.get_current_mapset())
>>> kvp['points']
10

>>> kvp = ciface.read_vector_full_info("test", tgis.get_current_mapset())
>>> print kvp['points']
10
>>> kvp['point']
10
>>> kvp['area']
0
>>> kvp['lines']
10
>>> kvp['line']
0
>>> 'columns' in kvp
False
>>> kvp["start_time"]
datetime.datetime(1995, 3, 12, 10, 34, 40)
>>> kvp["end_time"]

>>> check = ciface.has_vector_timestamp("test", tgis.get_current_mapset(), None)
>>> print check
True
>>> if check:
...     res = ciface.read_vector_timestamp("test", tgis.get_current_mapset())
...     if res[0]:
...         print str(res[1][0]), str(res[1][0])
...         ciface.remove_vector_timestamp("test", tgis.get_current_mapset())
1995-03-12 10:34:40 1995-03-12 10:34:40
1
>>> ciface.has_vector_timestamp("test", tgis.get_current_mapset())
False
>>> ciface.write_vector_timestamp("test", tgis.get_current_mapset(), "13 Jan 1999 14:30:05")
1
>>> ciface.has_vector_timestamp("test", tgis.get_current_mapset())
True

>>> ciface.get_driver_name()
'sqlite'
>>> ciface.get_database_name().split("/")[-1]
'sqlite.db'

>>> mapset = ciface.get_mapset()
>>> location = ciface.get_location()
>>> gisdbase = ciface.get_gisdbase()

>>> ciface.fatal_error() 
Traceback (most recent call last):
    raise FatalError("Exception raised: " + str(e) + " Message: " + message)
FatalError: Exception raised:  ...

>>> ciface.fatal_error() 
Traceback (most recent call last):
    raise FatalError("Exception raised: " + str(e) + " Message: " + message)
FatalError: Exception raised:  ...

>>> ciface.fatal_error() 
Traceback (most recent call last):
    raise FatalError("Exception raised: " + str(e) + " Message: " + message)
FatalError: Exception raised:  ...

>>> ciface.fatal_error() 
Traceback (most recent call last):
    raise FatalError("Exception raised: " + str(e) + " Message: " + message)
FatalError: Exception raised:  ...

>>> ciface.stop()

>>> gscript.del_temp_region()
Traceback (most recent call last):
    raise FatalError("Exception raised: " + str(e) + " Message: " + message)
FatalError: Exception raised:  ...
available_mapsets()[source]

Return all available mapsets the user can access as a list of strings

Returns:Names of available mapsets as list of strings
fatal_error(mapset=None)[source]

Generate a fatal error in libgis.

This function is only for testing purpose.

get_database_name(mapset=None)[source]

Return the temporal database name of a specific mapset

Parameters:mapset – Name of the mapset
Returns:Name of the database or None if no temporal database present
get_driver_name(mapset=None)[source]

Return the temporal database driver of a specific mapset

Parameters:mapset – Name of the mapset
Returns:Name of the driver or None if no temporal database present
get_gisdbase()[source]

Return the gisdatabase

Returns:Name of the gisdatabase
get_location()[source]

Return the location

Returns:Name of the location
get_mapset()[source]

Return the current mapset

Returns:Name of the current mapset
has_raster3d_timestamp(name, mapset)[source]

Check if a file based 3D raster timestamp exists

Parameters:
  • name – The name of the map
  • mapset – The mapset of the map
Returns:

True if exists, False if not

has_raster_timestamp(name, mapset)[source]

Check if a file based raster timestamp exists

Parameters:
  • name – The name of the map
  • mapset – The mapset of the map
Returns:

True if exists, False if not

has_vector_timestamp(name, mapset, layer=None)[source]

Check if a file based vector timestamp exists

Parameters:
  • name – The name of the map
  • mapset – The mapset of the map
  • layer – The layer of the vector map
Returns:

True if exists, False if not

raster3d_map_exists(name, mapset)[source]

Check if a 3D raster map exists in the spatial database

Parameters:
  • name – The name of the map
  • mapset – The mapset of the map
Returns:

True if exists, False if not

raster_map_exists(name, mapset)[source]

Check if a raster map exists in the spatial database

Parameters:
  • name – The name of the map
  • mapset – The mapset of the map
Returns:

True if exists, False if not

read_raster3d_info(name, mapset)[source]

Read the 3D raster map info from the file system and store the content into a dictionary

Parameters:
  • name – The name of the map
  • mapset – The mapset of the map
Returns:

The key value pairs of the map specific metadata, or None in case of an error

read_raster3d_timestamp(name, mapset)[source]

Read a file based 3D raster timestamp

Please have a look at the documentation G_read_raster3d_timestamp for the return values description.

The timestamps to be send are tuples of values:
  • relative time (start, end, unit), start and end are of type integer, unit is of type string.
  • absolute time (start, end), start and end are of type datetime

The end time may be None in case of a time instance.

Parameters:
  • name – The name of the map
  • mapset – The mapset of the map
Returns:

The return value of G_read_raster3d_timestamp

read_raster_full_info(name, mapset)[source]

Read raster info, history and cats using PyGRASS RasterRow and return a dictionary. Colors should be supported in the future.

Parameters:
  • name – The name of the map
  • mapset – The mapset of the map
Returns:

The key value pairs of the map specific metadata, or None in case of an error

read_raster_info(name, mapset)[source]

Read the raster map info from the file system and store the content into a dictionary

Parameters:
  • name – The name of the map
  • mapset – The mapset of the map
Returns:

The key value pairs of the map specific metadata, or None in case of an error

read_raster_timestamp(name, mapset)[source]

Read a file based raster timestamp

Please have a look at the documentation G_read_raster_timestamp for the return values description.

The timestamps to be send are tuples of values:
  • relative time (start, end, unit), start and end are of type integer, unit is of type string.
  • absolute time (start, end), start and end are of type datetime

The end time may be None in case of a time instance.

Parameters:
  • name – The name of the map
  • mapset – The mapset of the map
Returns:

The return value of G_read_raster_timestamp

read_vector_full_info(name, mapset)[source]

Read vector info using PyGRASS VectorTopo and return a dictionary.

Parameters:
  • name – The name of the map
  • mapset – The mapset of the map
Returns:

The key value pairs of the map specific metadata, or None in case of an error

read_vector_info(name, mapset)[source]

Read the vector map info from the file system and store the content into a dictionary

Parameters:
  • name – The name of the map
  • mapset – The mapset of the map
Returns:

The key value pairs of the map specific metadata, or None in case of an error

read_vector_timestamp(name, mapset, layer=None)[source]

Read a file based vector timestamp

Please have a look at the documentation G_read_vector_timestamp for the return values description.

The timestamps to be send are tuples of values:
  • relative time (start, end, unit), start and end are of type integer, unit is of type string.
  • absolute time (start, end), start and end are of type datetime

The end time may be None in case of a time instance.

Parameters:
  • name – The name of the map
  • mapset – The mapset of the map
  • layer – The layer of the vector map
Returns:

The return value ofG_read_vector_timestamp and the timestamps

remove_raster3d_timestamp(name, mapset)[source]

Remove a file based 3D raster timestamp

Please have a look at the documentation G_remove_raster3d_timestamp for the return values description.

Parameters:
  • name – The name of the map
  • mapset – The mapset of the map
Returns:

The return value of G_remove_raster3d_timestamp

remove_raster_timestamp(name, mapset)[source]

Remove a file based raster timestamp

Please have a look at the documentation G_remove_raster_timestamp for the return values description.

Parameters:
  • name – The name of the map
  • mapset – The mapset of the map
Returns:

The return value of G_remove_raster_timestamp

remove_vector_timestamp(name, mapset, layer=None)[source]

Remove a file based vector timestamp

Please have a look at the documentation G_remove_vector_timestamp for the return values description.

Parameters:
  • name – The name of the map
  • mapset – The mapset of the map
  • layer – The layer of the vector map
Returns:

The return value of G_remove_vector_timestamp

start_server()[source]
vector_map_exists(name, mapset)[source]

Check if a vector map exists in the spatial database

Parameters:
  • name – The name of the map
  • mapset – The mapset of the map
Returns:

True if exists, False if not

write_raster3d_timestamp(name, mapset, timestring)[source]

Write a file based 3D raster timestamp

Please have a look at the documentation G_write_raster3d_timestamp for the return values description.

Note:
Only timestamps of maps from the current mapset can written.
Parameters:
  • name – The name of the map
  • mapset – The mapset of the map
  • timestring – A GRASS datetime C-library compatible string
Returns:

The return value of G_write_raster3d_timestamp

write_raster_timestamp(name, mapset, timestring)[source]

Write a file based raster timestamp

Please have a look at the documentation G_write_raster_timestamp for the return values description.

Note:
Only timestamps of maps from the current mapset can written.
Parameters:
  • name – The name of the map
  • mapset – The mapset of the map
  • timestring – A GRASS datetime C-library compatible string
Returns:

The return value of G_write_raster_timestamp

write_vector_timestamp(name, mapset, timestring, layer=None)[source]

Write a file based vector timestamp

Please have a look at the documentation G_write_vector_timestamp for the return values description.

Note:
Only timestamps pf maps from the current mapset can written.
Parameters:
  • name – The name of the map
  • mapset – The mapset of the map
  • timestring – A GRASS datetime C-library compatible string
  • layer – The layer of the vector map
Returns:

The return value of G_write_vector_timestamp

class temporal.c_libraries_interface.RPCDefs[source]

Bases: object

AVAILABLE_MAPSETS = 8
GET_DATABASE_NAME = 10
GET_DRIVER_NAME = 9
G_FATAL_ERROR = 49
G_GISDBASE = 13
G_LOCATION = 12
G_MAPSET = 11
HAS_TIMESTAMP = 1
MAP_EXISTS = 6
READ_MAP_FULL_INFO = 14
READ_MAP_INFO = 7
READ_TIMESTAMP = 3
REMOVE_TIMESTAMP = 4
STOP = 0
TYPE_RASTER = 0
TYPE_RASTER3D = 1
TYPE_VECTOR = 2
WRITE_TIMESTAMP = 2
temporal.c_libraries_interface.c_library_server(lock, conn)[source]

The GRASS C-libraries server function designed to be a target for multiprocessing.Process

Parameters:
  • lock – A multiprocessing.Lock
  • conn – A multiprocessing.Pipe

temporal.core module

This module provides the functionality to create the temporal SQL database and to establish a connection to the database.

Usage:

>>> import grass.temporal as tgis
>>> # Create the temporal database
>>> tgis.init()
>>> # Establish a database connection
>>> dbif, connected = tgis.init_dbif(None)
>>> dbif.connect()
>>> # Execute a SQL statement
>>> dbif.execute_transaction("SELECT datetime(0, 'unixepoch', 'localtime');")
>>> # Mogrify an SQL statement
>>> dbif.mogrify_sql_statement(["SELECT name from raster_base where name = ?",
... ("precipitation",)])
"SELECT name from raster_base where name = 'precipitation'"
>>> dbif.close()

(C) 2011-2014 by the GRASS Development Team This program is free software under the GNU General Public License (>=v2). Read the file COPYING that comes with GRASS for details.

author:Soeren Gebbert
class temporal.core.DBConnection(backend=None, dbstring=None)[source]

Bases: object

This class represents the database interface connection and provides access to the chosen backend modules.

The following DBMS are supported:

  • sqlite via the sqlite3 standard library
  • postgresql via psycopg2
check_table(table_name)[source]

Check if a table exists in the temporal database

Parameters:
  • table_name – The name of the table to be checked for existence
  • mapset – The mapset of the abstract dataset or temporal database location, if None the current mapset will be used
Returns:

True if the table exists, False otherwise

TODO: There may be several temporal databases in a location, hence the mapset is used to query the correct temporal database.

close()[source]

Close the DBMI connection TODO: There may be several temporal databases in a location, hence close all temporal databases that have been opened. Use a dictionary to manage different connections.

connect(dbstring=None)[source]

Connect to the DBMI to execute SQL statements

Supported backends are sqlite3 and postgresql

param dbstring: The database connection string

execute(statement, args=None)[source]

Execute a SQL statement

Parameters:statement – The executable SQL statement or SQL script
execute_transaction(statement, mapset=None)[source]

Execute a transactional SQL statement

The BEGIN and END TRANSACTION statements will be added automatically to the sql statement

Parameters:statement – The executable SQL statement or SQL script
fetchall()[source]
fetchone()[source]
is_connected()[source]
mogrify_sql_statement(content)[source]

Return the SQL statement and arguments as executable SQL string

TODO: Use the mapset argument to identify the correct database driver

Parameters:
  • content – The content as tuple with two entries, the first entry is the SQL statement with DBMI specific place holder (?), the second entry is the argument list that should substitute the place holder.
  • mapset – The mapset of the abstract dataset or temporal database location, if None the current mapset will be used

Usage:

>>> init()
>>> dbif = SQLDatabaseInterfaceConnection()
>>> dbif.mogrify_sql_statement(["SELECT ctime FROM raster_base WHERE id = ?",
... ["soil@PERMANENT",]])
"SELECT ctime FROM raster_base WHERE id = 'soil@PERMANENT'"
rollback()[source]

Roll back the last transaction. This must be called in case a new query should be performed after a db error.

This is only relevant for postgresql database.

class temporal.core.SQLDatabaseInterfaceConnection[source]

Bases: object

check_table(table_name, mapset=None)[source]

Check if a table exists in the temporal database

Parameters:
  • table_name – The name of the table to be checked for existence
  • mapset – The mapset of the abstract dataset or temporal database location, if None the current mapset will be used
Returns:

True if the table exists, False otherwise

TODO: There may be several temporal databases in a location, hence the mapset is used to query the correct temporal database.

close()[source]

Close the DBMI connection

There may be several temporal databases in a location, hence close all temporal databases that have been opened.

connect()[source]

Connect to the DBMI to execute SQL statements

Supported backends are sqlite3 and postgresql

execute(statement, args=None, mapset=None)[source]
Parameters:mapset – The mapset of the abstract dataset or temporal database location, if None the current mapset will be used
execute_transaction(statement, mapset=None)[source]

Execute a transactional SQL statement

The BEGIN and END TRANSACTION statements will be added automatically to the sql statement

Parameters:statement – The executable SQL statement or SQL script
fetchall(mapset=None)[source]
fetchone(mapset=None)[source]
get_dbmi(mapset=None)[source]
is_connected()[source]
mogrify_sql_statement(content, mapset=None)[source]

Return the SQL statement and arguments as executable SQL string

Parameters:
  • content – The content as tuple with two entries, the first entry is the SQL statement with DBMI specific place holder (?), the second entry is the argument list that should substitute the place holder.
  • mapset – The mapset of the abstract dataset or temporal database location, if None the current mapset will be used
rollback(mapset=None)[source]

Roll back the last transaction. This must be called in case a new query should be performed after a db error.

This is only relevant for postgresql database.

temporal.core.create_temporal_database(dbif)[source]

This function will create the temporal database

It will create all tables and triggers that are needed to run the temporal GIS

Parameters:dbif – The database interface to be used
temporal.core.get_available_temporal_mapsets()[source]

Return a list of of mapset names with temporal database driver and names that are accessible from the current mapset.

Returns:A dictionary, mapset names are keys, the tuple (driver, database) are the values
temporal.core.get_current_gisdbase()[source]

Return the current gis database (gisdbase)

This is the fastest way to receive the current gisdbase. The current gisdbase is set by init() and stored in a global variable. This function provides access to this global variable.

temporal.core.get_current_location()[source]

Return the current location

This is the fastest way to receive the current location. The current location is set by init() and stored in a global variable. This function provides access to this global variable.

temporal.core.get_current_mapset()[source]

Return the current mapset

This is the fastest way to receive the current mapset. The current mapset is set by init() and stored in a global variable. This function provides access to this global variable.

temporal.core.get_database_info_string()[source]
temporal.core.get_enable_mapset_check()[source]

Return True if the mapsets should be checked while insert, update, delete requests and space time dataset registration.

If this global variable is set True, then maps can only be registered in space time datasets with the same mapset. In addition, only maps in the current mapset can be inserted, updated or deleted from the temporal database. Overwrite this global variable by: g.gisenv set=”TGIS_DISABLE_MAPSET_CHECK=True”

..warning:

Be aware to face corrupted temporal database in case this
global variable is set to False. This feature is highly
experimental and violates the grass permission guidance.
temporal.core.get_enable_timestamp_write()[source]

Return True if the map timestamps should be written to the spatial database metadata as well.

If this global variable is set True, the timestamps of maps will be written as textfiles for each map that will be inserted or updated in the temporal database using the C-library timestamp interface. Overwrite this global variable by: g.gisenv set=”TGIS_DISABLE_TIMESTAMP_WRITE=True”

..warning:

Be aware that C-libraries can not access timestamp information if
they are not written as spatial database metadata, hence modules
that make use of timestamps using the C-library interface will not
work with maps that were created without writing the timestamps.
temporal.core.get_raise_on_error()[source]

Return True if a FatalError exception is raised instead of calling sys.exit(1) in case a fatal error was invoked with msgr.fatal()

temporal.core.get_sql_template_path()[source]
temporal.core.get_tgis_backend()[source]

Return the temporal GIS backend as string

Returns:either “sqlite” or “pg”
temporal.core.get_tgis_c_library_interface()[source]

Return the C-library interface that provides a fast and exit safe interface to the C-library libgis, libraster, libraster3d and libvector functions

temporal.core.get_tgis_database()[source]

Return the temporal database string specified with t.connect

temporal.core.get_tgis_database_string()[source]

Return the preprocessed temporal database string

This string is the temporal database string set with t.connect that was processed to substitue location, gisdbase and mapset variables.

temporal.core.get_tgis_db_version()[source]

Get the version number of the temporal framework :returns: The version number of the temporal framework as string

temporal.core.get_tgis_dbmi_paramstyle()[source]

Return the temporal database backend parameter style

Returns:“qmark” or “”
temporal.core.get_tgis_message_interface()[source]

Return the temporal GIS message interface which is of type grass.pygrass.message.Messenger()

Use this message interface to print messages to stdout using the GRASS C-library messaging system.

temporal.core.get_tgis_metadata(dbif=None)[source]

Return the tgis metadata table as a list of rows (dicts) or None if not present

Parameters:dbif – The database interface to be used
Returns:The selected rows with key/value columns or None
temporal.core.get_tgis_version()[source]

Get the version number of the temporal framework :returns: The version number of the temporal framework as string

temporal.core.init(raise_fatal_error=False)[source]

This function set the correct database backend from GRASS environmental variables and creates the grass temporal database structure for raster, vector and raster3d maps as well as for the space-time datasets strds, str3ds and stvds in case it does not exist.

Several global variables are initiated and the messenger and C-library interface subprocesses are spawned.

Re-run this function in case the following GRASS variables change while the process runs:

  • MAPSET
  • LOCATION_NAME
  • GISDBASE
  • TGIS_DISABLE_MAPSET_CHECK
  • TGIS_DISABLE_TIMESTAMP_WRITE

Re-run this function if the following t.connect variables change while the process runs:

  • temporal GIS driver (set by t.connect driver=)
  • temporal GIS database (set by t.connect database=)

The following environmental variables are checked:

  • GRASS_TGIS_PROFILE (True, False, 1, 0)
  • GRASS_TGIS_RAISE_ON_ERROR (True, False, 1, 0)

..warning:

This functions must be called before any spatio-temporal processing
can be started
param raise_fatal_error:
 Set this True to assure that the init() function does not kill a persistent process like the GUI. If set True a grass.pygrass.messages.FatalError exception will be raised in case a fatal error occurs in the init process, otherwise sys.exit(1) will be called.
temporal.core.init_dbif(dbif)[source]

This method checks if the database interface connection exists, if not a new one will be created, connected and True will be returned. If the database interface exists but is connected, the connection will be established.

Returns:the tuple (dbif, True|False)

Usage code sample:

dbif, connect = tgis.init_dbif(None)

sql = dbif.mogrify_sql_statement(["SELECT * FROM raster_base WHERE ? = ?"],
                                       ["id", "soil@PERMANENT"])
dbif.execute_transaction(sql)

if connect:
    dbif.close()
temporal.core.profile_function(func)[source]

Profiling function provided by the temporal framework

temporal.core.set_raise_on_error(raise_exp=True)[source]

Define behavior on fatal error, invoked using the tgis messenger interface (msgr.fatal())

The messenger interface will be restarted using the new error policy

Parameters:raise_exp – True to raise a FatalError exception instead of calling sys.exit(1) when using the tgis messenger interface
>>> import grass.temporal as tgis
>>> tgis.init()
>>> ignore = tgis.set_raise_on_error(False)
>>> msgr = tgis.get_tgis_message_interface()
>>> tgis.get_raise_on_error()
False
>>> msgr.fatal("Ohh no no no!")
Traceback (most recent call last):
  File "__init__.py", line 239, in fatal
    sys.exit(1)
SystemExit: 1

>>> tgis.set_raise_on_error(True)
False
>>> msgr.fatal("Ohh no no no!")
Traceback (most recent call last):
  File "__init__.py", line 241, in fatal
    raise FatalError(message)
FatalError: Ohh no no no!
Traceback (most recent call last):
  File "__init__.py", line 241, in fatal
    raise FatalError(message)
FatalError: Ohh no no no!
Returns:current status
temporal.core.stop_subprocesses()[source]

Stop the messenger and C-interface subprocesses that are started by tgis.init()

temporal.datetime_math module

Functions for mathematical datetime operations

(C) 2011-2013 by the GRASS Development Team This program is free software under the GNU General Public License (>=v2). Read the file COPYING that comes with GRASS for details.

authors:Soeren Gebbert
temporal.datetime_math.adjust_datetime_to_granularity(mydate, granularity)[source]

Modify the datetime object to fit the given granularity

  • Years will start at the first of Januar
  • Months will start at the first day of the month
  • Days will start at the first Hour of the day
  • Hours will start at the first minute of an hour
  • Minutes will start at the first second of a minute

Usage:

>>> dt = datetime(2001, 8, 8, 12,30,30)
>>> adjust_datetime_to_granularity(dt, "5 seconds")
datetime.datetime(2001, 8, 8, 12, 30, 30)

>>> adjust_datetime_to_granularity(dt, "20 minutes")
datetime.datetime(2001, 8, 8, 12, 30)

>>> adjust_datetime_to_granularity(dt, "20 minutes")
datetime.datetime(2001, 8, 8, 12, 30)

>>> adjust_datetime_to_granularity(dt, "3 hours")
datetime.datetime(2001, 8, 8, 12, 0)

>>> adjust_datetime_to_granularity(dt, "5 days")
datetime.datetime(2001, 8, 8, 0, 0)

>>> adjust_datetime_to_granularity(dt, "2 weeks")
datetime.datetime(2001, 8, 6, 0, 0)

>>> adjust_datetime_to_granularity(dt, "6 months")
datetime.datetime(2001, 8, 1, 0, 0)

>>> adjust_datetime_to_granularity(dt, "2 years")
datetime.datetime(2001, 1, 1, 0, 0)

>>> adjust_datetime_to_granularity(dt, "2 years, 3 months, 5 days, 3 hours, 3 minutes, 2 seconds")
datetime.datetime(2001, 8, 8, 12, 30, 30)

>>> adjust_datetime_to_granularity(dt, "3 months, 5 days, 3 minutes")
datetime.datetime(2001, 8, 8, 12, 30)

>>> adjust_datetime_to_granularity(dt, "3 weeks, 5 days")
datetime.datetime(2001, 8, 8, 0, 0)
temporal.datetime_math.check_datetime_string(time_string)[source]

Check if a string can be converted into a datetime object

Supported ISO string formats are:

  • YYYY-mm-dd
  • YYYY-mm-dd HH:MM:SS

Time zones are not supported

Parameters:time_string – The time string to be checked for conversion
Returns:datetime: object or an error message string in case of an error
temporal.datetime_math.compute_datetime_delta(start, end)[source]

Return a dictionary with the accumulated delta in year, month, day, hour, minute and second

Usage:

>>> start = datetime(2001, 1, 1, 00,00,00)
>>> end = datetime(2001, 1, 1, 00,00,00)
>>> compute_datetime_delta(start, end)
{'hour': 0, 'month': 0, 'second': 0, 'max_days': 0, 'year': 0, 'day': 0, 'minute': 0}

>>> start = datetime(2001, 1, 1, 00,00,14)
>>> end = datetime(2001, 1, 1, 00,00,44)
>>> compute_datetime_delta(start, end)
{'hour': 0, 'month': 0, 'second': 30, 'max_days': 0, 'year': 0, 'day': 0, 'minute': 0}

>>> start = datetime(2001, 1, 1, 00,00,44)
>>> end = datetime(2001, 1, 1, 00,01,14)
>>> compute_datetime_delta(start, end)
{'hour': 0, 'month': 0, 'second': 30, 'max_days': 0, 'year': 0, 'day': 0, 'minute': 1}

>>> start = datetime(2001, 1, 1, 00,00,30)
>>> end = datetime(2001, 1, 1, 00,05,30)
>>> compute_datetime_delta(start, end)
{'hour': 0, 'month': 0, 'second': 300, 'max_days': 0, 'year': 0, 'day': 0, 'minute': 5}

>>> start = datetime(2001, 1, 1, 00,00,00)
>>> end = datetime(2001, 1, 1, 00,01,00)
>>> compute_datetime_delta(start, end)
{'hour': 0, 'month': 0, 'second': 0, 'max_days': 0, 'year': 0, 'day': 0, 'minute': 1}

>>> start = datetime(2011,10,31, 00,45,00)
>>> end = datetime(2011,10,31, 01,45,00)
>>> compute_datetime_delta(start, end)
{'hour': 1, 'second': 0, 'max_days': 0, 'year': 0, 'day': 0, 'minute': 60}

>>> start = datetime(2011,10,31, 00,45,00)
>>> end = datetime(2011,10,31, 01,15,00)
>>> compute_datetime_delta(start, end)
{'hour': 1, 'second': 0, 'max_days': 0, 'year': 0, 'day': 0, 'minute': 30}

>>> start = datetime(2011,10,31, 00,45,00)
>>> end = datetime(2011,10,31, 12,15,00)
>>> compute_datetime_delta(start, end)
{'hour': 12, 'second': 0, 'max_days': 0, 'year': 0, 'day': 0, 'minute': 690}

>>> start = datetime(2011,10,31, 00,00,00)
>>> end = datetime(2011,10,31, 01,00,00)
>>> compute_datetime_delta(start, end)
{'hour': 1, 'second': 0, 'max_days': 0, 'year': 0, 'day': 0, 'minute': 0}

>>> start = datetime(2011,10,31, 00,00,00)
>>> end = datetime(2011,11,01, 01,00,00)
>>> compute_datetime_delta(start, end)
{'hour': 25, 'second': 0, 'max_days': 1, 'year': 0, 'day': 1, 'minute': 0}

>>> start = datetime(2011,10,31, 12,00,00)
>>> end = datetime(2011,11,01, 06,00,00)
>>> compute_datetime_delta(start, end)
{'hour': 18, 'second': 0, 'max_days': 0, 'year': 0, 'day': 0, 'minute': 0}

>>> start = datetime(2011,11,01, 00,00,00)
>>> end = datetime(2011,12,01, 01,00,00)
>>> compute_datetime_delta(start, end)
{'hour': 721, 'month': 1, 'second': 0, 'max_days': 30, 'year': 0, 'day': 0, 'minute': 0}

>>> start = datetime(2011,11,01, 00,00,00)
>>> end = datetime(2011,11,05, 00,00,00)
>>> compute_datetime_delta(start, end)
{'hour': 0, 'second': 0, 'max_days': 4, 'year': 0, 'day': 4, 'minute': 0}

>>> start = datetime(2011,10,06, 00,00,00)
>>> end = datetime(2011,11,05, 00,00,00)
>>> compute_datetime_delta(start, end)
{'hour': 0, 'second': 0, 'max_days': 30, 'year': 0, 'day': 30, 'minute': 0}

>>> start = datetime(2011,12,02, 00,00,00)
>>> end = datetime(2012,01,01, 00,00,00)
>>> compute_datetime_delta(start, end)
{'hour': 0, 'second': 0, 'max_days': 30, 'year': 1, 'day': 30, 'minute': 0}

>>> start = datetime(2011,01,01, 00,00,00)
>>> end = datetime(2011,02,01, 00,00,00)
>>> compute_datetime_delta(start, end)
{'hour': 0, 'month': 1, 'second': 0, 'max_days': 31, 'year': 0, 'day': 0, 'minute': 0}

>>> start = datetime(2011,12,01, 00,00,00)
>>> end = datetime(2012,01,01, 00,00,00)
>>> compute_datetime_delta(start, end)
{'hour': 0, 'month': 1, 'second': 0, 'max_days': 31, 'year': 1, 'day': 0, 'minute': 0}

>>> start = datetime(2011,12,01, 00,00,00)
>>> end = datetime(2012,06,01, 00,00,00)
>>> compute_datetime_delta(start, end)
{'hour': 0, 'month': 6, 'second': 0, 'max_days': 183, 'year': 1, 'day': 0, 'minute': 0}

>>> start = datetime(2011,06,01, 00,00,00)
>>> end = datetime(2021,06,01, 00,00,00)
>>> compute_datetime_delta(start, end)
{'hour': 0, 'month': 120, 'second': 0, 'max_days': 3653, 'year': 10, 'day': 0, 'minute': 0}

>>> start = datetime(2011,06,01, 00,00,00)
>>> end = datetime(2012,06,01, 12,00,00)
>>> compute_datetime_delta(start, end)
{'hour': 8796, 'month': 12, 'second': 0, 'max_days': 366, 'year': 1, 'day': 0, 'minute': 0}

>>> start = datetime(2011,06,01, 00,00,00)
>>> end = datetime(2012,06,01, 12,30,00)
>>> compute_datetime_delta(start, end)
{'hour': 8796, 'month': 12, 'second': 0, 'max_days': 366, 'year': 1, 'day': 0, 'minute': 527790}

>>> start = datetime(2011,06,01, 00,00,00)
>>> end = datetime(2012,06,01, 12,00,05)
>>> compute_datetime_delta(start, end)
{'hour': 8796, 'month': 12, 'second': 31665605, 'max_days': 366, 'year': 1, 'day': 0, 'minute': 0}

>>> start = datetime(2011,06,01, 00,00,00)
>>> end = datetime(2012,06,01, 00,30,00)
>>> compute_datetime_delta(start, end)
{'hour': 0, 'month': 12, 'second': 0, 'max_days': 366, 'year': 1, 'day': 0, 'minute': 527070}

>>> start = datetime(2011,06,01, 00,00,00)
>>> end = datetime(2012,06,01, 00,00,05)
>>> compute_datetime_delta(start, end)
{'hour': 0, 'month': 12, 'second': 31622405, 'max_days': 366, 'year': 1, 'day': 0, 'minute': 0}
Returns:A dictionary with year, month, day, hour, minute and second as keys()
temporal.datetime_math.create_numeric_suffic(base, count, zeros)[source]

Create a string based on count and number of zeros decided by zeros

Parameters:
  • base – the basename for new map
  • count – a number
  • zeros – a string containing the expected number, coming from suffix option
temporal.datetime_math.create_suffix_from_datetime(start_time, granularity)[source]

Create a datetime string based on a datetime object and a provided granularity that can be used as suffix for map names.

dateteime=2001-01-01 00:00:00, granularity=”1 month” returns “2001_01”

Parameters:
  • start_time – The datetime object
  • granularity – The granularity for example “1 month” or “100 seconds”
Returns:

A string

temporal.datetime_math.create_time_suffix(mapp, end=False)[source]

Create a datetime string based on a map datetime object

Parameters:
  • mapp – a temporal map dataset
  • end – True if you want add also end time to the suffix
temporal.datetime_math.datetime_to_grass_datetime_string(dt)[source]

Convert a python datetime object into a GRASS datetime string

>>> import grass.temporal as tgis
>>> import dateutil.parser as parser
>>> dt = parser.parse("2011-01-01 10:00:00 +01:30")
>>> tgis.datetime_to_grass_datetime_string(dt)
'01 jan 2011 10:00:00 +0090'
>>> dt = parser.parse("2011-01-01 10:00:00 +02:30")
>>> tgis.datetime_to_grass_datetime_string(dt)
'01 jan 2011 10:00:00 +0150'
>>> dt = parser.parse("2011-01-01 10:00:00 +12:00")
>>> tgis.datetime_to_grass_datetime_string(dt)
'01 jan 2011 10:00:00 +0720'
>>> dt = parser.parse("2011-01-01 10:00:00 -01:30")
>>> tgis.datetime_to_grass_datetime_string(dt)
'01 jan 2011 10:00:00 -0090'
temporal.datetime_math.decrement_datetime_by_string(mydate, increment, mult=1)[source]

Return a new datetime object decremented with the provided relative dates specified as string. Additional a multiplier can be specified to multiply the increment before adding to the provided datetime object.

Usage:

>>> dt = datetime(2001, 1, 1, 0, 0, 0)
>>> string = "31 days"
>>> decrement_datetime_by_string(dt, string)
datetime.datetime(2000, 12, 1, 0, 0)

>>> dt = datetime(2001, 1, 1, 0, 0, 0)
>>> string = "1 month"
>>> decrement_datetime_by_string(dt, string)
datetime.datetime(2000, 12, 1, 0, 0)

>>> dt = datetime(2001, 1, 1, 0, 0, 0)
>>> string = "2 month"
>>> decrement_datetime_by_string(dt, string)
datetime.datetime(2000, 11, 1, 0, 0)

>>> dt = datetime(2001, 1, 1, 0, 0, 0)
>>> string = "24 months"
>>> decrement_datetime_by_string(dt, string)
datetime.datetime(1999, 1, 1, 0, 0)

>>> dt = datetime(2001, 1, 1, 0, 0, 0)
>>> string = "48 months"
>>> decrement_datetime_by_string(dt, string)
datetime.datetime(1997, 1, 1, 0, 0)

>>> dt = datetime(2001, 6, 1, 0, 0, 0)
>>> string = "5 months"
>>> decrement_datetime_by_string(dt, string)
datetime.datetime(2001, 1, 1, 0, 0)

>>> dt = datetime(2001, 6, 1, 0, 0, 0)
>>> string = "7 months"
>>> decrement_datetime_by_string(dt, string)
datetime.datetime(2000, 11, 1, 0, 0)

>>> dt = datetime(2001, 1, 1, 0, 0, 0)
>>> string = "1 year"
>>> decrement_datetime_by_string(dt, string)
datetime.datetime(2000, 1, 1, 0, 0)
Parameters:
  • mydate – A datetime object to incremented
  • increment – A string providing increment information: The string may include comma separated values of type seconds, minutes, hours, days, weeks, months and years Example: Increment the datetime 2001-01-01 00:00:00 with “60 seconds, 4 minutes, 12 hours, 10 days, 1 weeks, 5 months, 1 years” will result in the datetime 2003-02-18 12:05:00
  • mult – A multiplier, default is 1
Returns:

The new datetime object or none in case of an error

temporal.datetime_math.increment_datetime_by_string(mydate, increment, mult=1)[source]

Return a new datetime object incremented with the provided relative dates specified as string. Additional a multiplier can be specified to multiply the increment before adding to the provided datetime object.

Usage:

>>> dt = datetime(2001, 9, 1, 0, 0, 0)
>>> string = "60 seconds, 4 minutes, 12 hours, 10 days, 1 weeks, 5 months, 1 years"
>>> increment_datetime_by_string(dt, string)
datetime.datetime(2003, 2, 18, 12, 5)

>>> dt = datetime(2001, 11, 1, 0, 0, 0)
>>> string = "1 months"
>>> increment_datetime_by_string(dt, string)
datetime.datetime(2001, 12, 1, 0, 0)

>>> dt = datetime(2001, 11, 1, 0, 0, 0)
>>> string = "13 months"
>>> increment_datetime_by_string(dt, string)
datetime.datetime(2002, 12, 1, 0, 0)

>>> dt = datetime(2001, 1, 1, 0, 0, 0)
>>> string = "72 months"
>>> increment_datetime_by_string(dt, string)
datetime.datetime(2007, 1, 1, 0, 0)

>>> dt = datetime(2001, 1, 1, 0, 0, 0)
>>> string = "72 months"
>>> increment_datetime_by_string(dt, string)
datetime.datetime(2007, 1, 1, 0, 0)

>>> dt = datetime(2001, 1, 1, 0, 0, 0)
>>> string = "5 minutes"
>>> increment_datetime_by_string(dt, string)
datetime.datetime(2001, 1, 1, 0, 5)

>>> dt = datetime(2001, 1, 1, 0, 0, 0)
>>> string = "49 hours"
>>> increment_datetime_by_string(dt, string)
datetime.datetime(2001, 1, 3, 1, 0)

>>> dt = datetime(2001, 1, 1, 0, 0, 0)
>>> string = "3600 seconds"
>>> increment_datetime_by_string(dt, string)
datetime.datetime(2001, 1, 1, 1, 0)

>>> dt = datetime(2001, 1, 1, 0, 0, 0)
>>> string = "30 days"
>>> increment_datetime_by_string(dt, string)
datetime.datetime(2001, 1, 31, 0, 0)
Parameters:
  • mydate – A datetime object to incremented
  • increment – A string providing increment information: The string may include comma separated values of type seconds, minutes, hours, days, weeks, months and years Example: Increment the datetime 2001-01-01 00:00:00 with “60 seconds, 4 minutes, 12 hours, 10 days, 1 weeks, 5 months, 1 years” will result in the datetime 2003-02-18 12:05:00
  • mult – A multiplier, default is 1
Returns:

The new datetime object or none in case of an error

temporal.datetime_math.modify_datetime(mydate, years=0, months=0, weeks=0, days=0, hours=0, minutes=0, seconds=0)[source]

Return a new datetime object incremented with the provided relative dates and times

temporal.datetime_math.modify_datetime_by_string(mydate, increment, mult=1, sign=1)[source]

Return a new datetime object incremented with the provided relative dates specified as string. Additional a multiplier can be specified to multiply the increment before adding to the provided datetime object.

Parameters:
  • mydate – A datetime object to incremented
  • increment – A string providing increment information: The string may include comma separated values of type seconds, minutes, hours, days, weeks, months and years Example: Increment the datetime 2001-01-01 00:00:00 with “60 seconds, 4 minutes, 12 hours, 10 days, 1 weeks, 5 months, 1 years” will result in the datetime 2003-02-18 12:05:00
  • mult – A multiplier, default is 1
  • sign – Choose 1 for positive sign (incrementing) or -1 for negative sign (decrementing).
Returns:

The new datetime object or none in case of an error

temporal.datetime_math.relative_time_to_time_delta(value)[source]

Convert the double value representing days into a timedelta object.

temporal.datetime_math.relative_time_to_time_delta_seconds(value)[source]

Convert the double value representing seconds into a timedelta object.

temporal.datetime_math.string_to_datetime(time_string)[source]

Convert a string into a datetime object

In case datutil is not installed the supported ISO string formats are:

  • YYYY-mm-dd
  • YYYY-mm-dd HH:MM:SS
  • Time zones are not supported

If dateutil is installed, all string formats of the dateutil module are supported, as well as time zones

Parameters:time_string – The time string to convert
Returns:datetime object or None in case the string could not be converted
temporal.datetime_math.time_delta_to_relative_time(delta)[source]

Convert the time delta into a double value, representing days.

temporal.datetime_math.time_delta_to_relative_time_seconds(delta)[source]

Convert the time delta into a double value, representing seconds.

temporal.extract module

Extract functions for space time raster, 3d raster and vector datasets

(C) 2012-2013 by the GRASS Development Team This program is free software under the GNU General Public License (>=v2). Read the file COPYING that comes with GRASS for details.

authors:Soeren Gebbert
temporal.extract.extract_dataset(input, output, type, where, expression, base, time_suffix, nprocs=1, register_null=False, layer=1, vtype='point, line, boundary, centroid, area, face')[source]

Extract a subset of a space time raster, raster3d or vector dataset

A mapcalc expression can be provided to process the temporal extracted maps. Mapcalc expressions are supported for raster and raster3d maps.

Parameters:
  • input – The name of the input space time raster/raster3d dataset
  • output – The name of the extracted new space time raster/raster3d dataset
  • type – The type of the dataset: “raster”, “raster3d” or vector
  • where – The temporal SQL WHERE statement for subset extraction
  • expression – The r(3).mapcalc expression or the v.extract where statement
  • base – The base name of the new created maps in case a mapclac expression is provided
  • time_suffix – string to choose which suffix to use: gran, time, num%* (where * are digits)
  • nprocs – The number of parallel processes to be used for mapcalc processing
  • register_null – Set this number True to register empty maps (only raster and raster3d maps)
  • layer – The vector layer number to be used when no timestamped layer is present, default is 1
  • vtype – The feature type to be extracted for vector maps, default is point,line,boundary,centroid,area and face
temporal.extract.run_mapcalc2d(expr)[source]

Helper function to run r.mapcalc in parallel

temporal.extract.run_mapcalc3d(expr)[source]

Helper function to run r3.mapcalc in parallel

temporal.extract.run_vector_extraction(input, output, layer, type, where)[source]

Helper function to run r.mapcalc in parallel

temporal.factory module

Object factory

Usage:

import grass.temporal as tgis

tgis.register_maps_in_space_time_dataset(type, name, maps)

(C) 2012-2013 by the GRASS Development Team This program is free software under the GNU General Public License (>=v2). Read the file COPYING that comes with GRASS for details.

authors:Soeren Gebbert
temporal.factory.dataset_factory(type, id)[source]

A factory functions to create space time or map datasets

Parameters:
  • type – the dataset type: rast or raster; rast3d, raster3d or raster_3d; vect or vector; strds; str3ds; stvds
  • id – The id of the dataset (“name@mapset”)

temporal.gui_support module

GUI support functions

(C) 2008-2011 by the GRASS Development Team This program is free software under the GNU General Public License (>=v2). Read the file COPYING that comes with GRASS for details.

authors:Soeren Gebbert
temporal.gui_support.tlist(type, dbif=None)[source]

Return a list of space time datasets of absolute and relative time

Parameters:type – element type (strds, str3ds, stvds)
Returns:a list of space time dataset ids
temporal.gui_support.tlist_grouped(type, group_type=False, dbif=None)[source]

List of temporal elements grouped by mapsets.

Returns a dictionary where the keys are mapset names and the values are lists of space time datasets in that mapset. Example:

>>> tgis.tlist_grouped('strds')['PERMANENT']
['precipitation', 'temperature']
Parameters:
  • type – element type (strds, str3ds, stvds)
  • group_type – TBD
Returns:

directory of mapsets/elements

temporal.list_stds module

Functions to create space time dataset lists

Usage:

import grass.temporal as tgis

tgis.register_maps_in_space_time_dataset(type, name, maps)

(C) 2012-2016 by the GRASS Development Team This program is free software under the GNU General Public License (>=v2). Read the file COPYING that comes with GRASS GIS for details.

authors:Soeren Gebbert
temporal.list_stds.get_dataset_list(type, temporal_type, columns=None, where=None, order=None, dbif=None)[source]

Return a list of time stamped maps or space time datasets of a specific temporal type that are registered in the temporal database

This method returns a dictionary, the keys are the available mapsets, the values are the rows from the SQL database query.

Parameters:
  • type – The type of the datasets (strds, str3ds, stvds, raster, raster_3d, vector)
  • temporal_type – The temporal type of the datasets (absolute, relative)
  • columns – A comma separated list of columns that will be selected
  • where – A where statement for selected listing without “WHERE”
  • order – A comma separated list of columns to order the datasets by category
  • dbif – The database interface to be used
Returns:

A dictionary with the rows of the SQL query for each available mapset

>>> import grass.temporal as tgis
>>> tgis.init()
>>> name = "list_stds_test"
>>> sp = tgis.open_new_stds(name=name, type="strds",
... temporaltype="absolute", title="title", descr="descr", semantic="mean", dbif=None, overwrite=True)
>>> mapset = tgis.get_current_mapset()
>>> stds_list = tgis.get_dataset_list("strds", "absolute", columns="name")
>>> rows =  stds_list[mapset]
>>> for row in rows:
...     if row["name"] == name:
...         print(True)
True
>>> stds_list = tgis.get_dataset_list("strds", "absolute", columns="name,mapset", where="mapset = '%s'"%(mapset))
>>> rows =  stds_list[mapset]
>>> for row in rows:
...     if row["name"] == name and row["mapset"] == mapset:
...         print(True)
True
>>> check = sp.delete()
temporal.list_stds.list_maps_of_stds(type, input, columns, order, where, separator, method, no_header=False, gran=None, dbif=None, outpath=None)[source]

List the maps of a space time dataset using different methods

Parameters:
  • type – The type of the maps raster, raster3d or vector
  • input – Name of a space time raster dataset
  • columns – A comma separated list of columns to be printed to stdout
  • order – A comma separated list of columns to order the maps by category
  • where – A where statement for selected listing without “WHERE” e.g: start_time < “2001-01-01” and end_time > “2001-01-01”
  • separator – The field separator character between the columns
  • method – String identifier to select a method out of cols, comma,delta or deltagaps
  • dbif

    The database interface to be used

    • “cols” Print preselected columns specified by columns
    • “comma” Print the map ids (“name@mapset”) as comma separated string
    • “delta” Print the map ids (“name@mapset”) with start time,
      end time, relative length of intervals and the relative distance to the begin
    • “deltagaps” Same as “delta” with additional listing of gaps.
      Gaps can be easily identified as the id is “None”
    • “gran” List map using the granularity of the space time dataset,
      columns are identical to deltagaps
  • no_header – Suppress the printing of column names
  • gran – The user defined granule to be used if method=gran is set, in case gran=None the granule of the space time dataset is used
  • outpath – The path to file where to save output

temporal.mapcalc module

Raster and 3d raster mapcalculation functions

(C) 2012-2013 by the GRASS Development Team This program is free software under the GNU General Public License (>=v2). Read the file COPYING that comes with GRASS for details.

authors:Soeren Gebbert
temporal.mapcalc.dataset_mapcalculator(inputs, output, type, expression, base, method, nprocs=1, register_null=False, spatial=False)[source]

Perform map-calculations of maps from different space time raster/raster3d datasets, using a specific sampling method to select temporal related maps.

A mapcalc expression must be provided to process the temporal selected maps. Temporal operators are available in addition to the r.mapcalc operators:

Supported operators for relative and absolute time are:

  • td() - the time delta of the current interval in days

    and fractions of days or the unit in case of relative time

  • start_time() - The start time of the interval from the begin of

    the time series in days and fractions of days or the unit in case of relative time

  • end_time() - The end time of the current interval from the begin of

    the time series in days and fractions of days or the unit in case of relative time

Supported operators for absolute time:

  • start_doy() - Day of year (doy) from the start time [1 - 366]

  • start_dow() - Day of week (dow) from the start time [1 - 7],

    the start of the week is monday == 1

  • start_year() - The year of the start time [0 - 9999]

  • start_month() - The month of the start time [1 - 12]

  • start_week() - Week of year of the start time [1 - 54]

  • start_day() - Day of month from the start time [1 - 31]

  • start_hour() - The hour of the start time [0 - 23]

  • start_minute() - The minute of the start time [0 - 59]

  • start_second() - The second of the start time [0 - 59]

  • end_doy() - Day of year (doy) from the end time [1 - 366]

  • end_dow() - Day of week (dow) from the end time [1 - 7],

    the start of the week is monday == 1

  • end_year() - The year of the end time [0 - 9999]

  • end_month() - The month of the end time [1 - 12]

  • end_week() - Week of year of the end time [1 - 54]

  • end_day() - Day of month from the end time [1 - 31]

  • end_hour() - The hour of the end time [0 - 23]

  • end_minute() - The minute of the end time [0 - 59]

  • end_second() - The minute of the end time [0 - 59]

Parameters:
  • inputs – The names of the input space time raster/raster3d datasets
  • output – The name of the extracted new space time raster(3d) dataset
  • type – The type of the dataset: “raster” or “raster3d”
  • expression – The r(3).mapcalc expression
  • base – The base name of the new created maps in case a mapclac expression is provided
  • method – The method to be used for temporal sampling
  • nprocs – The number of parallel processes to be used for mapcalc processing
  • register_null – Set this number True to register empty maps
  • spatial – Check spatial overlap

temporal.metadata module

Metadata classes for map layer and space time datasets

Usage:

>>> import grass.temporal as tgis
>>> tgis.init()
>>> meta = tgis.RasterMetadata()
>>> meta = tgis.Raster3DMetadata()
>>> meta = tgis.VectorMetadata()
>>> meta = tgis.STRDSMetadata()
>>> meta = tgis.STR3DSMetadata()
>>> meta = tgis.STVDSMetadata()

(C) 2012-2013 by the GRASS Development Team This program is free software under the GNU General Public License (>=v2). Read the file COPYING that comes with GRASS for details.

authors:Soeren Gebbert
class temporal.metadata.Raster3DMetadata(ident=None, datatype=None, cols=None, rows=None, depths=None, number_of_cells=None, nsres=None, ewres=None, tbres=None, min=None, max=None)[source]

Bases: temporal.metadata.RasterMetadataBase

This is the raster3d metadata class

This class is the interface to the raster3d_metadata table in the temporal database that stores the metadata of all registered 3D raster maps.

The metadata includes all raster metadata variables and additional the number of depths, the top-bottom resolution and the space time 3D raster dataset register table is stored.

Usage:

>>> init()
>>> meta = Raster3DMetadata(ident="soil@PERMANENT",
... datatype="FCELL", cols=100, rows=100, depths=100,
... number_of_cells=1000000, nsres=0.1, ewres=0.1, tbres=0.1,
... min=0, max=100)
>>> meta.datatype
'FCELL'
>>> meta.cols
100
>>> meta.rows
100
>>> meta.depths
100
>>> meta.number_of_cells
1000000
>>> meta.nsres
0.1
>>> meta.ewres
0.1
>>> meta.tbres
0.1
>>> meta.min
0.0
>>> meta.max
100.0
>>> meta.print_info()
 +-------------------- Metadata information ----------------------------------+
 | Datatype:................... FCELL
 | Number of columns:.......... 100
 | Number of rows:............. 100
 | Number of cells:............ 1000000
 | North-South resolution:..... 0.1
 | East-west resolution:....... 0.1
 | Minimum value:.............. 0.0
 | Maximum value:.............. 100.0
 | Number of depths:........... 100
 | Top-Bottom resolution:...... 0.1
>>> meta.print_shell_info()
datatype=FCELL
cols=100
rows=100
number_of_cells=1000000
nsres=0.1
ewres=0.1
min=0.0
max=100.0
depths=100
tbres=0.1
depths

Get number of depths :return: None if not found

get_depths()[source]

Get number of depths :return: None if not found

get_tbres()[source]

Get top-bottom resolution :return: None if not found

print_info()[source]

Print information about this class in human readable style

print_shell_info()[source]

Print information about this class in shell style

set_depths(depths)[source]

Set the number of depths

set_tbres(tbres)[source]

Set the top-bottom resolution

tbres

Get top-bottom resolution :return: None if not found

class temporal.metadata.RasterMetadata(ident=None, datatype=None, cols=None, rows=None, number_of_cells=None, nsres=None, ewres=None, min=None, max=None)[source]

Bases: temporal.metadata.RasterMetadataBase

This is the raster metadata class

This class is the interface to the raster_metadata table in the temporal database that stores the metadata of all registered raster maps.

The metadata includes the datatype, number of cols, rows and cells and the north-south and east west resolution of the map. Additionally the minimum and maximum valuesare stored.

Usage:

>>> init()
>>> meta = RasterMetadata(ident="soil@PERMANENT",
... datatype="CELL", cols=100, rows=100, number_of_cells=10000, nsres=0.1,
... ewres=0.1, min=0, max=100)
>>> meta.datatype
'CELL'
>>> meta.cols
100
>>> meta.rows
100
>>> meta.number_of_cells
10000
>>> meta.nsres
0.1
>>> meta.ewres
0.1
>>> meta.min
0.0
>>> meta.max
100.0
>>> meta.print_info()
 +-------------------- Metadata information ----------------------------------+
 | Datatype:................... CELL
 | Number of columns:.......... 100
 | Number of rows:............. 100
 | Number of cells:............ 10000
 | North-South resolution:..... 0.1
 | East-west resolution:....... 0.1
 | Minimum value:.............. 0.0
 | Maximum value:.............. 100.0
>>> meta.print_shell_info()
datatype=CELL
cols=100
rows=100
number_of_cells=10000
nsres=0.1
ewres=0.1
min=0.0
max=100.0
print_info()[source]

Print information about this class in human readable style

print_shell_info()[source]

Print information about this class in shell style

class temporal.metadata.RasterMetadataBase(table=None, ident=None, datatype=None, cols=None, rows=None, number_of_cells=None, nsres=None, ewres=None, min=None, max=None)[source]

Bases: temporal.base.SQLDatabaseInterface

This is the metadata base class for time stamped raster and raster3d maps

Usage:

>>> init()
>>> meta = RasterMetadataBase(table="metadata", ident="soil@PERMANENT",
... datatype="CELL", cols=100, rows=100, number_of_cells=10000, nsres=0.1,
... ewres=0.1, min=0, max=100)
>>> meta.datatype
'CELL'
>>> meta.cols
100
>>> meta.rows
100
>>> meta.number_of_cells
10000
>>> meta.nsres
0.1
>>> meta.ewres
0.1
>>> meta.min
0.0
>>> meta.max
100.0
>>> meta.print_info()
 | Datatype:................... CELL
 | Number of columns:.......... 100
 | Number of rows:............. 100
 | Number of cells:............ 10000
 | North-South resolution:..... 0.1
 | East-west resolution:....... 0.1
 | Minimum value:.............. 0.0
 | Maximum value:.............. 100.0
>>> meta.print_shell_info()
datatype=CELL
cols=100
rows=100
number_of_cells=10000
nsres=0.1
ewres=0.1
min=0.0
max=100.0
cols

Get number of cols :return: None if not found

datatype

Get the map type :return: None if not found

ewres

Get east-west resolution :return: None if not found

get_cols()[source]

Get number of cols :return: None if not found

get_datatype()[source]

Get the map type :return: None if not found

get_ewres()[source]

Get east-west resolution :return: None if not found

get_id()[source]

Convenient method to get the unique identifier (primary key) :return: None if not found

get_max()[source]

Get the maximum cell value :return: None if not found

get_min()[source]

Get the minimum cell value :return: None if not found

get_nsres()[source]

Get the north-south resolution :return: None if not found

get_number_of_cells()[source]

Get number of cells :return: None if not found

get_rows()[source]

Get number of rows :return: None if not found

max

Get the maximum cell value :return: None if not found

min

Get the minimum cell value :return: None if not found

nsres

Get the north-south resolution :return: None if not found

number_of_cells

Get number of cells :return: None if not found

print_info()[source]

Print information about this class in human readable style

print_shell_info()[source]

Print information about this class in shell style

rows

Get number of rows :return: None if not found

set_cols(cols)[source]

Set the number of cols

set_datatype(datatype)[source]

Set the datatype

set_ewres(ewres)[source]

Set the east-west resolution

set_id(ident)[source]

Convenient method to set the unique identifier (primary key)

set_max(max)[source]

Set the maximum raster value

set_min(min)[source]

Set the minimum raster value

set_nsres(nsres)[source]

Set the north-south resolution

set_number_of_cells(number_of_cells)[source]

Set the number of cells

set_rows(rows)[source]

Set the number of rows

class temporal.metadata.STDSMetadataBase(table=None, ident=None, title=None, description=None, command=None)[source]

Bases: temporal.base.SQLDatabaseInterface

This is the space time dataset metadata base class for strds, stvds and str3ds datasets setting/getting the id, the title and the description

Usage:

>>> init()
>>> meta = STDSMetadataBase(ident="soils@PERMANENT",
... title="Soils", description="Soils 1950 - 2010")
>>> meta.id
'soils@PERMANENT'
>>> meta.title
'Soils'
>>> meta.description
'Soils 1950 - 2010'
>>> meta.number_of_maps
>>> meta.print_info()
 | Number of registered maps:.. None
 |
 | Title:
 | Soils
 | Description:
 | Soils 1950 - 2010
 | Command history:
>>> meta.print_shell_info()
number_of_maps=None
description

Get description :return: None if not found

get_command()[source]

Get command :return: None if not found

get_description()[source]

Get description :return: None if not found

get_id()[source]

Convenient method to get the unique identifier (primary key) :return: None if not found

get_number_of_maps()[source]

Get the number of registered maps, this value is set in the database automatically via SQL, so no setter exists :return: None if not found

get_title()[source]

Get the title :return: None if not found

id

Convenient method to get the unique identifier (primary key) :return: None if not found

number_of_maps

Get the number of registered maps, this value is set in the database automatically via SQL, so no setter exists :return: None if not found

print_history()[source]

Print history information about this class in human readable shell style

print_info()[source]

Print information about this class in human readable style

print_shell_info()[source]

Print information about this class in shell style

set_command(command)[source]

Set the number of cols

set_description(description)[source]

Set the number of cols

set_id(ident)[source]

Convenient method to set the unique identifier (primary key)

set_title(title)[source]

Set the title

title

Get the title :return: None if not found

class temporal.metadata.STDSRasterMetadataBase(table=None, ident=None, title=None, description=None, aggregation_type=None)[source]

Bases: temporal.metadata.STDSMetadataBase

This is the space time dataset metadata base class for strds and str3ds datasets

Most of the metadata values are set by SQL scripts in the database when new maps are added. Therefor only some set- an many get-functions are available.

Usage:

>>> init()
>>> meta = STDSRasterMetadataBase(ident="soils@PERMANENT",
... title="Soils", description="Soils 1950 - 2010")
>>> meta.id
'soils@PERMANENT'
>>> meta.title
'Soils'
>>> meta.description
'Soils 1950 - 2010'
>>> meta.number_of_maps
>>> meta.min_max
>>> meta.max_max
>>> meta.min_min
>>> meta.max_min
>>> meta.nsres_min
>>> meta.nsres_max
>>> meta.ewres_min
>>> meta.ewres_max
>>> meta.print_info()
 | North-South resolution min:. None
 | North-South resolution max:. None
 | East-west resolution min:... None
 | East-west resolution max:... None
 | Minimum value min:.......... None
 | Minimum value max:.......... None
 | Maximum value min:.......... None
 | Maximum value max:.......... None
 | Aggregation type:........... None
 | Number of registered maps:.. None
 |
 | Title:
 | Soils
 | Description:
 | Soils 1950 - 2010
 | Command history:
>>> meta.print_shell_info()
aggregation_type=None
number_of_maps=None
nsres_min=None
nsres_max=None
ewres_min=None
ewres_max=None
min_min=None
min_max=None
max_min=None
max_max=None
aggregation_type

Get the aggregation type of the dataset (mean, min, max, ...) :return: None if not found

ewres_max

Get the maximal east-west resolution of all registered maps, this value is set in the database automatically via SQL, so no setter exists :return: None if not found

ewres_min

Get the minimal east-west resolution of all registered maps, this value is set in the database automatically via SQL, so no setter exists :return: None if not found

get_aggregation_type()[source]

Get the aggregation type of the dataset (mean, min, max, ...) :return: None if not found

get_ewres_max()[source]

Get the maximal east-west resolution of all registered maps, this value is set in the database automatically via SQL, so no setter exists :return: None if not found

get_ewres_min()[source]

Get the minimal east-west resolution of all registered maps, this value is set in the database automatically via SQL, so no setter exists :return: None if not found

get_max_max()[source]

Get the maximal maximum of all registered maps, this value is set in the database automatically via SQL, so no setter exists :return: None if not found

get_max_min()[source]

Get the minimal maximum of all registered maps, this value is set in the database automatically via SQL, so no setter exists :return: None if not found

get_min_max()[source]

Get the maximal minimum of all registered maps, this value is set in the database automatically via SQL, so no setter exists :return: None if not found

get_min_min()[source]

Get the minimal minimum of all registered maps, this value is set in the database automatically via SQL, so no setter exists :return: None if not found

get_nsres_max()[source]

Get the maximal north-south resolution of all registered maps, this value is set in the database automatically via SQL, so no setter exists :return: None if not found

get_nsres_min()[source]

Get the minimal north-south resolution of all registered maps, this value is set in the database automatically via SQL, so no setter exists :return: None if not found

max_max

Get the maximal maximum of all registered maps, this value is set in the database automatically via SQL, so no setter exists :return: None if not found

max_min

Get the minimal maximum of all registered maps, this value is set in the database automatically via SQL, so no setter exists :return: None if not found

min_max

Get the maximal minimum of all registered maps, this value is set in the database automatically via SQL, so no setter exists :return: None if not found

min_min

Get the minimal minimum of all registered maps, this value is set in the database automatically via SQL, so no setter exists :return: None if not found

nsres_max

Get the maximal north-south resolution of all registered maps, this value is set in the database automatically via SQL, so no setter exists :return: None if not found

nsres_min

Get the minimal north-south resolution of all registered maps, this value is set in the database automatically via SQL, so no setter exists :return: None if not found

print_info()[source]

Print information about this class in human readable style

print_shell_info()[source]

Print information about this class in shell style

set_aggregation_type(aggregation_type)[source]

Set the aggregation type of the dataset (mean, min, max, ...)

class temporal.metadata.STR3DSMetadata(ident=None, raster3d_register=None, title=None, description=None)[source]

Bases: temporal.metadata.STDSRasterMetadataBase

This is the space time 3D raster metadata class

This class is the interface to the str3ds_metadata table in the temporal database that stores the metadata of all registered space time 3D raster datasets

Most of the metadata values are set by SQL scripts in the database when new 3D raster maps are added. Therefor only some set- an many get-functions are available.

Usage:

>>> init()
>>> meta = STR3DSMetadata(ident="soils@PERMANENT",
... title="Soils", description="Soils 1950 - 2010")
>>> meta.id
'soils@PERMANENT'
>>> meta.title
'Soils'
>>> meta.description
'Soils 1950 - 2010'
>>> meta.number_of_maps
>>> meta.min_max
>>> meta.max_max
>>> meta.min_min
>>> meta.max_min
>>> meta.nsres_min
>>> meta.nsres_max
>>> meta.ewres_min
>>> meta.ewres_max
>>> meta.tbres_min
>>> meta.tbres_max
>>> meta.raster3d_register
>>> meta.print_info()
 +-------------------- Metadata information ----------------------------------+
 | 3D raster register table:... None
 | Top-bottom resolution min:.. None
 | Top-bottom resolution max:.. None
 | North-South resolution min:. None
 | North-South resolution max:. None
 | East-west resolution min:... None
 | East-west resolution max:... None
 | Minimum value min:.......... None
 | Minimum value max:.......... None
 | Maximum value min:.......... None
 | Maximum value max:.......... None
 | Aggregation type:........... None
 | Number of registered maps:.. None
 |
 | Title:
 | Soils
 | Description:
 | Soils 1950 - 2010
 | Command history:
>>> meta.print_shell_info()
aggregation_type=None
number_of_maps=None
nsres_min=None
nsres_max=None
ewres_min=None
ewres_max=None
min_min=None
min_max=None
max_min=None
max_max=None
tbres_min=None
tbres_max=None
raster3d_register=None
get_raster3d_register()[source]

Get the raster3d map register table name :return: None if not found

get_tbres_max()[source]

Get the maximal top-bottom resolution of all registered maps, this value is set in the database automatically via SQL, so no setter exists :return: None if not found

get_tbres_min()[source]

Get the minimal top-bottom resolution of all registered maps, this value is set in the database automatically via SQL, so no setter exists :return: None if not found

print_info()[source]

Print information about this class in human readable style

print_shell_info()[source]

Print information about this class in shell style

raster3d_register

Get the raster3d map register table name :return: None if not found

set_raster3d_register(raster3d_register)[source]

Set the raster map register table name

tbres_max

Get the maximal top-bottom resolution of all registered maps, this value is set in the database automatically via SQL, so no setter exists :return: None if not found

tbres_min

Get the minimal top-bottom resolution of all registered maps, this value is set in the database automatically via SQL, so no setter exists :return: None if not found

class temporal.metadata.STRDSMetadata(ident=None, raster_register=None, title=None, description=None)[source]

Bases: temporal.metadata.STDSRasterMetadataBase

This is the raster metadata class

This class is the interface to the strds_metadata table in the temporal database that stores the metadata of all registered space time raster datasets

Most of the metadata values are set by SQL scripts in the database when new raster maps are added. Therefor only some set- an many get-functions are available.

Usage:

>>> init()
>>> meta = STRDSMetadata(ident="soils@PERMANENT",
... title="Soils", description="Soils 1950 - 2010")
>>> meta.id
'soils@PERMANENT'
>>> meta.title
'Soils'
>>> meta.description
'Soils 1950 - 2010'
>>> meta.number_of_maps
>>> meta.min_max
>>> meta.max_max
>>> meta.min_min
>>> meta.max_min
>>> meta.nsres_min
>>> meta.nsres_max
>>> meta.ewres_min
>>> meta.ewres_max
>>> meta.raster_register
>>> meta.print_info()
 +-------------------- Metadata information ----------------------------------+
 | Raster register table:...... None
 | North-South resolution min:. None
 | North-South resolution max:. None
 | East-west resolution min:... None
 | East-west resolution max:... None
 | Minimum value min:.......... None
 | Minimum value max:.......... None
 | Maximum value min:.......... None
 | Maximum value max:.......... None
 | Aggregation type:........... None
 | Number of registered maps:.. None
 |
 | Title:
 | Soils
 | Description:
 | Soils 1950 - 2010
 | Command history:
>>> meta.print_shell_info()
aggregation_type=None
number_of_maps=None
nsres_min=None
nsres_max=None
ewres_min=None
ewres_max=None
min_min=None
min_max=None
max_min=None
max_max=None
raster_register=None
get_raster_register()[source]

Get the raster map register table name :return: None if not found

print_info()[source]

Print information about this class in human readable style

print_shell_info()[source]

Print information about this class in shell style

raster_register

Get the raster map register table name :return: None if not found

set_raster_register(raster_register)[source]

Set the raster map register table name

class temporal.metadata.STVDSMetadata(ident=None, vector_register=None, title=None, description=None)[source]

Bases: temporal.metadata.STDSMetadataBase

This is the space time vector dataset metadata class

This class is the interface to the stvds_metadata table in the temporal database that stores the metadata of all registered space time vector datasets

Most of the metadata values are set by SQL scripts in the database when new vector maps are added. Therefor only some set- an many get-functions are available.

Usage:

>>> init()
>>> meta = STVDSMetadata(ident="lidars@PERMANENT",
... title="LIDARS", description="LIDARS 2008 - 2010")
>>> meta.id
'lidars@PERMANENT'
>>> meta.title
'LIDARS'
>>> meta.description
'LIDARS 2008 - 2010'
>>> meta.number_of_maps
>>> meta.number_of_points
>>> meta.number_of_lines
>>> meta.number_of_boundaries
>>> meta.number_of_centroids
>>> meta.number_of_faces
>>> meta.number_of_kernels
>>> meta.number_of_primitives
>>> meta.number_of_nodes
>>> meta.number_of_areas
>>> meta.number_of_islands
>>> meta.number_of_holes
>>> meta.number_of_volumes
>>> meta.print_info()
 +-------------------- Metadata information ----------------------------------+
 | Vector register table:...... None
 | Number of points ........... None
 | Number of lines ............ None
 | Number of boundaries ....... None
 | Number of centroids ........ None
 | Number of faces ............ None
 | Number of kernels .......... None
 | Number of primitives ....... None
 | Number of nodes ............ None
 | Number of areas ............ None
 | Number of islands .......... None
 | Number of holes ............ None
 | Number of volumes .......... None
 | Number of registered maps:.. None
 |
 | Title:
 | LIDARS
 | Description:
 | LIDARS 2008 - 2010
 | Command history:
>>> meta.print_shell_info()
number_of_maps=None
vector_register=None
points=None
lines=None
boundaries=None
centroids=None
faces=None
kernels=None
primitives=None
nodes=None
areas=None
islands=None
holes=None
volumes=None
get_number_of_areas()[source]

Get the number of areas of all registered maps, this value is set in the database automatically via SQL, so no setter exists :return: None if not found

get_number_of_boundaries()[source]

Get the number of boundaries of all registered maps, this value is set in the database automatically via SQL, so no setter exists :return: None if not found

get_number_of_centroids()[source]

Get the number of centroids of all registered maps, this value is set in the database automatically via SQL, so no setter exists :return: None if not found

get_number_of_faces()[source]

Get the number of faces of all registered maps, this value is set in the database automatically via SQL, so no setter exists :return: None if not found

get_number_of_holes()[source]

Get the number of holes of all registered maps, this value is set in the database automatically via SQL, so no setter exists :return: None if not found

get_number_of_islands()[source]

Get the number of islands of all registered maps, this value is set in the database automatically via SQL, so no setter exists :return: None if not found

get_number_of_kernels()[source]

Get the number of kernels of all registered maps, this value is set in the database automatically via SQL, so no setter exists :return: None if not found

get_number_of_lines()[source]

Get the number of lines of all registered maps, this value is set in the database automatically via SQL, so no setter exists :return: None if not found

get_number_of_nodes()[source]

Get the number of nodes of all registered maps, this value is set in the database automatically via SQL, so no setter exists :return: None if not found

get_number_of_points()[source]

Get the number of points of all registered maps, this value is set in the database automatically via SQL, so no setter exists :return: None if not found

get_number_of_primitives()[source]

Get the number of primitives of all registered maps, this value is set in the database automatically via SQL, so no setter exists :return: None if not found

get_number_of_volumes()[source]

Get the number of volumes of all registered maps, this value is set in the database automatically via SQL, so no setter exists :return: None if not found

get_vector_register()[source]

Get the vector map register table name :return: None if not found

number_of_areas

Get the number of areas of all registered maps, this value is set in the database automatically via SQL, so no setter exists :return: None if not found

number_of_boundaries

Get the number of boundaries of all registered maps, this value is set in the database automatically via SQL, so no setter exists :return: None if not found

number_of_centroids

Get the number of centroids of all registered maps, this value is set in the database automatically via SQL, so no setter exists :return: None if not found

number_of_faces

Get the number of faces of all registered maps, this value is set in the database automatically via SQL, so no setter exists :return: None if not found

number_of_holes

Get the number of holes of all registered maps, this value is set in the database automatically via SQL, so no setter exists :return: None if not found

number_of_islands

Get the number of islands of all registered maps, this value is set in the database automatically via SQL, so no setter exists :return: None if not found

number_of_kernels

Get the number of kernels of all registered maps, this value is set in the database automatically via SQL, so no setter exists :return: None if not found

number_of_lines

Get the number of lines of all registered maps, this value is set in the database automatically via SQL, so no setter exists :return: None if not found

number_of_nodes

Get the number of nodes of all registered maps, this value is set in the database automatically via SQL, so no setter exists :return: None if not found

number_of_points

Get the number of points of all registered maps, this value is set in the database automatically via SQL, so no setter exists :return: None if not found

number_of_primitives

Get the number of primitives of all registered maps, this value is set in the database automatically via SQL, so no setter exists :return: None if not found

number_of_volumes

Get the number of volumes of all registered maps, this value is set in the database automatically via SQL, so no setter exists :return: None if not found

print_info()[source]

Print information about this class in human readable style

print_shell_info()[source]

Print information about this class in shell style

set_vector_register(vector_register)[source]

Set the vector map register table name

vector_register

Get the vector map register table name :return: None if not found

class temporal.metadata.VectorMetadata(ident=None, is_3d=False, number_of_points=None, number_of_lines=None, number_of_boundaries=None, number_of_centroids=None, number_of_faces=None, number_of_kernels=None, number_of_primitives=None, number_of_nodes=None, number_of_areas=None, number_of_islands=None, number_of_holes=None, number_of_volumes=None)[source]

Bases: temporal.base.SQLDatabaseInterface

This is the vector metadata class

This class is the interface to the vector_metadata table in the temporal database that stores the metadata of all registered vector maps.

Usage:

>>> init()
>>> meta = VectorMetadata(ident="lidar@PERMANENT", is_3d=True,
... number_of_points=1, number_of_lines=2, number_of_boundaries=3,
... number_of_centroids=4, number_of_faces=5, number_of_kernels=6,
... number_of_primitives=7, number_of_nodes=8, number_of_areas=9,
... number_of_islands=10, number_of_holes=11, number_of_volumes=12)
>>> meta.id
'lidar@PERMANENT'
>>> meta.is_3d
True
>>> meta.number_of_points
1
>>> meta.number_of_lines
2
>>> meta.number_of_boundaries
3
>>> meta.number_of_centroids
4
>>> meta.number_of_faces
5
>>> meta.number_of_kernels
6
>>> meta.number_of_primitives
7
>>> meta.number_of_nodes
8
>>> meta.number_of_areas
9
>>> meta.number_of_islands
10
>>> meta.number_of_holes
11
>>> meta.number_of_volumes
12
>>> meta.print_info()
 +-------------------- Metadata information ----------------------------------+
 | Is map 3d .................. True
 | Number of points ........... 1
 | Number of lines ............ 2
 | Number of boundaries ....... 3
 | Number of centroids ........ 4
 | Number of faces ............ 5
 | Number of kernels .......... 6
 | Number of primitives ....... 7
 | Number of nodes ............ 8
 | Number of areas ............ 9
 | Number of islands .......... 10
 | Number of holes ............ 11
 | Number of volumes .......... 12
>>> meta.print_shell_info()
is_3d=True
points=1
lines=2
boundaries=3
centroids=4
faces=5
kernels=6
primitives=7
nodes=8
areas=9
islands=10
holes=11
volumes=12
get_3d_info()[source]

Return True if the map is three dimensional, False if not and None if not info was found

get_id()[source]

Convenient method to get the unique identifier (primary key) :return: None if not found

get_number_of_areas()[source]

Get the number of areas of the vector map :return: None if not found

get_number_of_boundaries()[source]

Get the number of boundaries of the vector map :return: None if not found

get_number_of_centroids()[source]

Get the number of centroids of the vector map :return: None if not found

get_number_of_faces()[source]

Get the number of faces of the vector map :return: None if not found

get_number_of_holes()[source]

Get the number of holes of the vector map :return: None if not found

get_number_of_islands()[source]

Get the number of islands of the vector map :return: None if not found

get_number_of_kernels()[source]

Get the number of kernels of the vector map :return: None if not found

get_number_of_lines()[source]

Get the number of lines of the vector map :return: None if not found

get_number_of_nodes()[source]

Get the number of nodes of the vector map :return: None if not found

get_number_of_points()[source]

Get the number of points of the vector map :return: None if not found

get_number_of_primitives()[source]

Get the number of primitives of the vector map :return: None if not found

get_number_of_volumes()[source]

Get the number of volumes of the vector map :return: None if not found

id

Convenient method to get the unique identifier (primary key) :return: None if not found

is_3d

Return True if the map is three dimensional, False if not and None if not info was found

number_of_areas

Get the number of areas of the vector map :return: None if not found

number_of_boundaries

Get the number of boundaries of the vector map :return: None if not found

number_of_centroids

Get the number of centroids of the vector map :return: None if not found

number_of_faces

Get the number of faces of the vector map :return: None if not found

number_of_holes

Get the number of holes of the vector map :return: None if not found

number_of_islands

Get the number of islands of the vector map :return: None if not found

number_of_kernels

Get the number of kernels of the vector map :return: None if not found

number_of_lines

Get the number of lines of the vector map :return: None if not found

number_of_nodes

Get the number of nodes of the vector map :return: None if not found

number_of_points

Get the number of points of the vector map :return: None if not found

number_of_primitives

Get the number of primitives of the vector map :return: None if not found

number_of_volumes

Get the number of volumes of the vector map :return: None if not found

print_info()[source]

Print information about this class in human readable style

print_shell_info()[source]

Print information about this class in shell style

set_3d_info(is_3d)[source]

Set True if the vector map is three dimensional

set_id(ident)[source]

Convenient method to set the unique identifier (primary key)

set_number_of_areas(number_of_areas)[source]

Set the number of areas of the vector map

set_number_of_boundaries(number_of_boundaries)[source]

Set the number of boundaries of the vector map

set_number_of_centroids(number_of_centroids)[source]

Set the number of centroids of the vector map

set_number_of_faces(number_of_faces)[source]

Set the number of faces of the vector map

set_number_of_holes(number_of_holes)[source]

Set the number of holes of the vector map

set_number_of_islands(number_of_islands)[source]

Set the number of islands of the vector map

set_number_of_kernels(number_of_kernels)[source]

Set the number of kernels of the vector map

set_number_of_lines(number_of_lines)[source]

Set the number of lines of the vector map

set_number_of_nodes(number_of_nodes)[source]

Set the number of nodes of the vector map

set_number_of_points(number_of_points)[source]

Set the number of points of the vector map

set_number_of_primitives(number_of_primitives)[source]

Set the number of primitives of the vector map

set_number_of_volumes(number_of_volumes)[source]

Set the number of volumes of the vector map

temporal.open_stds module

Functions to open or create space time datasets

Usage:

import grass.temporal as tgis

tgis.register_maps_in_space_time_dataset(type, name, maps)

(C) 2012-2014 by the GRASS Development Team This program is free software under the GNU General Public License (>=v2). Read the file COPYING that comes with GRASS for details.

authors:Soeren Gebbert
temporal.open_stds.check_new_map_dataset(name, layer=None, type='raster', overwrite=False, dbif=None)[source]
Check if a new map dataset of a specific type can be created in
the temporal database
Parameters:
  • name – The name of the new map dataset
  • layer – The layer of the new map dataset
  • type – The type of the new map dataset (raster, vector, raster3d)
  • dbif – The temporal database interface to be used
  • overwrite – Flag to allow overwriting
Returns:

A map dataset object

This function will raise a FatalError in case of an error.

temporal.open_stds.check_new_stds(name, type, dbif=None, overwrite=False)[source]

Check if a new space time dataset of a specific type can be created

Parameters:
  • name – The name of the new space time dataset
  • type – The type of the new space time dataset (strd, str3ds, stvds, raster, vector, raster3d)
  • dbif – The temporal database interface to be used
  • overwrite – Flag to allow overwriting
Returns:

A space time dataset object that must be filled with content before insertion in the temporal database

This function will raise a FatalError in case of an error.

temporal.open_stds.open_new_map_dataset(name, layer=None, type='raster', temporal_extent=None, overwrite=False, dbif=None)[source]
Create a new map dataset object of a specific type that can be
registered in the temporal database
Parameters:
  • name – The name of the new map dataset
  • layer – The layer of the new map dataset
  • type – The type of the new map dataset (raster, vector, raster3d)
  • dbif – The temporal database interface to be used
  • overwrite – Flag to allow overwriting
Returns:

A map dataset object

temporal.open_stds.open_new_stds(name, type, temporaltype, title, descr, semantic, dbif=None, overwrite=False)[source]

Create a new space time dataset of a specific type

Parameters:
  • name – The name of the new space time dataset
  • type – The type of the new space time dataset (strd, str3ds, stvds, raster, vector, raster3d)
  • temporaltype – The temporal type (relative or absolute)
  • title – The title
  • descr – The dataset description
  • semantic – Semantical information
  • dbif – The temporal database interface to be used
  • overwrite – Flag to allow overwriting
Returns:

The new created space time dataset

This function will raise a FatalError in case of an error.

temporal.open_stds.open_old_stds(name, type, dbif=None)[source]

This function opens an existing space time dataset and return the created and initialized object of the specified type.

This function will call exit() or raise a grass.pygrass.messages.FatalError in case the type is wrong, or the space time dataset was not found.

Parameters:
  • name – The name of the space time dataset, if the name does not contain the mapset (name@mapset) then the current mapset will be used to identifiy the space time dataset
  • type – The type of the space time dataset (strd, str3ds, stvds, raster, vector, raster3d)
  • dbif – The optional database interface to be used
Returns:

New stds object

temporal.register module

Functions to register map layer in space time datasets and the temporal database

Usage:

import grass.temporal as tgis

tgis.register_maps_in_space_time_dataset(type, name, maps)

(C) 2012-2013 by the GRASS Development Team This program is free software under the GNU General Public License (>=v2). Read the file COPYING that comes with GRASS for details.

authors:Soeren Gebbert
temporal.register.assign_valid_time_to_map(ttype, map, start, end, unit, increment=None, mult=1, interval=False)[source]

Assign the valid time to a map dataset

Parameters:
  • ttype – The temporal type which should be assigned and which the time format is of
  • map – A map dataset object derived from abstract_map_dataset
  • start – The start date and time of the first map (format absolute: “yyyy-mm-dd HH:MM:SS” or “yyyy-mm-dd”, format relative is integer 5)
  • end – The end date and time of the first map (format absolute: “yyyy-mm-dd HH:MM:SS” or “yyyy-mm-dd”, format relative is integer 5)
  • unit – The unit of the relative time: years, months, days, hours, minutes, seconds
  • increment – Time increment between maps for time stamp creation (format absolute: NNN seconds, minutes, hours, days, weeks, months, years; format relative is integer 1)
  • mult – A multiplier for the increment
  • interval – If True, time intervals are created in case the start time and an increment is provided
temporal.register.register_map_object_list(type, map_list, output_stds, delete_empty, unit, dbif=None)[source]

Register a list of AbstractMapDataset objects in the temporal database and optional in a space time dataset.

Parameters:
  • type – The type of the map layer (raster, raster_3d, vector)
  • map_list – List of AbstractMapDataset objects
  • output_stds – The output stds
  • delete_empty – Set True to delete empty map layer found in the map_list
  • unit – The temporal unit of the space time dataset
  • dbif – The database interface to be used
temporal.register.register_maps_in_space_time_dataset(type, name, maps=None, file=None, start=None, end=None, unit=None, increment=None, dbif=None, interval=False, fs='|', update_cmd_list=True)[source]

Use this method to register maps in space time datasets.

Additionally a start time string and an increment string can be specified to assign a time interval automatically to the maps.

It takes care of the correct update of the space time datasets from all registered maps.

Parameters:
  • type – The type of the maps raster, raster_3d or vector
  • name – The name of the space time dataset. Maps will be registered in the temporal database if the name was set to None
  • maps – A comma separated list of map names
  • file – Input file, one map per line map with start and optional end time
  • start – The start date and time of the first map (format absolute: “yyyy-mm-dd HH:MM:SS” or “yyyy-mm-dd”, format relative is integer 5)
  • end – The end date and time of the first map (format absolute: “yyyy-mm-dd HH:MM:SS” or “yyyy-mm-dd”, format relative is integer 5)
  • unit – The unit of the relative time: years, months, days, hours, minutes, seconds
  • increment – Time increment between maps for time stamp creation (format absolute: NNN seconds, minutes, hours, days, weeks, months, years; format relative: 1.0)
  • dbif – The database interface to be used
  • interval – If True, time intervals are created in case the start time and an increment is provided
  • fs – Field separator used in input file
  • update_cmd_list – If is True, the command that was invoking this process will be written to the process history

temporal.sampling module

Sampling functions for space time datasets

Usage:

import grass.temporal as tgis

tgis.register_maps_in_space_time_dataset(type, name, maps)

(C) 2012-2013 by the GRASS Development Team This program is free software under the GNU General Public License (>=v2). Read the file COPYING that comes with GRASS for details.

authors:Soeren Gebbert
temporal.sampling.sample_stds_by_stds_topology(intype, sampletype, inputs, sampler, header, separator, method, spatial=False, print_only=True)[source]

Sample the input space time datasets with a sample space time dataset, return the created map matrix and optionally print the result to stdout

In case multiple maps are located in the current granule, the map names are separated by comma.

In case a layer is present, the names map ids are extended in this form: “name:layer@mapset”

Attention: Do not use the comma as separator for printing

param intype:Type of the input space time dataset (strds, stvds or str3ds)
param sampletype:
 Type of the sample space time datasets (strds, stvds or str3ds)
param inputs:Name or comma separated names of space time datasets or a list of map names
param sampler:Name of a space time dataset used for temporal sampling
param header:Set True to print column names
param separator:
 The field separator character between the columns
param method:The method to be used for temporal sampling (start,during,contain,overlap,equal) as comma separated string or as a list of methods
param spatial:Perform spatial overlapping check
param print_only:
 If set True (default) then the result of the sampling will be printed to stdout, if set to False the resulting map matrix will be returned.
return:The map matrix or None if nothing found

temporal.space_time_datasets module

Map layer and space time dataset classes

(C) 2012-2013 by the GRASS Development Team This program is free software under the GNU General Public License (>=v2). Read the file COPYING that comes with GRASS for details.

authors:Soeren Gebbert
class temporal.space_time_datasets.Raster3DDataset(ident)[source]

Bases: temporal.abstract_map_dataset.AbstractMapDataset

Raster3d dataset class

This class provides functions to select, update, insert or delete raster3d map information and valid time stamps into the SQL temporal database.

Usage:

>>> import grass.script as grass
>>> init()
>>> grass.use_temp_region()
>>> grass.run_command("g.region", n=80.0, s=0.0, e=120.0, w=0.0,
... t=100.0, b=0.0, res=10.0, res3=10.0)
0
>>> grass.run_command("r3.mapcalc", overwrite=True, quiet=True,
...                   expression="str3ds_map_test_case = 1")
0
>>> grass.run_command("r3.timestamp", map="str3ds_map_test_case",
...                   date="15 jan 1999", quiet=True)
0
>>> mapset = get_current_mapset()
>>> name = "str3ds_map_test_case"
>>> identifier = "%s@%s" % (name, mapset)
>>> r3map = Raster3DDataset(identifier)
>>> r3map.map_exists()
True
>>> r3map.read_timestamp_from_grass()
True
>>> r3map.get_temporal_extent_as_tuple()
(datetime.datetime(1999, 1, 15, 0, 0), None)
>>> r3map.load()
True
>>> r3map.spatial_extent.print_info()
 +-------------------- Spatial extent ----------------------------------------+
 | North:...................... 80.0
 | South:...................... 0.0
 | East:.. .................... 120.0
 | West:....................... 0.0
 | Top:........................ 100.0
 | Bottom:..................... 0.0
>>> r3map.absolute_time.print_info()
 +-------------------- Absolute time -----------------------------------------+
 | Start time:................. 1999-01-15 00:00:00
 | End time:................... None
>>> r3map.metadata.print_info()
 +-------------------- Metadata information ----------------------------------+
 | Datatype:................... DCELL
 | Number of columns:.......... 8
 | Number of rows:............. 12
 | Number of cells:............ 960
 | North-South resolution:..... 10.0
 | East-west resolution:....... 10.0
 | Minimum value:.............. 1.0
 | Maximum value:.............. 1.0
 | Number of depths:........... 10
 | Top-Bottom resolution:...... 10.0

>>> grass.run_command("r3.timestamp", map="str3ds_map_test_case",
...                   date="2 years", quiet=True)
0
>>> r3map.read_timestamp_from_grass()
True
>>> r3map.get_temporal_extent_as_tuple()
(2, None)
>>> r3map.get_relative_time_unit()
'years'

>>> newmap = r3map.get_new_instance("new@PERMANENT")
>>> isinstance(newmap, Raster3DDataset)
True
>>> newstr3ds = r3map.get_new_stds_instance("new@PERMANENT")
>>> isinstance(newstr3ds, SpaceTimeRaster3DDataset)
True
>>> r3map.get_type()
'raster3d'
>>> r3map.set_absolute_time(start_time=datetime(2001,1,1),
...                        end_time=datetime(2012,1,1))
True
>>> r3map.get_absolute_time()
(datetime.datetime(2001, 1, 1, 0, 0), datetime.datetime(2012, 1, 1, 0, 0))
>>> r3map.get_temporal_extent_as_tuple()
(datetime.datetime(2001, 1, 1, 0, 0), datetime.datetime(2012, 1, 1, 0, 0))
>>> r3map.get_name()
u'str3ds_map_test_case'
>>> r3map.get_mapset() == mapset
True
>>> r3map.get_temporal_type()
'absolute'
>>> r3map.get_spatial_extent_as_tuple()
(80.0, 0.0, 120.0, 0.0, 100.0, 0.0)
>>> r3map.is_time_absolute()
True
>>> r3map.is_time_relative()
False
>>> grass.run_command("g.remove", flags="f", type="raster_3d", name=name, quiet=True)
0
>>> grass.del_temp_region()
get_new_instance(ident)[source]

Return a new instance with the type of this class

get_new_stds_instance(ident)[source]

Return a new space time dataset instance in which maps are stored with the type of this class

get_np_array()[source]

Return this 3D raster map as memmap numpy style array to access the 3D raster values in numpy style without loading the whole map in the RAM.

In case this 3D raster map does exists in the grass spatial database, the map will be exported using r3.out.bin to a temporary location and assigned to the memmap object that is returned by this function.

In case the 3D raster map does not exist, an empty temporary binary file will be created and assigned to the memap object.

You need to call the write function to write the memmap array back into grass.

get_type()[source]
has_grass_timestamp()[source]

Check if a grass file bsased time stamp exists for this map.

Returns:True if success, False on error
is_stds()[source]

Return True if this class is a space time dataset

Returns:True if this class is a space time dataset, False otherwise
load()[source]

Load all info from an existing 3d raster map into the internal structure

This method checks first if the map exists, in case it exists the metadata of the map is put into this object and True is returned

Returns:True is the map exists and the metadata was filled successfully and getting the data was successful, False otherwise
map_exists()[source]

Return True in case the map exists in the grass spatial database

Returns:True if map exists, False otherwise
read_timestamp_from_grass()[source]

Read the timestamp of this map from the map metadata in the grass file system based spatial database and set the internal time stamp that should be insert/updated in the temporal database.

Returns:True if success, False on error
remove_timestamp_from_grass()[source]

Remove the timestamp from the grass file system based spatial database

Returns:True if success, False on error
reset(ident)[source]

Reset the internal structure and set the identifier

spatial_disjoint_union(dataset)[source]

Return the three or two dimensional union as spatial_extent object.

Parameters:dataset – The abstract dataset to create a union with
Returns:The union spatial extent
spatial_intersection(dataset)[source]

Return the three or two dimensional intersection as spatial_extent object or None in case no intersection was found.

Parameters:dataset – The abstract dataset to intersect with
Returns:The intersection spatial extent or None
spatial_overlapping(dataset)[source]

Return True if the spatial extents overlap

spatial_relation(dataset)[source]

Return the two or three dimensional spatial relation

spatial_union(dataset)[source]

Return the three or two dimensional union as spatial_extent object or None in case the extents does not overlap or meet.

Parameters:dataset – The abstract dataset to create a union with
Returns:The union spatial extent or None
write_timestamp_to_grass()[source]

Write the timestamp of this map into the map metadata in the grass file system based spatial database.

Internally the libgis API functions are used for writing

return:True if success, False on error
class temporal.space_time_datasets.RasterDataset(ident)[source]

Bases: temporal.abstract_map_dataset.AbstractMapDataset

Raster dataset class

This class provides functions to select, update, insert or delete raster map information and valid time stamps into the SQL temporal database.

Usage:

>>> import grass.script as grass
>>> init()
>>> grass.use_temp_region()
>>> grass.run_command("g.region", n=80.0, s=0.0, e=120.0, w=0.0,
... t=1.0, b=0.0, res=10.0)
0
>>> grass.run_command("r.mapcalc", overwrite=True, quiet=True,
... expression="strds_map_test_case = 1")
0
>>> grass.run_command("r.timestamp", map="strds_map_test_case",
...                   date="15 jan 1999", quiet=True)
0
>>> mapset = get_current_mapset()
>>> name = "strds_map_test_case"
>>> identifier = "%s@%s" % (name, mapset)
>>> rmap = RasterDataset(identifier)
>>> rmap.map_exists()
True
>>> rmap.read_timestamp_from_grass()
True
>>> rmap.get_temporal_extent_as_tuple()
(datetime.datetime(1999, 1, 15, 0, 0), None)
>>> rmap.load()
True
>>> rmap.spatial_extent.print_info()
 +-------------------- Spatial extent ----------------------------------------+
 | North:...................... 80.0
 | South:...................... 0.0
 | East:.. .................... 120.0
 | West:....................... 0.0
 | Top:........................ 0.0
 | Bottom:..................... 0.0
>>> rmap.absolute_time.print_info()
 +-------------------- Absolute time -----------------------------------------+
 | Start time:................. 1999-01-15 00:00:00
 | End time:................... None
>>> rmap.metadata.print_info()
 +-------------------- Metadata information ----------------------------------+
 | Datatype:................... CELL
 | Number of columns:.......... 8
 | Number of rows:............. 12
 | Number of cells:............ 96
 | North-South resolution:..... 10.0
 | East-west resolution:....... 10.0
 | Minimum value:.............. 1.0
 | Maximum value:.............. 1.0

>>> grass.run_command("r.timestamp", map="strds_map_test_case",
...                   date="2 years", quiet=True)
0
>>> rmap.read_timestamp_from_grass()
True
>>> rmap.get_temporal_extent_as_tuple()
(2, None)
>>> rmap.get_relative_time_unit()
'years'

>>> newmap = rmap.get_new_instance("new@PERMANENT")
>>> isinstance(newmap, RasterDataset)
True
>>> newstrds = rmap.get_new_stds_instance("new@PERMANENT")
>>> isinstance(newstrds, SpaceTimeRasterDataset)
True
>>> rmap.get_type()
'raster'
>>> rmap.set_absolute_time(start_time=datetime(2001,1,1),
...                        end_time=datetime(2012,1,1))
True
>>> rmap.get_absolute_time()
(datetime.datetime(2001, 1, 1, 0, 0), datetime.datetime(2012, 1, 1, 0, 0))
>>> rmap.get_temporal_extent_as_tuple()
(datetime.datetime(2001, 1, 1, 0, 0), datetime.datetime(2012, 1, 1, 0, 0))
>>> rmap.get_name()
u'strds_map_test_case'
>>> rmap.get_mapset() == mapset
True
>>> rmap.get_temporal_type()
'absolute'
>>> rmap.get_spatial_extent_as_tuple()
(80.0, 0.0, 120.0, 0.0, 0.0, 0.0)
>>> rmap.is_time_absolute()
True
>>> rmap.is_time_relative()
False

>>> grass.run_command("g.remove", flags="f", type="raster", name=name, quiet=True)
0
>>> grass.del_temp_region()
get_new_instance(ident)[source]

Return a new instance with the type of this class

get_new_stds_instance(ident)[source]

Return a new space time dataset instance in which maps are stored with the type of this class

get_np_array()[source]

Return this raster map as memmap numpy style array to access the raster values in numpy style without loading the whole map in the RAM.

In case this raster map does exists in the grass spatial database, the map will be exported using r.out.bin to a temporary location and assigned to the memmap object that is returned by this function.

In case the raster map does not exist, an empty temporary binary file will be created and assigned to the memap object.

You need to call the write function to write the memmap array back into grass.

get_type()[source]
has_grass_timestamp()[source]

Check if a grass file bsased time stamp exists for this map.

Returns:True if success, False on error
is_stds()[source]

Return True if this class is a space time dataset

Returns:True if this class is a space time dataset, False otherwise
load()[source]

Load all info from an existing raster map into the internal structure

This method checks first if the map exists, in case it exists the metadata of the map is put into this object and True is returned

Returns:True is the map exists and the metadata was filled successfully and getting the data was successful, False otherwise
map_exists()[source]

Return True in case the map exists in the grass spatial database

Returns:True if map exists, False otherwise
read_timestamp_from_grass()[source]

Read the timestamp of this map from the map metadata in the grass file system based spatial database and set the internal time stamp that should be insert/updated in the temporal database.

Returns:True if success, False on error
remove_timestamp_from_grass()[source]

Remove the timestamp from the grass file system based spatial database

Internally the libgis API functions are used for removal

Returns:True if success, False on error
reset(ident)[source]

Reset the internal structure and set the identifier

spatial_disjoint_union(dataset)[source]

Return the two dimensional union as spatial_extent object.

Parameters:dataset – The abstract dataset to create a union with
Returns:The union spatial extent
spatial_intersection(dataset)[source]

Return the two dimensional intersection as spatial_extent object or None in case no intersection was found.

Parameters:dataset – The abstract dataset to intersect with
Returns:The intersection spatial extent or None
spatial_overlapping(dataset)[source]

Return True if the spatial extents 2d overlap

spatial_relation(dataset)[source]

Return the two dimensional spatial relation

spatial_union(dataset)[source]

Return the two dimensional union as spatial_extent object or None in case the extents does not overlap or meet.

:param dataset :The abstract dataset to create a union with :return: The union spatial extent or None

write_timestamp_to_grass()[source]

Write the timestamp of this map into the map metadata in the grass file system based spatial database.

Internally the libgis API functions are used for writing

Returns:True if success, False on error
class temporal.space_time_datasets.SpaceTimeRaster3DDataset(ident)[source]

Bases: temporal.abstract_space_time_dataset.AbstractSpaceTimeDataset

Space time raster3d dataset class

get_map_register()[source]

Return the name of the map register table

get_new_instance(ident)[source]

Return a new instance with the type of this class

get_new_map_instance(ident)[source]

Return a new instance of a map dataset which is associated with the type of this class

get_type()[source]
is_stds()[source]

Return True if this class is a space time dataset

Returns:True if this class is a space time dataset, False otherwise
reset(ident)[source]

Reset the internal structure and set the identifier

set_map_register(name)[source]

Set the name of the map register table

spatial_disjoint_union(dataset)[source]

Return the three or two dimensional union as spatial_extent object.

Parameters:dataset – The abstract dataset to create a union with
Returns:The union spatial extent
spatial_intersection(dataset)[source]

Return the three or two dimensional intersection as spatial_extent object or None in case no intersection was found.

Parameters:dataset – The abstract dataset to intersect with
Returns:The intersection spatial extent or None
spatial_overlapping(dataset)[source]

Return True if the spatial extents overlap

spatial_relation(dataset)[source]

Return the two or three dimensional spatial relation

spatial_union(dataset)[source]

Return the three or two dimensional union as spatial_extent object or None in case the extents does not overlap or meet.

Parameters:dataset – The abstract dataset to create a union with
Returns:The union spatial extent or None
class temporal.space_time_datasets.SpaceTimeRasterDataset(ident)[source]

Bases: temporal.abstract_space_time_dataset.AbstractSpaceTimeDataset

Space time raster dataset class

get_map_register()[source]

Return the name of the map register table

get_new_instance(ident)[source]

Return a new instance with the type of this class

get_new_map_instance(ident)[source]

Return a new instance of a map dataset which is associated ” “with the type of this class

get_type()[source]
is_stds()[source]

Return True if this class is a space time dataset

Returns:True if this class is a space time dataset, False otherwise
reset(ident)[source]

Reset the internal structure and set the identifier

set_map_register(name)[source]

Set the name of the map register table

spatial_disjoint_union(dataset)[source]

Return the two dimensional union as spatial_extent object.

Parameters:dataset – The abstract dataset to create a union with
Returns:The union spatial extent
spatial_intersection(dataset)[source]

Return the two dimensional intersection as spatial_extent object or None in case no intersection was found.

Parameters:dataset – The abstract dataset to intersect with
Returns:The intersection spatial extent or None
spatial_overlapping(dataset)[source]

Return True if the spatial extents 2d overlap

spatial_relation(dataset)[source]

Return the two dimensional spatial relation

spatial_union(dataset)[source]

Return the two dimensional union as spatial_extent object or None in case the extents does not overlap or meet.

Parameters:dataset – The abstract dataset to create a union with
Returns:The union spatial extent or None
class temporal.space_time_datasets.SpaceTimeVectorDataset(ident)[source]

Bases: temporal.abstract_space_time_dataset.AbstractSpaceTimeDataset

Space time vector dataset class

get_map_register()[source]

Return the name of the map register table

get_new_instance(ident)[source]

Return a new instance with the type of this class

get_new_map_instance(ident)[source]

Return a new instance of a map dataset which is associated with the type of this class

get_type()[source]
is_stds()[source]

Return True if this class is a space time dataset

Returns:True if this class is a space time dataset, False otherwise
reset(ident)[source]

Reset the internal structure and set the identifier

set_map_register(name)[source]

Set the name of the map register table

spatial_disjoint_union(dataset)[source]

Return the two dimensional union as spatial_extent object.

Parameters:dataset – The abstract dataset to create a union with
Returns:The union spatial extent
spatial_intersection(dataset)[source]

Return the two dimensional intersection as spatial_extent object or None in case no intersection was found.

Parameters:dataset – The abstract dataset to intersect with
Returns:The intersection spatial extent or None
spatial_overlapping(dataset)[source]

Return True if the spatial extents 2d overlap

spatial_relation(dataset)[source]

Return the two dimensional spatial relation

spatial_union(dataset)[source]

Return the two dimensional union as spatial_extent object or None in case the extents does not overlap or meet.

Parameters:dataset – The abstract dataset to create a union with
Returns:The union spatial extent or None
class temporal.space_time_datasets.VectorDataset(ident)[source]

Bases: temporal.abstract_map_dataset.AbstractMapDataset

Vector dataset class

This class provides functions to select, update, insert or delete vector map information and valid time stamps into the SQL temporal database.

Usage:

>>> import grass.script as grass
>>> init()
>>> grass.use_temp_region()
>>> grass.run_command("g.region", n=80.0, s=0.0, e=120.0, w=0.0,
... t=1.0, b=0.0, res=10.0)
0
>>> grass.run_command("v.random", overwrite=True, output="stvds_map_test_case",
... n=100, zmin=0, zmax=100, flags="z", column="elevation", quiet=True)
0
>>> grass.run_command("v.timestamp", map="stvds_map_test_case",
...                   date="15 jan 1999", quiet=True)
0
>>> mapset = get_current_mapset()
>>> name = "stvds_map_test_case"
>>> identifier = "%s@%s" % (name, mapset)
>>> vmap = VectorDataset(identifier)
>>> vmap.map_exists()
True
>>> vmap.read_timestamp_from_grass()
True
>>> vmap.get_temporal_extent_as_tuple()
(datetime.datetime(1999, 1, 15, 0, 0), None)
>>> vmap.load()
True
>>> vmap.absolute_time.print_info()
 +-------------------- Absolute time -----------------------------------------+
 | Start time:................. 1999-01-15 00:00:00
 | End time:................... None
>>> vmap.metadata.print_info()
 +-------------------- Metadata information ----------------------------------+
 | Is map 3d .................. True
 | Number of points ........... 100
 | Number of lines ............ 0
 | Number of boundaries ....... 0
 | Number of centroids ........ 0
 | Number of faces ............ 0
 | Number of kernels .......... 0
 | Number of primitives ....... 100
 | Number of nodes ............ 0
 | Number of areas ............ 0
 | Number of islands .......... 0
 | Number of holes ............ 0
 | Number of volumes .......... 0

>>> grass.run_command("v.timestamp", map="stvds_map_test_case",
...                   date="2 years", quiet=True)
0
>>> vmap.read_timestamp_from_grass()
True
>>> vmap.get_temporal_extent_as_tuple()
(2, None)
>>> vmap.get_relative_time_unit()
'years'

>>> newmap = vmap.get_new_instance("new@PERMANENT")
>>> isinstance(newmap, VectorDataset)
True
>>> newstvds = vmap.get_new_stds_instance("new@PERMANENT")
>>> isinstance(newstvds, SpaceTimeVectorDataset)
True
>>> vmap.get_type()
'vector'
>>> vmap.set_absolute_time(start_time=datetime(2001,1,1),
...                        end_time=datetime(2012,1,1))
True
>>> vmap.get_absolute_time()
(datetime.datetime(2001, 1, 1, 0, 0), datetime.datetime(2012, 1, 1, 0, 0))
>>> vmap.get_temporal_extent_as_tuple()
(datetime.datetime(2001, 1, 1, 0, 0), datetime.datetime(2012, 1, 1, 0, 0))
>>> vmap.get_name()
u'stvds_map_test_case'
>>> vmap.get_mapset() == mapset
True
>>> vmap.get_temporal_type()
'absolute'
>>> vmap.is_time_absolute()
True
>>> vmap.is_time_relative()
False
>>> grass.run_command("g.remove", flags="f", type="vector", name=name, quiet=True)
0
>>> grass.del_temp_region()
get_layer()[source]

Return the layer

get_new_instance(ident)[source]

Return a new instance with the type of this class

get_new_stds_instance(ident)[source]

Return a new space time dataset instance in which maps are stored with the type of this class

get_type()[source]
has_grass_timestamp()[source]

Check if a grass file bsased time stamp exists for this map.

is_stds()[source]

Return True if this class is a space time dataset

Returns:True if this class is a space time dataset, False otherwise
load()[source]

Load all info from an existing vector map into the internal structure

This method checks first if the map exists, in case it exists the metadata of the map is put into this object and True is returned

Returns:True is the map exists and the metadata was filled successfully and getting the data was successful, False otherwise
map_exists()[source]

Return True in case the map exists in the grass spatial database

Returns:True if map exists, False otherwise
read_timestamp_from_grass()[source]

Read the timestamp of this map from the map metadata in the grass file system based spatial database and set the internal time stamp that should be insert/updated in the temporal database.

remove_timestamp_from_grass()[source]

Remove the timestamp from the grass file system based spatial database

Internally the libgis API functions are used for removal

reset(ident)[source]

Reset the internal structure and set the identifier

spatial_disjoint_union(dataset)[source]

Return the two dimensional union as spatial_extent object.

Parameters:dataset – The abstract dataset to create a union with
Returns:The union spatial extent
spatial_intersection(dataset)[source]

Return the two dimensional intersection as spatial_extent object or None in case no intersection was found.

Parameters:dataset – The abstract dataset to intersect with
Returns:The intersection spatial extent or None
spatial_overlapping(dataset)[source]

Return True if the spatial extents 2d overlap

spatial_relation(dataset)[source]

Return the two dimensional spatial relation

spatial_union(dataset)[source]

Return the two dimensional union as spatial_extent object or None in case the extents does not overlap or meet.

Parameters:dataset – The abstract dataset to create a union with
Returns:The union spatial extent or None
write_timestamp_to_grass()[source]

Write the timestamp of this map into the map metadata in the grass file system based spatial database.

Internally the libgis API functions are used for writing

temporal.spatial_extent module

Spatial extents classes for map layer and space time datasets

Usage:

>>> import grass.temporal as tgis
>>> tgis.init()
>>> extent = tgis.RasterSpatialExtent(
... ident="raster@PERMANENT", north=90, south=90, east=180, west=180,
... top=100, bottom=-20)
>>> extent = tgis.Raster3DSpatialExtent(
... ident="raster3d@PERMANENT", north=90, south=90, east=180, west=180,
... top=100, bottom=-20)
>>> extent = tgis.VectorSpatialExtent(
... ident="vector@PERMANENT", north=90, south=90, east=180, west=180,
... top=100, bottom=-20)
>>> extent = tgis.STRDSSpatialExtent(
... ident="strds@PERMANENT", north=90, south=90, east=180, west=180,
... top=100, bottom=-20)
>>> extent = tgis.STR3DSSpatialExtent(
... ident="str3ds@PERMANENT", north=90, south=90, east=180, west=180,
... top=100, bottom=-20)
>>> extent = tgis.STVDSSpatialExtent(
... ident="stvds@PERMANENT", north=90, south=90, east=180, west=180,
... top=100, bottom=-20)

(C) 2012-2013 by the GRASS Development Team This program is free software under the GNU General Public License (>=v2). Read the file COPYING that comes with GRASS for details.

authors:Soeren Gebbert
class temporal.spatial_extent.Raster3DSpatialExtent(ident=None, north=None, south=None, east=None, west=None, top=None, bottom=None)[source]

Bases: temporal.spatial_extent.SpatialExtent

class temporal.spatial_extent.RasterSpatialExtent(ident=None, north=None, south=None, east=None, west=None, top=None, bottom=None)[source]

Bases: temporal.spatial_extent.SpatialExtent

class temporal.spatial_extent.STR3DSSpatialExtent(ident=None, north=None, south=None, east=None, west=None, top=None, bottom=None)[source]

Bases: temporal.spatial_extent.SpatialExtent

class temporal.spatial_extent.STRDSSpatialExtent(ident=None, north=None, south=None, east=None, west=None, top=None, bottom=None)[source]

Bases: temporal.spatial_extent.SpatialExtent

class temporal.spatial_extent.STVDSSpatialExtent(ident=None, north=None, south=None, east=None, west=None, top=None, bottom=None)[source]

Bases: temporal.spatial_extent.SpatialExtent

class temporal.spatial_extent.SpatialExtent(table=None, ident=None, north=None, south=None, east=None, west=None, top=None, bottom=None, proj='XY')[source]

Bases: temporal.base.SQLDatabaseInterface

This is the spatial extent base class for all maps and space time datasets

This class implements a three dimensional axis aligned bounding box and functions to compute topological relationships

Usage:

>>> init()
>>> extent = SpatialExtent(table="raster_spatial_extent",
... ident="soil@PERMANENT", north=90, south=90, east=180, west=180,
... top=100, bottom=-20)
>>> extent.id
'soil@PERMANENT'
>>> extent.north
90.0
>>> extent.south
90.0
>>> extent.east
180.0
>>> extent.west
180.0
>>> extent.top
100.0
>>> extent.bottom
-20.0
>>> extent.print_info()
 +-------------------- Spatial extent ----------------------------------------+
 | North:...................... 90.0
 | South:...................... 90.0
 | East:.. .................... 180.0
 | West:....................... 180.0
 | Top:........................ 100.0
 | Bottom:..................... -20.0
>>> extent.print_shell_info()
north=90.0
south=90.0
east=180.0
west=180.0
top=100.0
bottom=-20.0
bottom

Get the bottom edge of the map :return: None if not found

contain(extent)[source]

Return True if this extent (A) contains the provided spatial extent (B) in three dimensions.

Usage:

>>> A = SpatialExtent(north=80, south=20, east=60, west=10,
... bottom=-50, top=50)
>>> B = SpatialExtent(north=79, south=21, east=59, west=11,
... bottom=-49, top=49)
>>> A.contain(B)
True
>>> B.contain(A)
False
Parameters:extent – The spatial extent
Returns:True or False
contain_2d(extent)[source]

Return True if this extent (A) contains the provided spatial extent (B) in two dimensions.

Usage:

>>> A = SpatialExtent(north=80, south=20, east=60, west=10)
>>> B = SpatialExtent(north=79, south=21, east=59, west=11)
>>> A.contain_2d(B)
True
>>> B.contain_2d(A)
False
Parameters:extent – The spatial extent
Returns:True or False
cover(extent)[source]

Return True if this extent covers the provided spatial extent in three dimensions.

The following cases are excluded:

  • contain
  • in
  • equivalent
Parameters:extent – The spatial extent
Returns:True or False
cover_2d(extent)[source]

Return True if this extent (A) covers the provided spatial extent (B) in two dimensions.

 _____    _____    _____    _____
|A  __|  |__  A|  |A | B|  |B | A|
|  |B |  | B|  |  |  |__|  |__|  |
|__|__|  |__|__|  |_____|  |_____|

 _____    _____    _____    _____
|A|B| |  |A  __|  |A _  |  |__  A|
| |_| |  |  |__|B | |B| | B|__|  |
|_____|  |_____|  |_|_|_|  |_____|

 _____    _____    _____    _____
|A|B  |  |_____|A |A|B|A|  |_____|A
| |   |  |B    |  | | | |  |_____|B
|_|___|  |_____|  |_|_|_|  |_____|A

The following cases are excluded:

  • contain
  • in
  • equivalent
Parameters:extent – The spatial extent
Returns:True or False
covered(extent)[source]

Return True if this extent is covered by the provided spatial extent in three dimensions.

The following cases are excluded:

  • contain
  • in
  • equivalent
Parameters:extent – The spatial extent
Returns:True or False
covered_2d(extent)[source]

Return True if this extent is covered by the provided spatial extent in two dimensions.

The following cases are excluded:

  • contain
  • in
  • equivalent
Parameters:extent – The spatial extent
Returns:True or False
disjoint(extent)[source]

Return True if this extent is disjoint with the provided spatial extent in three dimensions.

Parameters:extent – The spatial extent
Returns:True or False
disjoint_2d(extent)[source]

Return True if this extent (A) is disjoint with the provided spatial extent (B) in three dimensions.

  _____
 |  A  |
 |_____|
 _______
|   B   |
|_______|
Parameters:extent – The spatial extent
Returns:True or False
disjoint_union(extent)[source]

Return the three dimensional union as spatial_extent .

Usage:

   >>> A = SpatialExtent(north=80, south=20, east=60, west=10,
   ... bottom=-50, top=50)
   >>> B = SpatialExtent(north=80, south=20, east=60, west=10,
   ... bottom=-50, top=50)
   >>> C = A.disjoint_union(B)
   >>> C.print_info()
    +-------------------- Spatial extent ----------------------------------------+
    | North:...................... 80.0
    | South:...................... 20.0
    | East:.. .................... 60.0
    | West:....................... 10.0
    | Top:........................ 50.0
    | Bottom:..................... -50.0
   >>> B = SpatialExtent(north=40, south=30, east=60, west=10,
   ... bottom=-50, top=50)
   >>> C = A.disjoint_union(B)
   >>> C.print_info()
    +-------------------- Spatial extent ----------------------------------------+
    | North:...................... 80.0
    | South:...................... 20.0
    | East:.. .................... 60.0
    | West:....................... 10.0
    | Top:........................ 50.0
    | Bottom:..................... -50.0
   >>> B = SpatialExtent(north=40, south=30, east=60, west=30,
   ... bottom=-50, top=50)
   >>> C = A.disjoint_union(B)
   >>> C.print_info()
    +-------------------- Spatial extent ----------------------------------------+
    | North:...................... 80.0
    | South:...................... 20.0
    | East:.. .................... 60.0
    | West:....................... 10.0
    | Top:........................ 50.0
    | Bottom:..................... -50.0
   >>> B = SpatialExtent(north=40, south=30, east=60, west=30,
   ... bottom=-30, top=50)
   >>> C = A.disjoint_union(B)
   >>> C.print_info()
    +-------------------- Spatial extent ----------------------------------------+
    | North:...................... 80.0
    | South:...................... 20.0
    | East:.. .................... 60.0
    | West:....................... 10.0
    | Top:........................ 50.0
    | Bottom:..................... -50.0
   >>> B = SpatialExtent(north=40, south=30, east=60, west=30,
   ... bottom=-30, top=30)
   >>> C = A.disjoint_union(B)
   >>> C.print_info()
    +-------------------- Spatial extent ----------------------------------------+
    | North:...................... 80.0
    | South:...................... 20.0
    | East:.. .................... 60.0
    | West:....................... 10.0
    | Top:........................ 50.0
    | Bottom:..................... -50.0
   >>> A = SpatialExtent(north=80, south=20, east=60, west=10,
   ... bottom=-50, top=50)
   >>> B = SpatialExtent(north=90, south=80, east=70, west=20,
   ... bottom=-30, top=60)
   >>> C = A.disjoint_union(B)
   >>> C.print_info()
    +-------------------- Spatial extent ----------------------------------------+
    | North:...................... 90.0
    | South:...................... 20.0
    | East:.. .................... 70.0
    | West:....................... 10.0
    | Top:........................ 60.0
    | Bottom:..................... -50.0


:param extent: The spatial extent to create a disjoint union with
:return: The union spatial extent
disjoint_union_2d(extent)[source]

Return the two dimensional union as spatial_extent.

Parameters:extent – The spatial extent to create a union with
Returns:The union spatial extent
east

Get the eastern edge of the map :return: None if not found

equivalent(extent)[source]

Return True if this extent (A) is equal to the provided spatial extent (B) in three dimensions.

Usage:

>>> A = SpatialExtent(north=80, south=20, east=60, west=10,
... bottom=-50, top=50)
>>> B = SpatialExtent(north=80, south=20, east=60, west=10,
... bottom=-50, top=50)
>>> A.equivalent(B)
True
>>> B.equivalent(A)
True
Parameters:extent – The spatial extent
Returns:True or False
equivalent_2d(extent)[source]

Return True if this extent (A) is equal to the provided spatial extent (B) in two dimensions.

Usage:

>>> A = SpatialExtent(north=80, south=20, east=60, west=10)
>>> B = SpatialExtent(north=80, south=20, east=60, west=10)
>>> A.equivalent_2d(B)
True
>>> B.equivalent_2d(A)
True
Parameters:extent – The spatial extent
Returns:True or False
get_area()[source]

Compute the area of the extent, extent in z direction is ignored

get_bottom()[source]

Get the bottom edge of the map :return: None if not found

get_east()[source]

Get the eastern edge of the map :return: None if not found

get_id()[source]

Convenient method to get the unique identifier (primary key) :return: None if not found

get_north()[source]

Get the northern edge of the map :return: None if not found

get_projection()[source]

Get the projection of the spatial extent

get_south()[source]

Get the southern edge of the map :return: None if not found

get_spatial_extent_as_tuple()[source]

Return a tuple (north, south, east, west, top, bottom) of the spatial extent

get_spatial_extent_as_tuple_2d()[source]

Return a tuple (north, south, east, west,) of the 2d spatial extent

get_top()[source]

Get the top edge of the map :return: None if not found

get_volume()[source]

Compute the volume of the extent, in case z is zero (top == bottom or top - bottom = 1) the area is returned

get_west()[source]

Get the western edge of the map :return: None if not found

id

Convenient method to get the unique identifier (primary key) :return: None if not found

intersect(extent)[source]

Return the three dimensional intersection as spatial_extent object or None in case no intersection was found.

Usage:

   >>> A = SpatialExtent(north=80, south=20, east=60, west=10,
   ... bottom=-50, top=50)
   >>> B = SpatialExtent(north=80, south=20, east=60, west=10,
   ... bottom=-50, top=50)
   >>> C = A.intersect(B)
   >>> C.print_info()
    +-------------------- Spatial extent ----------------------------------------+
    | North:...................... 80.0
    | South:...................... 20.0
    | East:.. .................... 60.0
    | West:....................... 10.0
    | Top:........................ 50.0
    | Bottom:..................... -50.0
   >>> B = SpatialExtent(north=40, south=30, east=60, west=10,
   ... bottom=-50, top=50)
   >>> C = A.intersect(B)
   >>> C.print_info()
    +-------------------- Spatial extent ----------------------------------------+
    | North:...................... 40.0
    | South:...................... 30.0
    | East:.. .................... 60.0
    | West:....................... 10.0
    | Top:........................ 50.0
    | Bottom:..................... -50.0
   >>> B = SpatialExtent(north=40, south=30, east=60, west=30,
   ... bottom=-50, top=50)
   >>> C = A.intersect(B)
   >>> C.print_info()
    +-------------------- Spatial extent ----------------------------------------+
    | North:...................... 40.0
    | South:...................... 30.0
    | East:.. .................... 60.0
    | West:....................... 30.0
    | Top:........................ 50.0
    | Bottom:..................... -50.0
   >>> B = SpatialExtent(north=40, south=30, east=60, west=30,
   ... bottom=-30, top=50)
   >>> C = A.intersect(B)
   >>> C.print_info()
    +-------------------- Spatial extent ----------------------------------------+
    | North:...................... 40.0
    | South:...................... 30.0
    | East:.. .................... 60.0
    | West:....................... 30.0
    | Top:........................ 50.0
    | Bottom:..................... -30.0
   >>> B = SpatialExtent(north=40, south=30, east=60, west=30,
   ... bottom=-30, top=30)
   >>> C = A.intersect(B)
   >>> C.print_info()
    +-------------------- Spatial extent ----------------------------------------+
    | North:...................... 40.0
    | South:...................... 30.0
    | East:.. .................... 60.0
    | West:....................... 30.0
    | Top:........................ 30.0
    | Bottom:..................... -30.0


:param extent: The spatial extent to intersect with
:return: The intersection spatial extent
intersect_2d(extent)[source]
Return the two dimensional intersection as spatial_extent
object or None in case no intersection was found.
Parameters:extent – The spatial extent to intersect with
Returns:The intersection spatial extent
is_in(extent)[source]

Return True if this extent (A) is located in the provided spatial extent (B) in three dimensions.

Usage:

>>> A = SpatialExtent(north=79, south=21, east=59, west=11,
... bottom=-49, top=49)
>>> B = SpatialExtent(north=80, south=20, east=60, west=10,
... bottom=-50, top=50)
>>> A.is_in(B)
True
>>> B.is_in(A)
False
Parameters:extent – The spatial extent
Returns:True or False
is_in_2d(extent)[source]

Return True if this extent (A) is located in the provided spatial extent (B) in two dimensions.

 _____
|A _  |
| |_| |
|_____|B
Parameters:extent – The spatial extent
Returns:True or False
meet(extent)[source]

Return True if this extent meets with the provided spatial extent in three dimensions.

Parameters:extent – The spatial extent
Returns:True or False
meet_2d(extent)[source]

Return True if this extent (A) meets with the provided spatial extent (B) in two dimensions.

 _____ _____
|  A  |  B  |
|_____|     |
      |_____|
 _____ _____
|  B  |  A  |
|     |     |
|_____|_____|
  ___
 | A |
 |   |
 |___|
|  B  |
|     |
|_____|
 _____
|  B  |
|     |
|_____|_
  |  A  |
  |     |
  |_____|
Parameters:extent – The spatial extent
Returns:True or False
north

Get the northern edge of the map :return: None if not found

overlap(extent)[source]

Return True if this extent overlaps with the provided spatial extent in three dimensions.

The following cases are excluded:

  • contain
  • in
  • cover
  • covered
  • equivalent
Parameters:extent – The spatial extent
Returns:True or False
overlap_2d(extent)[source]

Return True if this extent (A) overlaps with the provided spatial extent (B) in two dimensions. Code is lend from wind_overlap.c in lib/gis

 _____
|A  __|__
|  |  | B|
|__|__|  |
   |_____|

The following cases are excluded:

  • contain
  • in
  • cover
  • covered
  • equivalent
Parameters:extent – The spatial extent
Returns:True or False
overlapping(extent)[source]

Return True if this (A) and the provided spatial extent (B) overlaps in three dimensional space.

Overlapping includes the spatial relations:

  • contain
  • in
  • cover
  • covered
  • equivalent

Usage:

>>> A = SpatialExtent(north=80, south=20, east=60, west=10, bottom=-50, top=50)
>>> B = SpatialExtent(north=80, south=20, east=60, west=10, bottom=-50, top=50)
>>> A.overlapping(B)
True
Parameters:extent – The spatial extent to check overlapping with
Returns:True or False
overlapping_2d(extent)[source]

Return True if this (A) and the provided spatial extent (B) overlaps in two dimensional space. Code is lend from wind_overlap.c in lib/gis

Overlapping includes the spatial relations:

  • contain
  • in
  • cover
  • covered
  • equivalent
>>> A = SpatialExtent(north=80, south=20, east=60, west=10)
>>> B = SpatialExtent(north=80, south=20, east=60, west=10)
>>> A.overlapping_2d(B)
True
Parameters:extent – The spatial extent to check overlapping with
Returns:True or False
print_info()[source]

Print information about this class in human readable style

print_shell_info()[source]

Print information about this class in shell style

set_bottom(bottom)[source]

Set the bottom edge of the map

set_east(east)[source]

Set the eastern edge of the map

set_id(ident)[source]

Convenient method to set the unique identifier (primary key)

set_north(north)[source]

Set the northern edge of the map

set_projection(proj)[source]

Set the projection of the spatial extent it should be XY or LL. As default the projection is XY

set_south(south)[source]

Set the southern edge of the map

set_spatial_extent(spatial_extent)[source]

Set the three dimensional spatial extent

Parameters:spatial_extent – An object of type SpatialExtent or its subclasses
set_spatial_extent_2d(spatial_extent)[source]

Set the three dimensional spatial extent

Parameters:spatial_extent – An object of type SpatialExtent or its subclasses
set_spatial_extent_from_values(north, south, east, west, top, bottom)[source]

Set the three dimensional spatial extent

Parameters:
  • north – The northern edge
  • south – The southern edge
  • east – The eastern edge
  • west – The western edge
  • top – The top edge
  • bottom – The bottom edge
set_spatial_extent_from_values_2d(north, south, east, west)[source]

Set the two dimensional spatial extent from values

Parameters:
  • north – The northern edge
  • south – The southern edge
  • east – The eastern edge
  • west – The western edge
set_top(top)[source]

Set the top edge of the map

set_west(west)[source]

Set the western edge of the map

south

Get the southern edge of the map :return: None if not found

spatial_relation(extent)[source]

Returns the two dimensional spatial relation between this extent and the provided spatial extent in three dimensions.

Spatial relations are:

  • disjoint
  • meet
  • overlap
  • cover
  • covered
  • in
  • contain
  • equivalent

Usage:

>>> A = SpatialExtent(north=80, south=20, east=60, west=10, bottom=-50, top=50)
>>> B = SpatialExtent(north=80, south=20, east=60, west=10, bottom=-50, top=50)
>>> A.spatial_relation(B)
'equivalent'
>>> B.spatial_relation(A)
'equivalent'
>>> B = SpatialExtent(north=70, south=20, east=60, west=10, bottom=-50, top=50)
>>> A.spatial_relation_2d(B)
'cover'
>>> A.spatial_relation(B)
'cover'
>>> B = SpatialExtent(north=70, south=30, east=60, west=10, bottom=-50, top=50)
>>> A.spatial_relation_2d(B)
'cover'
>>> A.spatial_relation(B)
'cover'
>>> B.spatial_relation_2d(A)
'covered'
>>> B.spatial_relation(A)
'covered'
>>> B = SpatialExtent(north=70, south=30, east=50, west=10, bottom=-50, top=50)
>>> A.spatial_relation_2d(B)
'cover'
>>> B.spatial_relation_2d(A)
'covered'
>>> A.spatial_relation(B)
'cover'
>>> B = SpatialExtent(north=70, south=30, east=50, west=20, bottom=-50, top=50)
>>> B.spatial_relation(A)
'covered'
>>> B = SpatialExtent(north=70, south=30, east=50, west=20, bottom=-50, top=50)
>>> A.spatial_relation_2d(B)
'contain'
>>> A.spatial_relation(B)
'cover'
>>> B = SpatialExtent(north=70, south=30, east=50, west=20, bottom=-40, top=50)
>>> A.spatial_relation(B)
'cover'
>>> B = SpatialExtent(north=70, south=30, east=50, west=20, bottom=-40, top=40)
>>> A.spatial_relation(B)
'contain'
>>> B.spatial_relation(A)
'in'
>>> B = SpatialExtent(north=90, south=30, east=50, west=20, bottom=-40, top=40)
>>> A.spatial_relation_2d(B)
'overlap'
>>> A.spatial_relation(B)
'overlap'
>>> B = SpatialExtent(north=90, south=5, east=70, west=5, bottom=-40, top=40)
>>> A.spatial_relation_2d(B)
'in'
>>> A.spatial_relation(B)
'overlap'
>>> B = SpatialExtent(north=90, south=5, east=70, west=5, bottom=-40, top=60)
>>> A.spatial_relation(B)
'overlap'
>>> B = SpatialExtent(north=90, south=5, east=70, west=5, bottom=-60, top=60)
>>> A.spatial_relation(B)
'in'
>>> A = SpatialExtent(north=80, south=60, east=60, west=10, bottom=-50, top=50)
>>> B = SpatialExtent(north=60, south=20, east=60, west=10, bottom=-50, top=50)
>>> A.spatial_relation_2d(B)
'meet'
>>> A.spatial_relation(B)
'meet'
>>> A = SpatialExtent(north=60, south=40, east=60, west=10, bottom=-50, top=50)
>>> B = SpatialExtent(north=80, south=60, east=60, west=10, bottom=-50, top=50)
>>> A.spatial_relation_2d(B)
'meet'
>>> A.spatial_relation(B)
'meet'
>>> A = SpatialExtent(north=80, south=40, east=60, west=40, bottom=-50, top=50)
>>> B = SpatialExtent(north=80, south=40, east=40, west=20, bottom=-50, top=50)
>>> A.spatial_relation_2d(B)
'meet'
>>> A.spatial_relation(B)
'meet'
>>> A = SpatialExtent(north=80, south=40, east=40, west=20, bottom=-50, top=50)
>>> B = SpatialExtent(north=90, south=30, east=60, west=40, bottom=-50, top=50)
>>> A.spatial_relation_2d(B)
'meet'
>>> A.spatial_relation(B)
'meet'
>>> A = SpatialExtent(north=80, south=40, east=40, west=20, bottom=-50, top=50)
>>> B = SpatialExtent(north=70, south=50, east=60, west=40, bottom=-50, top=50)
>>> A.spatial_relation_2d(B)
'meet'
>>> A.spatial_relation(B)
'meet'
>>> A = SpatialExtent(north=80, south=40, east=40, west=20, bottom=-50, top=50)
>>> B = SpatialExtent(north=60, south=20, east=60, west=40, bottom=-50, top=50)
>>> A.spatial_relation_2d(B)
'meet'
>>> A.spatial_relation(B)
'meet'
>>> A = SpatialExtent(north=80, south=40, east=40, west=20, bottom=-50, top=50)
>>> B = SpatialExtent(north=40, south=20, east=60, west=40, bottom=-50, top=50)
>>> A.spatial_relation_2d(B)
'disjoint'
>>> A.spatial_relation(B)
'disjoint'
>>> A = SpatialExtent(north=80, south=40, east=40, west=20, bottom=-50, top=50)
>>> B = SpatialExtent(north=60, south=20, east=60, west=40, bottom=-60, top=60)
>>> A.spatial_relation(B)
'meet'
>>> A = SpatialExtent(north=80, south=40, east=40, west=20, bottom=-50, top=50)
>>> B = SpatialExtent(north=90, south=30, east=60, west=40, bottom=-40, top=40)
>>> A.spatial_relation(B)
'meet'
>>> A = SpatialExtent(north=80, south=40, east=60, west=20, bottom=0, top=50)
>>> B = SpatialExtent(north=80, south=40, east=60, west=20, bottom=-50, top=0)
>>> A.spatial_relation(B)
'meet'
>>> A = SpatialExtent(north=80, south=40, east=60, west=20, bottom=0, top=50)
>>> B = SpatialExtent(north=80, south=50, east=60, west=30, bottom=-50, top=0)
>>> A.spatial_relation(B)
'meet'
>>> A = SpatialExtent(north=80, south=40, east=60, west=20, bottom=0, top=50)
>>> B = SpatialExtent(north=70, south=50, east=50, west=30, bottom=-50, top=0)
>>> A.spatial_relation(B)
'meet'
>>> A = SpatialExtent(north=80, south=40, east=60, west=20, bottom=0, top=50)
>>> B = SpatialExtent(north=90, south=30, east=70, west=10, bottom=-50, top=0)
>>> A.spatial_relation(B)
'meet'
>>> A = SpatialExtent(north=80, south=40, east=60, west=20, bottom=0, top=50)
>>> B = SpatialExtent(north=70, south=30, east=50, west=10, bottom=-50, top=0)
>>> A.spatial_relation(B)
'meet'
>>> A = SpatialExtent(north=80, south=40, east=60, west=20, bottom=-50, top=0)
>>> B = SpatialExtent(north=80, south=40, east=60, west=20, bottom=0, top=50)
>>> A.spatial_relation(B)
'meet'
>>> A = SpatialExtent(north=80, south=40, east=60, west=20, bottom=-50, top=0)
>>> B = SpatialExtent(north=80, south=50, east=60, west=30, bottom=0, top=50)
>>> A.spatial_relation(B)
'meet'
>>> A = SpatialExtent(north=80, south=40, east=60, west=20, bottom=-50, top=0)
>>> B = SpatialExtent(north=70, south=50, east=50, west=30, bottom=0, top=50)
>>> A.spatial_relation(B)
'meet'
>>> A = SpatialExtent(north=80, south=40, east=60, west=20, bottom=-50, top=0)
>>> B = SpatialExtent(north=90, south=30, east=70, west=10, bottom=0, top=50)
>>> A.spatial_relation(B)
'meet'
>>> A = SpatialExtent(north=80, south=40, east=60, west=20, bottom=-50, top=0)
>>> B = SpatialExtent(north=70, south=30, east=50, west=10, bottom=0, top=50)
>>> A.spatial_relation(B)
'meet'
>>> A = SpatialExtent(north=80, south=20, east=60, west=10, bottom=-50, top=50)
>>> B = SpatialExtent(north=90, south=81, east=60, west=10, bottom=-50, top=50)
>>> A.spatial_relation(B)
'disjoint'
>>> A = SpatialExtent(north=80, south=20, east=60, west=10, bottom=-50, top=50)
>>> B = SpatialExtent(north=90, south=80, east=60, west=10, bottom=-50, top=50)
>>> A.spatial_relation(B)
'meet'
spatial_relation_2d(extent)[source]

Returns the two dimensional spatial relation between this extent and the provided spatial extent in two dimensions.

Spatial relations are:

  • disjoint
  • meet
  • overlap
  • cover
  • covered
  • in
  • contain
  • equivalent

Usage: see self.spatial_relation()

top

Get the top edge of the map :return: None if not found

union(extent)[source]
Return the three dimensional union as spatial_extent
object or None in case the extents does not overlap or meet.
Parameters:extent – The spatial extent to create a union with
Returns:The union spatial extent
union_2d(extent)[source]
Return the two dimensional union as spatial_extent
object or None in case the extents does not overlap or meet.
Parameters:extent – The spatial extent to create a union with
Returns:The union spatial extent
west

Get the western edge of the map :return: None if not found

class temporal.spatial_extent.VectorSpatialExtent(ident=None, north=None, south=None, east=None, west=None, top=None, bottom=None)[source]

Bases: temporal.spatial_extent.SpatialExtent

temporal.spatial_topology_dataset_connector module

Spatial topology connector class

Usage:

>>> import grass.temporal as tgis
>>> tmr = tgis.SpatialTopologyDatasetConnector()

(C) 2012-2013 by the GRASS Development Team This program is free software under the GNU General Public License (>=v2). Read the file COPYING that comes with GRASS for details.

authors:Soeren Gebbert
class temporal.spatial_topology_dataset_connector.SpatialTopologyDatasetConnector[source]

Bases: object

This class implements a spatial topology access structure to connect spatial related datasets

This object will be set up by spatial topology creation method provided by the SpatioTemporalTopologyBuilder.

The following spatial relations with access methods are supported:

  • equivalent
  • overlap
  • in
  • contain
  • meet
  • cover
  • covered

Usage:

>>> import grass.temporal as tgis
>>> tgis.init()
>>> map = tgis.RasterDataset("a@P")
>>> tmr = tgis.SpatialTopologyDatasetConnector()
>>> tmr.append_equivalent(map)
>>> tmr.append_overlap(map)
>>> tmr.append_in(map)
>>> tmr.append_contain(map)
>>> tmr.append_meet(map)
>>> tmr.append_cover(map)
>>> tmr.append_covered(map)
>>> tmr.print_spatial_topology_info()
 +-------------------- Spatial Topology --------------------------------------+
 | Equivalent: ................ a@P
 | Cover: ..................... a@P
 | Covered: ................... a@P
 | Overlap: ................... a@P
 | In: ........................ a@P
 | Contain: ................... a@P
 | Meet: ...................... a@P
>>> tmr.print_spatial_topology_shell_info()
equivalent=a@P
cover=a@P
covered=a@P
overlap=a@P
in=a@P
contain=a@P
meet=a@P
>>> rlist = tmr.get_spatial_relations()
>>> if "COVER" in rlist.keys():
...    print(rlist["COVER"][0].get_id())
a@P
append_contain(map)[source]

Append a map that this map spatially contains

Parameters:map – This object should be of type AbstractMapDataset or derived classes
append_cover(map)[source]

Append a map that spatially cover this map

Parameters:map – This object should be of type AbstractMapDataset or derived classes
append_covered(map)[source]

Append a map that is spatially covered by this map

Parameters:map – This object should be of type AbstractMapDataset or derived classes
append_equivalent(map)[source]

Append a map with equivalent spatial extent as this map

Parameters:map – This object should be of type AbstractMapDataset or derived classes
append_in(map)[source]

Append a map that this is spatial in this map

Parameters:map – This object should be of type AbstractMapDataset or derived classes
append_meet(map)[source]

Append a map that spatially meet with this map

Parameters:map – This object should be of type AbstractMapDataset or derived classes
append_overlap(map)[source]

Append a map that this spatial overlap with this map

Parameters:map – This object should be of type AbstractMapDataset or derived classes
contain

Return a list of map objects that this map contains

Returns:A list of map objects or None
cover

Return a list of map objects that spatially cover this map

Returns:A list of map objects or None
covered

Return a list of map objects that are spatially covered by this map

Returns:A list of map objects or None
equivalent

Return a list of map objects with equivalent spatial extent as this map

Returns:A list of map objects or None
get_contain()[source]

Return a list of map objects that this map contains

Returns:A list of map objects or None
get_cover()[source]

Return a list of map objects that spatially cover this map

Returns:A list of map objects or None
get_covered()[source]

Return a list of map objects that are spatially covered by this map

Returns:A list of map objects or None
get_equivalent()[source]

Return a list of map objects with equivalent spatial extent as this map

Returns:A list of map objects or None
get_in()[source]

Return a list of map objects that are spatial in this map

Returns:A list of map objects or None
get_meet()[source]

Return a list of map objects that spatially meet with this map

Returns:A list of map objects or None
get_number_of_spatial_relations()[source]

Return a dictionary in which the keys are the relation names and the value are the number of relations.

The following relations are available:

  • equivalent
  • overlap
  • in
  • contain
  • meet
  • cover
  • covered

To access topological information the spatial topology must be build first using the SpatialTopologyBuilder.

Returns:the dictionary with relations as keys and number as values or None in case the topology wasn’t build
get_overlap()[source]

Return a list of map objects that this map spatial overlap with

Returns:A list of map objects or None
get_spatial_relations()[source]

Return the dictionary of spatial relationships

Keys are the spatial relationships in upper case, values are abstract map objects.

Returns:The spatial relations dictionary
in_

Return a list of map objects that are spatial in this map

Returns:A list of map objects or None
is_spatial_topology_build()[source]

Check if the temporal topology was build

meet

Return a list of map objects that spatially meet with this map

Returns:A list of map objects or None
overlap

Return a list of map objects that this map spatial overlap with

Returns:A list of map objects or None
print_spatial_topology_info()[source]

Print information about this class in human readable style

print_spatial_topology_shell_info()[source]

Print information about this class in shell style

reset_spatial_topology()[source]

Reset any information about temporal topology

set_spatial_topology_build_false()[source]

Same as name

set_spatial_topology_build_true()[source]

Same as name

temporal.spatio_temporal_relationships module

Class to build the spatio-temporal topology between map lists

Usage:

import grass.temporal as tgis

tgis.print_temporal_relations(maps)

(C) 2012-2013 by the GRASS Development Team This program is free software under the GNU General Public License (>=v2). Read the file COPYING that comes with GRASS for details.

authors:Soeren Gebbert
class temporal.spatio_temporal_relationships.SpatioTemporalTopologyBuilder[source]

Bases: object

This class is designed to build the spatio-temporal topology of spatio-temporally related abstract dataset objects.

The abstract dataset objects must be provided as a single list, or in two lists.

Example:

# We have a space time raster dataset and build a map list
# from all registered maps ordered by start time
maps = strds.get_registered_maps_as_objects()

# Now lets build the temporal topology of the maps in the list

tb = SpatioTemporalTopologyBuilder()

tb.build(maps)

dbif, connected = init_dbif(None)

for map in tb:
    map.select(dbif)
    map.print_info()

# Same can be done with the existing map list
# But be aware that this is might not be temporally ordered
for map in maps:
    map.select(dbf)
    map.print_info()

# Using the next and previous methods, we can iterate over the
# topological related maps in this way

first = tb.get_first()

while first:
    first.print_topology_info()
    first = first.next()

# Dictionary like accessed
map = tb["name@mapset"]

>>> # Example with two lists of maps
>>> import grass.temporal as tgis
>>> import datetime
>>> # Create two list of maps with equal time stamps
>>> mapsA = []
>>> mapsB = []
>>> for i in range(4):
...     idA = "a%i@B"%(i)
...     mapA = tgis.RasterDataset(idA)
...     idB = "b%i@B"%(i)
...     mapB = tgis.RasterDataset(idB)
...     check = mapA.set_relative_time(i, i + 1, "months")
...     check = mapB.set_relative_time(i, i + 1, "months")
...     mapsA.append(mapA)
...     mapsB.append(mapB)
>>> # Build the topology between the two map lists
>>> tb = SpatioTemporalTopologyBuilder()
>>> tb.build(mapsA, mapsB, None)
>>> # Check relations of mapsA
>>> for map in mapsA:
...     if map.get_equal():
...         relations = map.get_equal()
...         print("Map %s has equal relation to map %s"%(map.get_name(),
...               relations[0].get_name()))
Map a0 has equal relation to map b0
Map a1 has equal relation to map b1
Map a2 has equal relation to map b2
Map a3 has equal relation to map b3
>>> # Check relations of mapsB
>>> for map in mapsB:
...     if map.get_equal():
...         relations = map.get_equal()
...         print("Map %s has equal relation to map %s"%(map.get_name(),
...               relations[0].get_name()))
Map b0 has equal relation to map a0
Map b1 has equal relation to map a1
Map b2 has equal relation to map a2
Map b3 has equal relation to map a3


>>> mapsA = []
>>> mapsB = []
>>> for i in range(4):
...     idA = "a%i@B"%(i)
...     mapA = tgis.RasterDataset(idA)
...     idB = "b%i@B"%(i)
...     mapB = tgis.RasterDataset(idB)
...     check = mapA.set_relative_time(i, i + 1, "months")
...     check = mapB.set_relative_time(i + 1, i + 2, "months")
...     mapsA.append(mapA)
...     mapsB.append(mapB)
>>> # Build the topology between the two map lists
>>> tb = SpatioTemporalTopologyBuilder()
>>> tb.build(mapsA, mapsB, None)
>>> # Check relations of mapsA
>>> for map in mapsA:
...     print(map.get_temporal_extent_as_tuple())
...     m = map.get_temporal_relations()
...     for key in m.keys():
...         if key not in ["NEXT", "PREV"]:
...             print((key, m[key][0].get_temporal_extent_as_tuple()))
(0, 1)
('PRECEDES', (1, 2))
(1, 2)
('PRECEDES', (2, 3))
('EQUAL', (1, 2))
(2, 3)
('FOLLOWS', (1, 2))
('PRECEDES', (3, 4))
('EQUAL', (2, 3))
(3, 4)
('FOLLOWS', (2, 3))
('EQUAL', (3, 4))
('PRECEDES', (4, 5))

>>> mapsA = []
>>> mapsB = []
>>> for i in range(4):
...     idA = "a%i@B"%(i)
...     mapA = tgis.RasterDataset(idA)
...     idB = "b%i@B"%(i)
...     mapB = tgis.RasterDataset(idB)
...     start = datetime.datetime(2000 + i, 1, 1)
...     end = datetime.datetime(2000 + i + 1, 1, 1)
...     check = mapA.set_absolute_time(start, end)
...     start = datetime.datetime(2000 + i + 1, 1, 1)
...     end = datetime.datetime(2000 + i + 2, 1, 1)
...     check = mapB.set_absolute_time(start, end)
...     mapsA.append(mapA)
...     mapsB.append(mapB)
>>> # Build the topology between the two map lists
>>> tb = SpatioTemporalTopologyBuilder()
>>> tb.build(mapsA, mapsB, None)
>>> # Check relations of mapsA
>>> for map in mapsA:
...     print(map.get_temporal_extent_as_tuple())
...     m = map.get_temporal_relations()
...     for key in m.keys():
...         if key not in ["NEXT", "PREV"]:
...             print((key, m[key][0].get_temporal_extent_as_tuple()))
(datetime.datetime(2000, 1, 1, 0, 0), datetime.datetime(2001, 1, 1, 0, 0))
('PRECEDES', (datetime.datetime(2001, 1, 1, 0, 0), datetime.datetime(2002, 1, 1, 0, 0)))
(datetime.datetime(2001, 1, 1, 0, 0), datetime.datetime(2002, 1, 1, 0, 0))
('PRECEDES', (datetime.datetime(2002, 1, 1, 0, 0), datetime.datetime(2003, 1, 1, 0, 0)))
('EQUAL', (datetime.datetime(2001, 1, 1, 0, 0), datetime.datetime(2002, 1, 1, 0, 0)))
(datetime.datetime(2002, 1, 1, 0, 0), datetime.datetime(2003, 1, 1, 0, 0))
('FOLLOWS', (datetime.datetime(2001, 1, 1, 0, 0), datetime.datetime(2002, 1, 1, 0, 0)))
('PRECEDES', (datetime.datetime(2003, 1, 1, 0, 0), datetime.datetime(2004, 1, 1, 0, 0)))
('EQUAL', (datetime.datetime(2002, 1, 1, 0, 0), datetime.datetime(2003, 1, 1, 0, 0)))
(datetime.datetime(2003, 1, 1, 0, 0), datetime.datetime(2004, 1, 1, 0, 0))
('FOLLOWS', (datetime.datetime(2002, 1, 1, 0, 0), datetime.datetime(2003, 1, 1, 0, 0)))
('EQUAL', (datetime.datetime(2003, 1, 1, 0, 0), datetime.datetime(2004, 1, 1, 0, 0)))
('PRECEDES', (datetime.datetime(2004, 1, 1, 0, 0), datetime.datetime(2005, 1, 1, 0, 0)))

>>> mapsA = []
>>> mapsB = []
>>> for i in range(4):
...     idA = "a%i@B"%(i)
...     mapA = tgis.RasterDataset(idA)
...     idB = "b%i@B"%(i)
...     mapB = tgis.RasterDataset(idB)
...     start = datetime.datetime(2000 + i, 1, 1)
...     end = datetime.datetime(2000 + i + 1, 1, 1)
...     check = mapA.set_absolute_time(start, end)
...     start = datetime.datetime(2000 + i, 1, 1)
...     end = datetime.datetime(2000 + i + 3, 1, 1)
...     check = mapB.set_absolute_time(start, end)
...     mapsA.append(mapA)
...     mapsB.append(mapB)
>>> # Build the topology between the two map lists
>>> tb = SpatioTemporalTopologyBuilder()
>>> tb.build(mapsA, mapsB, None)
>>> # Check relations of mapsA
>>> for map in mapsA:
...     print(map.get_temporal_extent_as_tuple())
...     m = map.get_temporal_relations()
...     for key in m.keys():
...         if key not in ["NEXT", "PREV"]:
...             print((key, m[key][0].get_temporal_extent_as_tuple()))
(datetime.datetime(2000, 1, 1, 0, 0), datetime.datetime(2001, 1, 1, 0, 0))
('DURING', (datetime.datetime(2000, 1, 1, 0, 0), datetime.datetime(2003, 1, 1, 0, 0)))
('STARTS', (datetime.datetime(2000, 1, 1, 0, 0), datetime.datetime(2003, 1, 1, 0, 0)))
('PRECEDES', (datetime.datetime(2001, 1, 1, 0, 0), datetime.datetime(2004, 1, 1, 0, 0)))
(datetime.datetime(2001, 1, 1, 0, 0), datetime.datetime(2002, 1, 1, 0, 0))
('DURING', (datetime.datetime(2000, 1, 1, 0, 0), datetime.datetime(2003, 1, 1, 0, 0)))
('STARTS', (datetime.datetime(2001, 1, 1, 0, 0), datetime.datetime(2004, 1, 1, 0, 0)))
('PRECEDES', (datetime.datetime(2002, 1, 1, 0, 0), datetime.datetime(2005, 1, 1, 0, 0)))
(datetime.datetime(2002, 1, 1, 0, 0), datetime.datetime(2003, 1, 1, 0, 0))
('PRECEDES', (datetime.datetime(2003, 1, 1, 0, 0), datetime.datetime(2006, 1, 1, 0, 0)))
('FINISHES', (datetime.datetime(2000, 1, 1, 0, 0), datetime.datetime(2003, 1, 1, 0, 0)))
('DURING', (datetime.datetime(2000, 1, 1, 0, 0), datetime.datetime(2003, 1, 1, 0, 0)))
('STARTS', (datetime.datetime(2002, 1, 1, 0, 0), datetime.datetime(2005, 1, 1, 0, 0)))
(datetime.datetime(2003, 1, 1, 0, 0), datetime.datetime(2004, 1, 1, 0, 0))
('FOLLOWS', (datetime.datetime(2000, 1, 1, 0, 0), datetime.datetime(2003, 1, 1, 0, 0)))
('DURING', (datetime.datetime(2001, 1, 1, 0, 0), datetime.datetime(2004, 1, 1, 0, 0)))
('FINISHES', (datetime.datetime(2001, 1, 1, 0, 0), datetime.datetime(2004, 1, 1, 0, 0)))
('STARTS', (datetime.datetime(2003, 1, 1, 0, 0), datetime.datetime(2006, 1, 1, 0, 0)))

>>> mapsA = []
>>> mapsB = []
>>> for i in range(4):
...     idA = "a%i@B"%(i)
...     mapA = tgis.RasterDataset(idA)
...     idB = "b%i@B"%(i)
...     mapB = tgis.RasterDataset(idB)
...     start = datetime.datetime(2000 + i, 1, 1)
...     end = datetime.datetime(2000 + i + 2, 1, 1)
...     check = mapA.set_absolute_time(start, end)
...     start = datetime.datetime(2000 + i, 1, 1)
...     end = datetime.datetime(2000 + i + 3, 1, 1)
...     check = mapB.set_absolute_time(start, end)
...     mapsA.append(mapA)
...     mapsB.append(mapB)
>>> # Build the topology between the two map lists
>>> tb = SpatioTemporalTopologyBuilder()
>>> tb.build(mapsA, mapsB, None)
>>> # Check relations of mapsA
>>> for map in mapsA:
...     print(map.get_temporal_extent_as_tuple())
...     m = map.get_temporal_relations()
...     for key in m.keys():
...         if key not in ["NEXT", "PREV"]:
...             print((key, m[key][0].get_temporal_extent_as_tuple()))
(datetime.datetime(2000, 1, 1, 0, 0), datetime.datetime(2002, 1, 1, 0, 0))
('OVERLAPS', (datetime.datetime(2001, 1, 1, 0, 0), datetime.datetime(2004, 1, 1, 0, 0)))
('DURING', (datetime.datetime(2000, 1, 1, 0, 0), datetime.datetime(2003, 1, 1, 0, 0)))
('STARTS', (datetime.datetime(2000, 1, 1, 0, 0), datetime.datetime(2003, 1, 1, 0, 0)))
('PRECEDES', (datetime.datetime(2002, 1, 1, 0, 0), datetime.datetime(2005, 1, 1, 0, 0)))
(datetime.datetime(2001, 1, 1, 0, 0), datetime.datetime(2003, 1, 1, 0, 0))
('OVERLAPS', (datetime.datetime(2002, 1, 1, 0, 0), datetime.datetime(2005, 1, 1, 0, 0)))
('PRECEDES', (datetime.datetime(2003, 1, 1, 0, 0), datetime.datetime(2006, 1, 1, 0, 0)))
('FINISHES', (datetime.datetime(2000, 1, 1, 0, 0), datetime.datetime(2003, 1, 1, 0, 0)))
('DURING', (datetime.datetime(2000, 1, 1, 0, 0), datetime.datetime(2003, 1, 1, 0, 0)))
('STARTS', (datetime.datetime(2001, 1, 1, 0, 0), datetime.datetime(2004, 1, 1, 0, 0)))
(datetime.datetime(2002, 1, 1, 0, 0), datetime.datetime(2004, 1, 1, 0, 0))
('OVERLAPS', (datetime.datetime(2003, 1, 1, 0, 0), datetime.datetime(2006, 1, 1, 0, 0)))
('OVERLAPPED', (datetime.datetime(2000, 1, 1, 0, 0), datetime.datetime(2003, 1, 1, 0, 0)))
('FINISHES', (datetime.datetime(2001, 1, 1, 0, 0), datetime.datetime(2004, 1, 1, 0, 0)))
('DURING', (datetime.datetime(2001, 1, 1, 0, 0), datetime.datetime(2004, 1, 1, 0, 0)))
('STARTS', (datetime.datetime(2002, 1, 1, 0, 0), datetime.datetime(2005, 1, 1, 0, 0)))
(datetime.datetime(2003, 1, 1, 0, 0), datetime.datetime(2005, 1, 1, 0, 0))
('OVERLAPPED', (datetime.datetime(2001, 1, 1, 0, 0), datetime.datetime(2004, 1, 1, 0, 0)))
('DURING', (datetime.datetime(2002, 1, 1, 0, 0), datetime.datetime(2005, 1, 1, 0, 0)))
('FINISHES', (datetime.datetime(2002, 1, 1, 0, 0), datetime.datetime(2005, 1, 1, 0, 0)))
('STARTS', (datetime.datetime(2003, 1, 1, 0, 0), datetime.datetime(2006, 1, 1, 0, 0)))
('FOLLOWS', (datetime.datetime(2000, 1, 1, 0, 0), datetime.datetime(2003, 1, 1, 0, 0)))

>>> mapsA = []
>>> mapsB = []
>>> for i in range(4):
...     idA = "a%i@B"%(i)
...     mapA = tgis.RasterDataset(idA)
...     idB = "b%i@B"%(i)
...     mapB = tgis.RasterDataset(idB)
...     start = datetime.datetime(2000, 1, 1, 0, 0, i)
...     end = datetime.datetime(2000, 1, 1, 0, 0, i + 2)
...     check = mapA.set_absolute_time(start, end)
...     start = datetime.datetime(2000, 1, 1, 0, 0, i + 1)
...     end = datetime.datetime(2000, 1, 1, 0, 0, i + 3)
...     check = mapB.set_absolute_time(start, end)
...     mapsA.append(mapA)
...     mapsB.append(mapB)
>>> # Build the topology between the two map lists
>>> tb = SpatioTemporalTopologyBuilder()
>>> tb.build(mapsA, mapsB, None)
>>> # Check relations of mapsA
>>> for map in mapsA:
...     print(map.get_temporal_extent_as_tuple())
...     m = map.get_temporal_relations()
...     for key in m.keys():
...         if key not in ["NEXT", "PREV"]:
...             print((key, m[key][0].get_temporal_extent_as_tuple()))
(datetime.datetime(2000, 1, 1, 0, 0), datetime.datetime(2000, 1, 1, 0, 0, 2))
('OVERLAPS', (datetime.datetime(2000, 1, 1, 0, 0, 1), datetime.datetime(2000, 1, 1, 0, 0, 3)))
('PRECEDES', (datetime.datetime(2000, 1, 1, 0, 0, 2), datetime.datetime(2000, 1, 1, 0, 0, 4)))
(datetime.datetime(2000, 1, 1, 0, 0, 1), datetime.datetime(2000, 1, 1, 0, 0, 3))
('OVERLAPS', (datetime.datetime(2000, 1, 1, 0, 0, 2), datetime.datetime(2000, 1, 1, 0, 0, 4)))
('PRECEDES', (datetime.datetime(2000, 1, 1, 0, 0, 3), datetime.datetime(2000, 1, 1, 0, 0, 5)))
('EQUAL', (datetime.datetime(2000, 1, 1, 0, 0, 1), datetime.datetime(2000, 1, 1, 0, 0, 3)))
(datetime.datetime(2000, 1, 1, 0, 0, 2), datetime.datetime(2000, 1, 1, 0, 0, 4))
('OVERLAPS', (datetime.datetime(2000, 1, 1, 0, 0, 3), datetime.datetime(2000, 1, 1, 0, 0, 5)))
('OVERLAPPED', (datetime.datetime(2000, 1, 1, 0, 0, 1), datetime.datetime(2000, 1, 1, 0, 0, 3)))
('PRECEDES', (datetime.datetime(2000, 1, 1, 0, 0, 4), datetime.datetime(2000, 1, 1, 0, 0, 6)))
('EQUAL', (datetime.datetime(2000, 1, 1, 0, 0, 2), datetime.datetime(2000, 1, 1, 0, 0, 4)))
(datetime.datetime(2000, 1, 1, 0, 0, 3), datetime.datetime(2000, 1, 1, 0, 0, 5))
('OVERLAPS', (datetime.datetime(2000, 1, 1, 0, 0, 4), datetime.datetime(2000, 1, 1, 0, 0, 6)))
('FOLLOWS', (datetime.datetime(2000, 1, 1, 0, 0, 1), datetime.datetime(2000, 1, 1, 0, 0, 3)))
('OVERLAPPED', (datetime.datetime(2000, 1, 1, 0, 0, 2), datetime.datetime(2000, 1, 1, 0, 0, 4)))
('EQUAL', (datetime.datetime(2000, 1, 1, 0, 0, 3), datetime.datetime(2000, 1, 1, 0, 0, 5)))

>>> mapsA = []
>>> for i in range(4):
...     idA = "a%i@B"%(i)
...     mapA = tgis.RasterDataset(idA)
...     start = datetime.datetime(2000, 1, 1, 0, 0, i)
...     end = datetime.datetime(2000, 1, 1, 0, 0, i + 2)
...     check = mapA.set_absolute_time(start, end)
...     mapsA.append(mapA)
>>> tb = SpatioTemporalTopologyBuilder()
>>> tb.build(mapsA)
>>> # Check relations of mapsA
>>> for map in mapsA:
...     print(map.get_temporal_extent_as_tuple())
...     m = map.get_temporal_relations()
...     for key in m.keys():
...         if key not in ["NEXT", "PREV"]:
...             print((key, m[key][0].get_temporal_extent_as_tuple()))
(datetime.datetime(2000, 1, 1, 0, 0), datetime.datetime(2000, 1, 1, 0, 0, 2))
('OVERLAPS', (datetime.datetime(2000, 1, 1, 0, 0, 1), datetime.datetime(2000, 1, 1, 0, 0, 3)))
('PRECEDES', (datetime.datetime(2000, 1, 1, 0, 0, 2), datetime.datetime(2000, 1, 1, 0, 0, 4)))
(datetime.datetime(2000, 1, 1, 0, 0, 1), datetime.datetime(2000, 1, 1, 0, 0, 3))
('OVERLAPS', (datetime.datetime(2000, 1, 1, 0, 0, 2), datetime.datetime(2000, 1, 1, 0, 0, 4)))
('OVERLAPPED', (datetime.datetime(2000, 1, 1, 0, 0), datetime.datetime(2000, 1, 1, 0, 0, 2)))
('PRECEDES', (datetime.datetime(2000, 1, 1, 0, 0, 3), datetime.datetime(2000, 1, 1, 0, 0, 5)))
(datetime.datetime(2000, 1, 1, 0, 0, 2), datetime.datetime(2000, 1, 1, 0, 0, 4))
('OVERLAPS', (datetime.datetime(2000, 1, 1, 0, 0, 3), datetime.datetime(2000, 1, 1, 0, 0, 5)))
('FOLLOWS', (datetime.datetime(2000, 1, 1, 0, 0), datetime.datetime(2000, 1, 1, 0, 0, 2)))
('OVERLAPPED', (datetime.datetime(2000, 1, 1, 0, 0, 1), datetime.datetime(2000, 1, 1, 0, 0, 3)))
(datetime.datetime(2000, 1, 1, 0, 0, 3), datetime.datetime(2000, 1, 1, 0, 0, 5))
('FOLLOWS', (datetime.datetime(2000, 1, 1, 0, 0, 1), datetime.datetime(2000, 1, 1, 0, 0, 3)))
('OVERLAPPED', (datetime.datetime(2000, 1, 1, 0, 0, 2), datetime.datetime(2000, 1, 1, 0, 0, 4)))
build(mapsA, mapsB=None, spatial=None)[source]

Build the spatio-temporal topology structure between one or two unordered lists of abstract dataset objects

This method builds the temporal or spatio-temporal topology from mapsA to mapsB and vice verse. The spatio-temporal topology structure of each map will be reset and rebuild for mapsA and mapsB.

After building the temporal or spatio-temporal topology the modified map objects of mapsA can be accessed in the same way as a dictionary using there id. The implemented iterator assures the chronological iteration over the mapsA.

Parameters:
  • mapsA – A list of abstract_dataset objects with initiated spatio-temporal extent
  • mapsB – An optional list of abstract_dataset objects with initiated spatio-temporal extent
  • spatial – This indicates if the spatial topology is created as well: spatial can be None (no spatial topology), “2D” using west, east, south, north or “3D” using west, east, south, north, bottom, top
get_first()[source]

Return the first map with the earliest start time

Returns:The map with the earliest start time
temporal.spatio_temporal_relationships.count_temporal_topology_relationships(maps1, maps2=None, dbif=None)[source]

Count the temporal relations of a single list of maps or between two lists of maps

param maps1:A list of abstract_dataset objects with initiated temporal extent
param maps2:A list of abstract_dataset objects with initiated temporal extent
param dbif:The database interface to be used
return:A dictionary with counted temporal relationships
temporal.spatio_temporal_relationships.create_temporal_relation_sql_where_statement(start, end, use_start=True, use_during=False, use_overlap=False, use_contain=False, use_equal=False, use_follows=False, use_precedes=False)[source]

Create a SQL WHERE statement for temporal relation selection of maps in space time datasets

param start:

The start time

param end:

The end time

param use_start:
 

Select maps of which the start time is located in the selection granule

map    :        s
granule:  s-----------------e

map    :        s--------------------e
granule:  s-----------------e

map    :        s--------e
granule:  s-----------------e
param use_during:
 

Select maps which are temporal during the selection granule

map    :     s-----------e
granule:  s-----------------e
param use_overlap:
 

Select maps which temporal overlap the selection granule

map    :     s-----------e
granule:        s-----------------e

map    :     s-----------e
granule:  s----------e
param use_contain:
 

Select maps which temporally contain the selection granule

map    :  s-----------------e
granule:     s-----------e
param use_equal:
 

Select maps which temporally equal to the selection granule

map    :  s-----------e
granule:  s-----------e
param use_follows:
 

Select maps which temporally follow the selection granule

map    :              s-----------e
granule:  s-----------e
param use_precedes:
 

Select maps which temporally precedes the selection granule

map    :  s-----------e
granule:              s-----------e

Usage:

>>> # Relative time
>>> start = 1
>>> end = 2
>>> create_temporal_relation_sql_where_statement(start, end,
... use_start=False)
>>> create_temporal_relation_sql_where_statement(start, end)
'((start_time >= 1 and start_time < 2) )'
>>> create_temporal_relation_sql_where_statement(start, end,
... use_start=True)
'((start_time >= 1 and start_time < 2) )'
>>> create_temporal_relation_sql_where_statement(start, end,
... use_start=False, use_during=True)
'(((start_time > 1 and end_time < 2) OR (start_time >= 1 and end_time < 2) OR (start_time > 1 and end_time <= 2)))'
>>> create_temporal_relation_sql_where_statement(start, end,
... use_start=False, use_overlap=True)
'(((start_time < 1 and end_time > 1 and end_time < 2) OR (start_time < 2 and start_time > 1 and end_time > 2)))'
>>> create_temporal_relation_sql_where_statement(start, end,
... use_start=False, use_contain=True)
'(((start_time < 1 and end_time > 2) OR (start_time <= 1 and end_time > 2) OR (start_time < 1 and end_time >= 2)))'
>>> create_temporal_relation_sql_where_statement(start, end,
... use_start=False, use_equal=True)
'((start_time = 1 and end_time = 2))'
>>> create_temporal_relation_sql_where_statement(start, end,
... use_start=False, use_follows=True)
'((start_time = 2))'
>>> create_temporal_relation_sql_where_statement(start, end,
... use_start=False, use_precedes=True)
'((end_time = 1))'
>>> create_temporal_relation_sql_where_statement(start, end,
... use_start=True, use_during=True, use_overlap=True, use_contain=True,
... use_equal=True, use_follows=True, use_precedes=True)
'((start_time >= 1 and start_time < 2)  OR ((start_time > 1 and end_time < 2) OR (start_time >= 1 and end_time < 2) OR (start_time > 1 and end_time <= 2)) OR ((start_time < 1 and end_time > 1 and end_time < 2) OR (start_time < 2 and start_time > 1 and end_time > 2)) OR ((start_time < 1 and end_time > 2) OR (start_time <= 1 and end_time > 2) OR (start_time < 1 and end_time >= 2)) OR (start_time = 1 and end_time = 2) OR (start_time = 2) OR (end_time = 1))'

>>> # Absolute time
>>> start = datetime(2001, 1, 1, 12, 30)
>>> end = datetime(2001, 3, 31, 14, 30)
>>> create_temporal_relation_sql_where_statement(start, end,
... use_start=False)
>>> create_temporal_relation_sql_where_statement(start, end)
"((start_time >= '2001-01-01 12:30:00' and start_time < '2001-03-31 14:30:00') )"
>>> create_temporal_relation_sql_where_statement(start, end,
... use_start=True)
"((start_time >= '2001-01-01 12:30:00' and start_time < '2001-03-31 14:30:00') )"
>>> create_temporal_relation_sql_where_statement(start, end,
... use_start=False, use_during=True)
"(((start_time > '2001-01-01 12:30:00' and end_time < '2001-03-31 14:30:00') OR (start_time >= '2001-01-01 12:30:00' and end_time < '2001-03-31 14:30:00') OR (start_time > '2001-01-01 12:30:00' and end_time <= '2001-03-31 14:30:00')))"
>>> create_temporal_relation_sql_where_statement(start, end,
... use_start=False, use_overlap=True)
"(((start_time < '2001-01-01 12:30:00' and end_time > '2001-01-01 12:30:00' and end_time < '2001-03-31 14:30:00') OR (start_time < '2001-03-31 14:30:00' and start_time > '2001-01-01 12:30:00' and end_time > '2001-03-31 14:30:00')))"
>>> create_temporal_relation_sql_where_statement(start, end,
... use_start=False, use_contain=True)
"(((start_time < '2001-01-01 12:30:00' and end_time > '2001-03-31 14:30:00') OR (start_time <= '2001-01-01 12:30:00' and end_time > '2001-03-31 14:30:00') OR (start_time < '2001-01-01 12:30:00' and end_time >= '2001-03-31 14:30:00')))"
>>> create_temporal_relation_sql_where_statement(start, end,
... use_start=False, use_equal=True)
"((start_time = '2001-01-01 12:30:00' and end_time = '2001-03-31 14:30:00'))"
>>> create_temporal_relation_sql_where_statement(start, end,
... use_start=False, use_follows=True)
"((start_time = '2001-03-31 14:30:00'))"
>>> create_temporal_relation_sql_where_statement(start, end,
... use_start=False, use_precedes=True)
"((end_time = '2001-01-01 12:30:00'))"
>>> create_temporal_relation_sql_where_statement(start, end,
... use_start=True, use_during=True, use_overlap=True, use_contain=True,
... use_equal=True, use_follows=True, use_precedes=True)
"((start_time >= '2001-01-01 12:30:00' and start_time < '2001-03-31 14:30:00')  OR ((start_time > '2001-01-01 12:30:00' and end_time < '2001-03-31 14:30:00') OR (start_time >= '2001-01-01 12:30:00' and end_time < '2001-03-31 14:30:00') OR (start_time > '2001-01-01 12:30:00' and end_time <= '2001-03-31 14:30:00')) OR ((start_time < '2001-01-01 12:30:00' and end_time > '2001-01-01 12:30:00' and end_time < '2001-03-31 14:30:00') OR (start_time < '2001-03-31 14:30:00' and start_time > '2001-01-01 12:30:00' and end_time > '2001-03-31 14:30:00')) OR ((start_time < '2001-01-01 12:30:00' and end_time > '2001-03-31 14:30:00') OR (start_time <= '2001-01-01 12:30:00' and end_time > '2001-03-31 14:30:00') OR (start_time < '2001-01-01 12:30:00' and end_time >= '2001-03-31 14:30:00')) OR (start_time = '2001-01-01 12:30:00' and end_time = '2001-03-31 14:30:00') OR (start_time = '2001-03-31 14:30:00') OR (end_time = '2001-01-01 12:30:00'))"
temporal.spatio_temporal_relationships.print_spatio_temporal_topology_relationships(maps1, maps2=None, spatial='2D', dbif=None)[source]

Print the temporal relationships of the map lists maps1 and maps2 to stdout.

param maps1:A list of abstract_dataset objects with initiated temporal extent
param maps2:An optional list of abstract_dataset objects with initiated temporal extent
param spatial:The dimension of the spatial extent to be used: “2D” using west, east, south, north or “3D” using west, east, south, north, bottom, top
param dbif:The database interface to be used
temporal.spatio_temporal_relationships.print_temporal_topology_relationships(maps1, maps2=None, dbif=None)[source]

Print the temporal relationships of the map lists maps1 and maps2 to stdout.

param maps1:A list of abstract_dataset objects with initiated temporal extent
param maps2:An optional list of abstract_dataset objects with initiated temporal extent
param dbif:The database interface to be used
temporal.spatio_temporal_relationships.set_spatial_relationship(A, B, relation)[source]
temporal.spatio_temporal_relationships.set_temoral_relationship(A, B, relation)[source]

temporal.stds_export module

Export functions for space time datasets

Usage:

import grass.temporal as tgis

input="temp_1950_2012@PERMANENT"
output="/tmp/temp_1950_2012.tar.gz"
compression="gzip"
directory="/tmp"
where=None
format_="GTiff"
type_="strds"
tgis.export_stds(input, output, compression, directory, where, format_, type_)

(C) 2012-2013 by the GRASS Development Team This program is free software under the GNU General Public License (>=v2). Read the file COPYING that comes with GRASS for details.

authors:Soeren Gebbert
temporal.stds_export.export_stds(input, output, compression, directory, where, format_='pack', type_='strds', datatype=None)[source]

Export space time datasets as tar archive with optional compression

This method should be used to export space time datasets of type raster and vector as tar archive that can be reimported with the method import_stds().

Parameters:
  • input – The name of the space time dataset to export
  • output – The name of the archive file
  • compression

    The compression of the archive file:

    • “no” no compression
    • “gzip” GNU zip compression
    • “bzip2” Bzip compression
  • directory – The working directory used for extraction and packing
  • where – The temporal WHERE SQL statement to select a subset of maps from the space time dataset
  • format

    The export format:

    • “GTiff” Geotiff format, only for raster maps
    • “AAIGrid” Arc/Info ASCII Grid format, only for raster maps
    • “pack” The GRASS raster, 3D raster or vector Pack format,
      this is the default setting
    • “GML” GML file export format, only for vector maps,
      v.out.ogr export option
  • type

    The space time dataset type

    • “strds” Space time raster dataset
    • “str3ds” Space time 3D raster dataset
    • “stvds” Space time vector dataset
  • datatype – Force the output datatype for r.out.gdal

temporal.stds_import module

Space time dataset import functions

Usage:

import grass.temporal as tgis

input="/tmp/temp_1950_2012.tar.gz"
output="temp_1950_2012"
directory="/tmp"
title="My new dataset"
descr="May new shiny dataset"
location=None
link=True
exp=True
overr=False
create=False
tgis.import_stds(input, output, directory, title, descr, location,
                link, exp, overr, create, "strds")

(C) 2012-2013 by the GRASS Development Team This program is free software under the GNU General Public License (>=v2). Read the file COPYING that comes with GRASS for details.

authors:Soeren Gebbert
temporal.stds_import.import_stds(input, output, directory, title=None, descr=None, location=None, link=False, exp=False, overr=False, create=False, stds_type='strds', base=None, set_current_region=False, memory=300)[source]

Import space time datasets of type raster and vector

Parameters:
  • input – Name of the input archive file
  • output – The name of the output space time dataset
  • directory – The extraction directory
  • title – The title of the new created space time dataset
  • descr – The description of the new created space time dataset
  • location – The name of the location that should be created, maps are imported into this location
  • link – Switch to link raster maps instead importing them
  • exp – Extend location extents based on new dataset
  • overr – Override projection (use location’s projection)
  • create – Create the location specified by the “location” parameter and exit. Do not import the space time datasets.
  • stds_type – The type of the space time dataset that should be imported
  • base – The base name of the new imported maps, it will be extended using a numerical index.
  • memory – Cache size for raster rows, used in r.in.gdal

temporal.temporal_algebra module

@package grass.temporal

Temporal algebra parser class

(C) 2014 by the GRASS Development Team This program is free software under the GNU General Public License (>=v2). Read the file COPYING that comes with GRASS for details.

authors:Thomas Leppelt and Soeren Gebbert
>>> import grass.temporal as tgis
>>> tgis.init(True)
>>> p = tgis.TemporalAlgebraLexer()
>>> p.build()
>>> p.debug = True
>>> expression =  "C = A : B"
>>> p.test(expression)
C = A : B
LexToken(NAME,'C',1,0)
LexToken(EQUALS,'=',1,2)
LexToken(NAME,'A',1,4)
LexToken(T_SELECT,':',1,6)
LexToken(NAME,'B',1,8)
>>> expression =  "C = test1 !: test2"
>>> p.test(expression)
C = test1 !: test2
LexToken(NAME,'C',1,0)
LexToken(EQUALS,'=',1,2)
LexToken(NAME,'test1',1,4)
LexToken(T_NOT_SELECT,'!:',1,10)
LexToken(NAME,'test2',1,13)
>>> expression =  "C = test1 {:,equal} test2"
>>> p.test(expression)
C = test1 {:,equal} test2
LexToken(NAME,'C',1,0)
LexToken(EQUALS,'=',1,2)
LexToken(NAME,'test1',1,4)
LexToken(T_SELECT_OPERATOR,'{:,equal}',1,10)
LexToken(NAME,'test2',1,20)
>>> expression =  "C = test1 {!:,equal} test2"
>>> p.test(expression)
C = test1 {!:,equal} test2
LexToken(NAME,'C',1,0)
LexToken(EQUALS,'=',1,2)
LexToken(NAME,'test1',1,4)
LexToken(T_SELECT_OPERATOR,'{!:,equal}',1,10)
LexToken(NAME,'test2',1,21)
>>> expression =  "C = test1 # test2"
>>> p.test(expression)
C = test1 # test2
LexToken(NAME,'C',1,0)
LexToken(EQUALS,'=',1,2)
LexToken(NAME,'test1',1,4)
LexToken(HASH,'#',1,10)
LexToken(NAME,'test2',1,12)
>>> expression =  "C = test1 {#} test2"
>>> p.test(expression)
C = test1 {#} test2
LexToken(NAME,'C',1,0)
LexToken(EQUALS,'=',1,2)
LexToken(NAME,'test1',1,4)
LexToken(T_HASH_OPERATOR,'{#}',1,10)
LexToken(NAME,'test2',1,14)
>>> expression =  "C = test1 {#,equal} test2"
>>> p.test(expression)
C = test1 {#,equal} test2
LexToken(NAME,'C',1,0)
LexToken(EQUALS,'=',1,2)
LexToken(NAME,'test1',1,4)
LexToken(T_HASH_OPERATOR,'{#,equal}',1,10)
LexToken(NAME,'test2',1,20)
>>> expression =  "C = test1 {#,equal|during} test2"
>>> p.test(expression)
C = test1 {#,equal|during} test2
LexToken(NAME,'C',1,0)
LexToken(EQUALS,'=',1,2)
LexToken(NAME,'test1',1,4)
LexToken(T_HASH_OPERATOR,'{#,equal|during}',1,10)
LexToken(NAME,'test2',1,27)
>>> expression =  "E = test1 : test2 !: test1"
>>> p.test(expression)
E = test1 : test2 !: test1
LexToken(NAME,'E',1,0)
LexToken(EQUALS,'=',1,2)
LexToken(NAME,'test1',1,4)
LexToken(T_SELECT,':',1,10)
LexToken(NAME,'test2',1,12)
LexToken(T_NOT_SELECT,'!:',1,18)
LexToken(NAME,'test1',1,21)
>>> expression =  'D = buff_t(test1,"10 months")'
>>> p.test(expression)
D = buff_t(test1,"10 months")
LexToken(NAME,'D',1,0)
LexToken(EQUALS,'=',1,2)
LexToken(BUFF_T,'buff_t',1,4)
LexToken(LPAREN,'(',1,10)
LexToken(NAME,'test1',1,11)
LexToken(COMMA,',',1,16)
LexToken(QUOTE,'"',1,17)
LexToken(INT,10,1,18)
LexToken(NAME,'months',1,21)
LexToken(QUOTE,'"',1,27)
LexToken(RPAREN,')',1,28)
>>> expression =  'H = tsnap(test1)'
>>> p.test(expression)
H = tsnap(test1)
LexToken(NAME,'H',1,0)
LexToken(EQUALS,'=',1,2)
LexToken(TSNAP,'tsnap',1,4)
LexToken(LPAREN,'(',1,9)
LexToken(NAME,'test1',1,10)
LexToken(RPAREN,')',1,15)
>>> expression =  'H = tsnap(test2 {:,during} buff_t(test1, "1 days"))'
>>> p.test(expression)
H = tsnap(test2 {:,during} buff_t(test1, "1 days"))
LexToken(NAME,'H',1,0)
LexToken(EQUALS,'=',1,2)
LexToken(TSNAP,'tsnap',1,4)
LexToken(LPAREN,'(',1,9)
LexToken(NAME,'test2',1,10)
LexToken(T_SELECT_OPERATOR,'{:,during}',1,16)
LexToken(BUFF_T,'buff_t',1,27)
LexToken(LPAREN,'(',1,33)
LexToken(NAME,'test1',1,34)
LexToken(COMMA,',',1,39)
LexToken(QUOTE,'"',1,41)
LexToken(INT,1,1,42)
LexToken(NAME,'days',1,44)
LexToken(QUOTE,'"',1,48)
LexToken(RPAREN,')',1,49)
LexToken(RPAREN,')',1,50)
>>> expression =  'H = tshift(test2 {:,during} buff_t(test1, "1 days"), "1 months")'
>>> p.test(expression)
H = tshift(test2 {:,during} buff_t(test1, "1 days"), "1 months")
LexToken(NAME,'H',1,0)
LexToken(EQUALS,'=',1,2)
LexToken(TSHIFT,'tshift',1,4)
LexToken(LPAREN,'(',1,10)
LexToken(NAME,'test2',1,11)
LexToken(T_SELECT_OPERATOR,'{:,during}',1,17)
LexToken(BUFF_T,'buff_t',1,28)
LexToken(LPAREN,'(',1,34)
LexToken(NAME,'test1',1,35)
LexToken(COMMA,',',1,40)
LexToken(QUOTE,'"',1,42)
LexToken(INT,1,1,43)
LexToken(NAME,'days',1,45)
LexToken(QUOTE,'"',1,49)
LexToken(RPAREN,')',1,50)
LexToken(COMMA,',',1,51)
LexToken(QUOTE,'"',1,53)
LexToken(INT,1,1,54)
LexToken(NAME,'months',1,56)
LexToken(QUOTE,'"',1,62)
LexToken(RPAREN,')',1,63)
>>> expression =  'H = tshift(A , 10)'
>>> p.test(expression)
H = tshift(A , 10)
LexToken(NAME,'H',1,0)
LexToken(EQUALS,'=',1,2)
LexToken(TSHIFT,'tshift',1,4)
LexToken(LPAREN,'(',1,10)
LexToken(NAME,'A',1,11)
LexToken(COMMA,',',1,13)
LexToken(INT,10,1,15)
LexToken(RPAREN,')',1,17)
>>> expression =  'H = if(td(A) > 10, A)'
>>> p.test(expression)
H = if(td(A) > 10, A)
LexToken(NAME,'H',1,0)
LexToken(EQUALS,'=',1,2)
LexToken(IF,'if',1,4)
LexToken(LPAREN,'(',1,6)
LexToken(TD,'td',1,7)
LexToken(LPAREN,'(',1,9)
LexToken(NAME,'A',1,10)
LexToken(RPAREN,')',1,11)
LexToken(GREATER,'>',1,13)
LexToken(INT,10,1,15)
LexToken(COMMA,',',1,17)
LexToken(NAME,'A',1,19)
LexToken(RPAREN,')',1,20)
>>> expression =  'H = if(td(A) > 10, A, B)'
>>> p.test(expression)
H = if(td(A) > 10, A, B)
LexToken(NAME,'H',1,0)
LexToken(EQUALS,'=',1,2)
LexToken(IF,'if',1,4)
LexToken(LPAREN,'(',1,6)
LexToken(TD,'td',1,7)
LexToken(LPAREN,'(',1,9)
LexToken(NAME,'A',1,10)
LexToken(RPAREN,')',1,11)
LexToken(GREATER,'>',1,13)
LexToken(INT,10,1,15)
LexToken(COMMA,',',1,17)
LexToken(NAME,'A',1,19)
LexToken(COMMA,',',1,20)
LexToken(NAME,'B',1,22)
LexToken(RPAREN,')',1,23)
>>> expression =  'I = if(equals,td(A) > 10 {||,equals} td(B) < 10, A)'
>>> p.test(expression)
I = if(equals,td(A) > 10 {||,equals} td(B) < 10, A)
LexToken(NAME,'I',1,0)
LexToken(EQUALS,'=',1,2)
LexToken(IF,'if',1,4)
LexToken(LPAREN,'(',1,6)
LexToken(NAME,'equals',1,7)
LexToken(COMMA,',',1,13)
LexToken(TD,'td',1,14)
LexToken(LPAREN,'(',1,16)
LexToken(NAME,'A',1,17)
LexToken(RPAREN,')',1,18)
LexToken(GREATER,'>',1,20)
LexToken(INT,10,1,22)
LexToken(T_COMP_OPERATOR,'{||,equals}',1,25)
LexToken(TD,'td',1,37)
LexToken(LPAREN,'(',1,39)
LexToken(NAME,'B',1,40)
LexToken(RPAREN,')',1,41)
LexToken(LOWER,'<',1,43)
LexToken(INT,10,1,45)
LexToken(COMMA,',',1,47)
LexToken(NAME,'A',1,49)
LexToken(RPAREN,')',1,50)
>>> expression =  'I = if(equals,td(A) > 10 || start_day() < 10, A)'
>>> p.test(expression)
I = if(equals,td(A) > 10 || start_day() < 10, A)
LexToken(NAME,'I',1,0)
LexToken(EQUALS,'=',1,2)
LexToken(IF,'if',1,4)
LexToken(LPAREN,'(',1,6)
LexToken(NAME,'equals',1,7)
LexToken(COMMA,',',1,13)
LexToken(TD,'td',1,14)
LexToken(LPAREN,'(',1,16)
LexToken(NAME,'A',1,17)
LexToken(RPAREN,')',1,18)
LexToken(GREATER,'>',1,20)
LexToken(INT,10,1,22)
LexToken(OR,'|',1,25)
LexToken(OR,'|',1,26)
LexToken(START_DAY,'start_day',1,28)
LexToken(LPAREN,'(',1,37)
LexToken(RPAREN,')',1,38)
LexToken(LOWER,'<',1,40)
LexToken(INT,10,1,42)
LexToken(COMMA,',',1,44)
LexToken(NAME,'A',1,46)
LexToken(RPAREN,')',1,47)
>>> expression =  'E = if({equals},td(A) >= 4 {&&,contain} td(B) == 2, C : D)'
>>> p.test(expression)
E = if({equals},td(A) >= 4 {&&,contain} td(B) == 2, C : D)
LexToken(NAME,'E',1,0)
LexToken(EQUALS,'=',1,2)
LexToken(IF,'if',1,4)
LexToken(LPAREN,'(',1,6)
LexToken(T_REL_OPERATOR,'{equals}',1,7)
LexToken(COMMA,',',1,15)
LexToken(TD,'td',1,16)
LexToken(LPAREN,'(',1,18)
LexToken(NAME,'A',1,19)
LexToken(RPAREN,')',1,20)
LexToken(GREATER_EQUALS,'>=',1,22)
LexToken(INT,4,1,25)
LexToken(T_COMP_OPERATOR,'{&&,contain}',1,27)
LexToken(TD,'td',1,40)
LexToken(LPAREN,'(',1,42)
LexToken(NAME,'B',1,43)
LexToken(RPAREN,')',1,44)
LexToken(CEQUALS,'==',1,46)
LexToken(INT,2,1,49)
LexToken(COMMA,',',1,50)
LexToken(NAME,'C',1,52)
LexToken(T_SELECT,':',1,54)
LexToken(NAME,'D',1,56)
LexToken(RPAREN,')',1,57)
>>> expression =  'F = if({equals},A {#,equal}, B, C : D)'
>>> p.test(expression)
F = if({equals},A {#,equal}, B, C : D)
LexToken(NAME,'F',1,0)
LexToken(EQUALS,'=',1,2)
LexToken(IF,'if',1,4)
LexToken(LPAREN,'(',1,6)
LexToken(T_REL_OPERATOR,'{equals}',1,7)
LexToken(COMMA,',',1,15)
LexToken(NAME,'A',1,16)
LexToken(T_HASH_OPERATOR,'{#,equal}',1,18)
LexToken(COMMA,',',1,27)
LexToken(NAME,'B',1,29)
LexToken(COMMA,',',1,30)
LexToken(NAME,'C',1,32)
LexToken(T_SELECT,':',1,34)
LexToken(NAME,'D',1,36)
LexToken(RPAREN,')',1,37)
>>> p = tgis.TemporalAlgebraParser()
>>> p.run = False
>>> p.debug = True
>>> expression =  "D = A {!:} B {:,during} C"
>>> print(expression)
D = A {!:} B {:,during} C
>>> ret = p.parse(expression)
A* =  A {!:} B
A** =  A* {:,during} C
D = A**
>>> expression =  "D = A {:} B {!:,during} C"
>>> print(expression)
D = A {:} B {!:,during} C
>>> ret = p.parse(expression)
A* =  A {:} B
A** =  A* {!:,during} C
D = A**
>>> p.run = False
>>> p.debug = False
>>> expression =  "C = test1 : test2"
>>> print(expression)
C = test1 : test2
>>> ret = p.parse(expression, 'stvds')
>>> expression =  'D = buff_t(test1,"10 months")'
>>> print(expression)
D = buff_t(test1,"10 months")
>>> ret = p.parse(expression, 'stvds')
>>> expression =  'E = test2 {:,during} buff_t(test1,"1 days")'
>>> print(expression)
E = test2 {:,during} buff_t(test1,"1 days")
>>> ret = p.parse(expression, 'stvds')
>>> expression =  'F = test2 {:,equal} buff_t(test1,"1 days")'
>>> print(expression)
F = test2 {:,equal} buff_t(test1,"1 days")
>>> ret = p.parse(expression, 'stvds')
>>> p.debug = True
>>> expression =  'H = tsnap(test2 {:,during} buff_t(test1, "1 days"))'
>>> ret = p.parse(expression, 'stvds')
test1* = buff_t( test1 , " 1 days " )
test2* =  test2 {:,during} test1*
test2** = tsnap( test2* )
H = test2**
>>> expression =  'H = tshift(test2 {:,during} test1, "1 days")'
>>> ret = p.parse(expression, 'stvds')
test2* =  test2 {:,during} test1
test2** = tshift( test2* , " 1 days " )
H = test2**
>>> expression =  'H = tshift(H, 3)'
>>> ret = p.parse(expression, 'stvds')
H* = tshift( H , 3 )
H = H*
>>> expression =  'C = if(td(A) == 2, A)'
>>> ret = p.parse(expression, 'stvds')
td(A)
td(A) == 2
A* =  if condition None  then  A
C = A*
>>> expression =  'C = if(td(A) == 5, A, B)'
>>> ret = p.parse(expression, 'stvds')
td(A)
td(A) == 5
A* =  if condition None  then  A  else  B
C = A*
>>> expression =  'C = if(td(A) == 5 || start_date(A) > "2010-01-01", A, B)'
>>> ret = p.parse(expression, 'stvds')
td(A)
td(A) == 5
start_date A > "2010-01-01"
None || None
A* =  if condition None  then  A  else  B
C = A*

>>> p = tgis.TemporalAlgebraLexer()
>>> p.build()
>>> p.debug = True
>>> expression =  "D = strds(A) : stvds(B) : str3ds(C)"
>>> p.test(expression)
D = strds(A) : stvds(B) : str3ds(C)
LexToken(NAME,'D',1,0)
LexToken(EQUALS,'=',1,2)
LexToken(STRDS,'strds',1,4)
LexToken(LPAREN,'(',1,9)
LexToken(NAME,'A',1,10)
LexToken(RPAREN,')',1,11)
LexToken(T_SELECT,':',1,13)
LexToken(STVDS,'stvds',1,15)
LexToken(LPAREN,'(',1,20)
LexToken(NAME,'B',1,21)
LexToken(RPAREN,')',1,22)
LexToken(T_SELECT,':',1,24)
LexToken(STR3DS,'str3ds',1,26)
LexToken(LPAREN,'(',1,32)
LexToken(NAME,'C',1,33)
LexToken(RPAREN,')',1,34)

>>> p = tgis.TemporalAlgebraLexer()
>>> p.build()
>>> p.debug = True
>>> expression =  "R = if(A {#,during} stvds(C) == 1, A)"
>>> p.test(expression)
R = if(A {#,during} stvds(C) == 1, A)
LexToken(NAME,'R',1,0)
LexToken(EQUALS,'=',1,2)
LexToken(IF,'if',1,4)
LexToken(LPAREN,'(',1,6)
LexToken(NAME,'A',1,7)
LexToken(T_HASH_OPERATOR,'{#,during}',1,9)
LexToken(STVDS,'stvds',1,20)
LexToken(LPAREN,'(',1,25)
LexToken(NAME,'C',1,26)
LexToken(RPAREN,')',1,27)
LexToken(CEQUALS,'==',1,29)
LexToken(INT,1,1,32)
LexToken(COMMA,',',1,33)
LexToken(NAME,'A',1,35)
LexToken(RPAREN,')',1,36)

>>> p = tgis.TemporalAlgebraLexer()
>>> p.build()
>>> p.debug = True
>>> expression =  "R = if({during}, stvds(C) {#,contains} A == 2, A)"
>>> p.test(expression)
R = if({during}, stvds(C) {#,contains} A == 2, A)
LexToken(NAME,'R',1,0)
LexToken(EQUALS,'=',1,2)
LexToken(IF,'if',1,4)
LexToken(LPAREN,'(',1,6)
LexToken(T_REL_OPERATOR,'{during}',1,7)
LexToken(COMMA,',',1,15)
LexToken(STVDS,'stvds',1,17)
LexToken(LPAREN,'(',1,22)
LexToken(NAME,'C',1,23)
LexToken(RPAREN,')',1,24)
LexToken(T_HASH_OPERATOR,'{#,contains}',1,26)
LexToken(NAME,'A',1,39)
LexToken(CEQUALS,'==',1,41)
LexToken(INT,2,1,44)
LexToken(COMMA,',',1,45)
LexToken(NAME,'A',1,47)
LexToken(RPAREN,')',1,48)
exception temporal.temporal_algebra.FatalError(msg)[source]

Bases: exceptions.Exception

class temporal.temporal_algebra.GlobalTemporalVar[source]

Bases: object

This class handles global temporal variable conditional expressions, like start_doy() == 3. The three parts of the statement are stored separately in tfunc (START_DOY), compop (==) and value (3). But also boolean values, time differences and relation operators for comparison in if-statements can be stored in this class.

get_type()[source]
get_type_value()[source]
class temporal.temporal_algebra.TemporalAlgebraLexer[source]

Bases: object

Lexical analyzer for the GRASS GIS temporal algebra

build(**kwargs)[source]
conditional_functions = {'merge': 'MERGE', 'tmap': 'TMAP', 'stvds': 'STVDS', 'str3ds': 'STR3DS', 'strds': 'STRDS', 'buff_t': 'BUFF_T', 'tsnap': 'TSNAP', 'tshift': 'TSHIFT', 'if': 'IF'}
datetime_functions = {'start_datetime': 'START_DATETIME', 'end_date': 'END_DATE', 'start_time': 'START_TIME', 'end_datetime': 'END_DATETIME', 'start_date': 'START_DATE', 'end_time': 'END_TIME'}
t_AND = '[&]'
t_CEQUALS = '=='
t_COMMA = ','
t_DATE(t)[source]

“dddd-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])”

t_DATETIME(t)[source]

“dddd-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])[ T](0[0-9]|1(0-9)|2[0-4]):(0[0-9]|[1-5][0-9]|60):(0[0-9]|[1-5][0-9]|60)”

t_EQUALS = '='
t_FLOAT(t)[source]

-?d+.d*(e-?d+)?

t_GREATER = '>'
t_GREATER_EQUALS = '>='
t_HASH = '\\#'
t_INT(t)[source]

-?d+

t_LIST(t)[source]

[[][.]*[]]

t_LOWER = '<'
t_LOWER_EQUALS = '<='
t_LPAREN = '\\('
t_NAME(t)[source]

[a-zA-Z_][a-zA-Z_0-9@]*

t_OR = '[\\|]'
t_QUOTE = '[\\"\\\']'
t_RPAREN = '\\)'
t_TIME(t)[source]

“(0[0-9]|1[0-9]|2[0-4]):(0[0-9]|[1-5][0-9]|60):(0[0-9]|[1-5][0-9]|60)”

t_T_COMP_OPERATOR = '\\{(\\|\\||&&)[,][a-zA-Z\\| ]*[,]?[\\|&]?([,])?([lrudi]|left|right|union|disjoint|intersect)?\\}'
t_T_HASH_OPERATOR = '\\{[#][,]?[a-zA-Z\\| ]*([,])?([lrudi]|left|right|union|disjoint|intersect)?\\}'
t_T_NOT_SELECT = '!:'
t_T_REL_OPERATOR = '\\{([a-zA-Z\\| ])+\\}'
t_T_SELECT = ':'
t_T_SELECT_OPERATOR = '\\{[!]?[:][,]?[a-zA-Z\\| ]*([,])?([lrudi]|left|right|union|disjoint|intersect)?\\}'
t_UNEQUALS = '!='
t_error(t)[source]
t_ignore = ' \t\n'
t_newline(t)[source]

n+

temporal_symbol(t)[source]
test(data)[source]
time_functions = {'start_month': 'START_MONTH', 'start_year': 'START_YEAR', 'start_minute': 'START_MINUTE', 'end_minute': 'END_MINUTE', 'start_dow': 'START_DOW', 'start_doy': 'START_DOY', 'start_week': 'START_WEEK', 'start_hour': 'START_HOUR', 'end_hour': 'END_HOUR', 'start_day': 'START_DAY', 'end_year': 'END_YEAR', 'end_month': 'END_MONTH', 'end_dow': 'END_DOW', 'end_day': 'END_DAY', 'start_second': 'START_SECOND', 'end_second': 'END_SECOND', 'td': 'TD', 'end_doy': 'END_DOY', 'end_week': 'END_WEEK'}
tokens = ('DATETIME', 'TIME', 'DATE', 'INT', 'FLOAT', 'LPAREN', 'RPAREN', 'COMMA', 'CEQUALS', 'EQUALS', 'UNEQUALS', 'LOWER', 'LOWER_EQUALS', 'GREATER', 'GREATER_EQUALS', 'HASH', 'OR', 'AND', 'T_SELECT_OPERATOR', 'T_HASH_OPERATOR', 'T_COMP_OPERATOR', 'T_REL_OPERATOR', 'T_SELECT', 'T_NOT_SELECT', 'NAME', 'QUOTE', 'START_DATETIME', 'END_DATE', 'START_TIME', 'END_DATETIME', 'START_DATE', 'END_TIME', 'START_MONTH', 'START_YEAR', 'START_MINUTE', 'END_MINUTE', 'START_DOW', 'START_DOY', 'START_WEEK', 'START_HOUR', 'END_HOUR', 'START_DAY', 'END_YEAR', 'END_MONTH', 'END_DOW', 'END_DAY', 'START_SECOND', 'END_SECOND', 'TD', 'END_DOY', 'END_WEEK', 'MERGE', 'TMAP', 'STVDS', 'STR3DS', 'STRDS', 'BUFF_T', 'TSNAP', 'TSHIFT', 'IF')
class temporal.temporal_algebra.TemporalAlgebraParser(pid=None, run=True, debug=False, spatial=False, register_null=False, dry_run=False, nprocs=1)[source]

Bases: object

The temporal algebra class

assign_bool_value(map_i, tbrelations, topolist=['EQUAL'])[source]

Function to assign boolean map value based on the map_values from the compared map list by topological relationships.

param map_i:Map object with temporal extent.
param tbrelations:
 List of temporal relation to map_i.
param topolist:List of strings for given temporal relations.
return:Map object with conditional value that has been assigned by relation maps that fulfil the topological relationships to maplistB specified in topolist.
build_condition_list(tvarexpr, thenlist, topolist=['EQUAL'])[source]

This function evaluates temporal variable expressions of a conditional expression in two steps. At first it combines stepwise the single conditions by their relations with LALR. In this prossess sub condition map lists will be created which will include information of the underlying single conditions. Important: The temporal relations between conditions are evaluated by implicit aggregation. In the second step the aggregated condition map list will be compared with the map list of conclusion statements by the given temporal relation.

The result is written as ‘condition_value’ attribute to the resulting map objects. These attribute consists of boolean expressions and operators which can be evaluated with the eval_condition_list function. [True, ‘||’, False, ‘&&’, True]

For example: td(A) == 1 && start_day() > 5 –> [True || False]
(for one map.condition_value in a then map list)
Parameters:
  • tvarexpr – List of GlobalTemporalVar objects and map lists. The list is constructed by the TemporalAlgebraParser in order of expression evaluation in the parser.
  • thenlist – Map list object of the conclusion statement. It will be compared and evaluated by the conditions.
  • topolist – List of temporal relations between the conditions and the conclusions.
Returns:

Map list with conditional values for all temporal expressions.

check_stds(input, clear=False, stds_type=None, check_type=True)[source]

Check if input space time dataset exist in database and return its map list.

Parameters:
  • input – Name of space time data set as string or list of maps.
  • clear – Reset the stored conditional values to empty list.
  • check_type – Check the type of the space time dataset to match the global stds type
  • stds_type – The type of the space time dataset to be opened, if not provided then self.stdstype will be used
Returns:

List of maps.

compare_bool_value(map_i, tbrelations, compop, aggregate, topolist=['EQUAL'])[source]
Function to evaluate two map lists with boolean values by boolean
comparison operator.
Parameters:
  • map_i – Map object with temporal extent.
  • tbrelations – List of temporal relation to map_i.
  • topolist – List of strings for given temporal relations.
  • compop – Comparison operator, && or ||.
  • aggregate – Aggregation operator for relation map list, & or |.
Returns:

Map object with conditional value that has been evaluated by comparison operators.

eval_condition_list(maplist, inverse=False)[source]

This function evaluates conditional values of a map list. A recursive function is used to evaluate comparison statements from left to right in the given conditional list.

For example:

- [True,  '||', False, '&&', True]  -> True
- [True,  '||', False, '&&', False] -> False
- [True,  '&&', False, '&&', True]  -> False
- [False, '||', True,  '||', False] -> True
- [False, '&&', True,  '&&', True]  -> False
- [True,  '&&', True,  '&&', True]  -> True
- [True,  '&&', True]               -> True
- [True,  '&&', False]              -> False
- [False, '||', True]               -> True
Parameters:tvarexpr – List of GlobalTemporalVar objects and map lists. The list is constructed by the TemporalAlgebraParser in order of expression evaluation in the parser.
Returns:Map list with conditional values for all temporal expressions.
eval_datetime_str(tfuncval, comp, value)[source]
eval_global_var(gvar, maplist)[source]
This function evaluates a global variable expression for a map list.
For example: start_day() > 5 , end_month() == 2.
Parameters:
  • gvar – Object of type GlobalTemporalVar containing temporal.
  • maplist – List of map objects.
Returns:

List of maps from maplist with added conditional boolean values.

eval_map_list(maplist, thenlist, topolist=['EQUAL'])[source]
This function transfers boolean values from temporal expression
from one map list to another by their topology. These boolean values are added to the maps as condition_value.
Parameters:
  • maplist – List of map objects containing boolean map values.
  • thenlist – List of map objects where the boolean values should be added.
Returns:

List of maps from thenlist with added conditional boolean values.

eval_toperator(operator, optype='relation')[source]

This function evaluates a string containing temporal operations.

param operator:String of temporal operations, e.g. {!=,equal|during,l}.
param optype:String to define operator type.
:return :List of temporal relations (equal, during), the given function
(!:) and the interval/instances (l).
>>> import grass.temporal as tgis
>>> tgis.init()
>>> p = tgis.TemporalOperatorParser()
>>> operator = "{+, during}"
>>> p.parse(operator, optype = 'raster')
>>> print((p.relations, p.temporal, p.function))
(['during'], 'l', '+')
generate_map_name()[source]

Generate an unique map name and register it in the objects map list

The map names are unique between processes. Do not use the same object for map name generation in multiple threads.

generate_new_map(base_map, bool_op='and', copy=True, rename=True, remove=False)[source]

Generate a new map using the spatio-temporal extent of the base map

Parameters:
  • base_map – This map is used to create the new map
  • bool_op – The boolean operator specifying the spatial extent operation (intersection, union, disjoint union)
  • copy – Specifies if the temporal extent of mapB should be copied to mapA
  • rename
    Specifies if the generated map get a random name or get
    the id from the base map.
    param remove:Set this True if this map is an intermediate or empty map that should be removed
Returns:

Map object

get_temporal_func_dict(map)[source]
This function creates a dictionary containing temporal functions for a
map dataset with time stamp.
Parameters:map – Map object with time stamps.
Returns:Dictionary with temporal functions for given input map.
>>> import grass.temporal as tgis
>>> import datetime
>>> tgis.init()
>>> l = tgis.TemporalAlgebraParser()
>>> # Example with one list of maps
>>> # Create one list of maps with equal time stamps
>>> for i in range(1):
...     idA = "a%i@B"%(i)
...     mapA = tgis.RasterDataset(idA)
...     mapA.uid = idA
...     check = mapA.set_absolute_time(datetime.datetime(2000,1,1),
...             datetime.datetime(2000,10,1))
...     tfuncdict = l.get_temporal_func_dict(mapA)
>>> print(tfuncdict["START_YEAR"])
2000
>>> print(tfuncdict["START_TIME"])
00:00:00
>>> print(tfuncdict["START_DATE"])
2000-01-01
>>> print(tfuncdict["START_DATETIME"])
2000-01-01 00:00:00
get_temporal_topo_list(maplistA, maplistB=None, topolist=['EQUAL'], assign_val=False, count_map=False, compare_bool=False, compop=None, aggregate=None)[source]

Build temporal topology for two space time data sets, copy map objects for given relation into map list.

Parameters:
  • maplistA – List of maps.
  • maplistB – List of maps.
  • topolist – List of strings of temporal relations.
  • assign_val – Boolean for assigning a boolean map value based on the map_values from the compared map list by topological relationships.
  • count_map – Boolean if the number of topological related maps should be returned.
  • compare_bool – Boolean for comparing boolean map values based on related map list and compariosn operator.
  • compop – Comparison operator, && or ||.
  • aggregate – Aggregation operator for relation map list, & or |.
Returns:

List of maps from maplistA that fulfil the topological relationships to maplistB specified in topolist.

# Example with two lists of maps
>>> import grass.temporal as tgis
>>> tgis.init(True)
>>> l = tgis.TemporalAlgebraParser()
>>> # Create two list of maps with equal time stamps
>>> mapsA = []
>>> mapsB = []
>>> for i in range(10):
...     idA = "a%i@B"%(i)
...     mapA = tgis.RasterDataset(idA)
...     mapA.uid = idA
...     idB = "b%i@B"%(i)
...     mapB = tgis.RasterDataset(idB)
...     mapB.uid = idB
...     check = mapA.set_relative_time(i, i + 1, "months")
...     check = mapB.set_relative_time(i, i + 1, "months")
...     mapsA.append(mapA)
...     mapsB.append(mapB)
>>> resultlist = l.get_temporal_topo_list(mapsA, mapsB, ['EQUAL'])
>>> for map in resultlist:
...     if map.get_equal():
...         relations = map.get_equal()
...         print("Map %s has equal relation to map %s"%(map.get_name(),
...               relations[0].get_name()))
Map a0 has equal relation to map b0
Map a1 has equal relation to map b1
Map a2 has equal relation to map b2
Map a3 has equal relation to map b3
Map a4 has equal relation to map b4
Map a5 has equal relation to map b5
Map a6 has equal relation to map b6
Map a7 has equal relation to map b7
Map a8 has equal relation to map b8
Map a9 has equal relation to map b9
>>> resultlist = l.get_temporal_topo_list(mapsA, mapsB, ['DURING'])
>>> print(resultlist)
[]
>>> # Create two list of maps with equal time stamps
>>> mapsA = []
>>> mapsB = []
>>> for i in range(10):
...     idA = "a%i@B"%(i)
...     mapA = tgis.RasterDataset(idA)
...     mapA.uid = idA
...     idB = "b%i@B"%(i)
...     mapB = tgis.RasterDataset(idB)
...     mapB.uid = idB
...     check = mapA.set_relative_time(i, i + 1, "months")
...     check = mapB.set_relative_time(i, i + 2, "months")
...     mapsA.append(mapA)
...     mapsB.append(mapB)
>>> resultlist = l.get_temporal_topo_list(mapsA, mapsB, ['starts','during'])
>>> for map in resultlist:
...     if map.get_starts():
...         relations = map.get_starts()
...         print("Map %s has start relation to map %s"%(map.get_name(),
...               relations[0].get_name()))
Map a0 has start relation to map b0
Map a1 has start relation to map b1
Map a2 has start relation to map b2
Map a3 has start relation to map b3
Map a4 has start relation to map b4
Map a5 has start relation to map b5
Map a6 has start relation to map b6
Map a7 has start relation to map b7
Map a8 has start relation to map b8
Map a9 has start relation to map b9
>>> for map in resultlist:
...     if map.get_during():
...         relations = map.get_during()
...         print("Map %s has during relation to map %s"%(map.get_name(),
...               relations[0].get_name()))
Map a0 has during relation to map b0
Map a1 has during relation to map b0
Map a2 has during relation to map b1
Map a3 has during relation to map b2
Map a4 has during relation to map b3
Map a5 has during relation to map b4
Map a6 has during relation to map b5
Map a7 has during relation to map b6
Map a8 has during relation to map b7
Map a9 has during relation to map b8
>>> # Create two list of maps with equal time stamps and map_value method.
>>> mapsA = []
>>> mapsB = []
>>> for i in range(10):
...     idA = "a%i@B"%(i)
...     mapA = tgis.RasterDataset(idA)
...     mapA.uid = idA
...     idB = "b%i@B"%(i)
...     mapB = tgis.RasterDataset(idB)
...     mapB.uid = idB
...     check = mapA.set_relative_time(i, i + 1, "months")
...     check = mapB.set_relative_time(i, i + 1, "months")
...     mapB.map_value = True
...     mapsA.append(mapA)
...     mapsB.append(mapB)
>>> # Create two list of maps with equal time stamps
>>> mapsA = []
>>> mapsB = []
>>> for i in range(10):
...     idA = "a%i@B"%(i)
...     mapA = tgis.RasterDataset(idA)
...     mapA.uid = idA
...     mapA.map_value = True
...     idB = "b%i@B"%(i)
...     mapB = tgis.RasterDataset(idB)
...     mapB.uid = idB
...     mapB.map_value = False
...     check = mapA.set_absolute_time(datetime(2000,1,i+1),
...             datetime(2000,1,i + 2))
...     check = mapB.set_absolute_time(datetime(2000,1,i+6),
...             datetime(2000,1,i + 7))
...     mapsA.append(mapA)
...     mapsB.append(mapB)
>>> resultlist = l.get_temporal_topo_list(mapsA, mapsB)
>>> for map in resultlist:
...     print(map.get_id())
a5@B
a6@B
a7@B
a8@B
a9@B
>>> resultlist = l.get_temporal_topo_list(mapsA, mapsB, ['during'])
>>> for map in resultlist:
...     print(map.get_id())
overlay_map_extent(mapA, mapB, bool_op=None, temp_op='l', copy=False)[source]

Compute the spatio-temporal extent of two topological related maps

Parameters:
  • mapA – The first map
  • mapB – The second maps
  • bool_op – The boolean operator specifying the spatial extent operation (intersection, union, disjoint union)
  • temp_op – The temporal operator specifying the temporal extent operation (intersection, union, disjoint union, right reference) Left reference is the default temporal extent behaviour.
  • copy – Specifies if the temporal extent of mapB should be copied to mapA
Returns:

0 if there is no overlay

p_compare_op(t)[source]
comp_op : CEQUALS
UNEQUALS
LOWER
LOWER_EQUALS
GREATER
GREATER_EQUALS
p_error(t)[source]
p_expr_condition_elif(t)[source]
expr : IF LPAREN t_var_expr COMMA stds COMMA stds RPAREN
IF LPAREN t_var_expr COMMA stds COMMA expr RPAREN
IF LPAREN t_var_expr COMMA expr COMMA stds RPAREN
IF LPAREN t_var_expr COMMA expr COMMA expr RPAREN
p_expr_condition_elif_relation(t)[source]
expr : IF LPAREN T_REL_OPERATOR COMMA t_var_expr COMMA stds COMMA stds RPAREN
IF LPAREN T_REL_OPERATOR COMMA t_var_expr COMMA stds COMMA expr RPAREN
IF LPAREN T_REL_OPERATOR COMMA t_var_expr COMMA expr COMMA stds RPAREN
IF LPAREN T_REL_OPERATOR COMMA t_var_expr COMMA expr COMMA expr RPAREN
p_expr_condition_if(t)[source]
expr : IF LPAREN t_var_expr COMMA stds RPAREN
IF LPAREN t_var_expr COMMA expr RPAREN
p_expr_condition_if_relation(t)[source]
expr : IF LPAREN T_REL_OPERATOR COMMA t_var_expr COMMA stds RPAREN
IF LPAREN T_REL_OPERATOR COMMA t_var_expr COMMA expr RPAREN
p_expr_str3ds_function(t)[source]

expr : STR3DS LPAREN stds RPAREN

p_expr_strds_function(t)[source]

expr : STRDS LPAREN stds RPAREN

p_expr_stvds_function(t)[source]

expr : STVDS LPAREN stds RPAREN

p_expr_t_buff(t)[source]
expr : BUFF_T LPAREN stds COMMA QUOTE number NAME QUOTE RPAREN
BUFF_T LPAREN expr COMMA QUOTE number NAME QUOTE RPAREN
BUFF_T LPAREN stds COMMA number RPAREN
BUFF_T LPAREN expr COMMA number RPAREN
p_expr_t_not_select(t)[source]
expr : stds T_NOT_SELECT stds
expr T_NOT_SELECT stds
stds T_NOT_SELECT expr
expr T_NOT_SELECT expr
p_expr_t_select(t)[source]
expr : stds T_SELECT stds
expr T_SELECT stds
stds T_SELECT expr
expr T_SELECT expr
p_expr_t_select_operator(t)[source]
expr : stds T_SELECT_OPERATOR stds
expr T_SELECT_OPERATOR stds
stds T_SELECT_OPERATOR expr
expr T_SELECT_OPERATOR expr
p_expr_t_shift(t)[source]
expr : TSHIFT LPAREN stds COMMA QUOTE number NAME QUOTE RPAREN
TSHIFT LPAREN expr COMMA QUOTE number NAME QUOTE RPAREN
TSHIFT LPAREN stds COMMA number RPAREN
TSHIFT LPAREN expr COMMA number RPAREN
p_expr_t_snap(t)[source]
expr : TSNAP LPAREN stds RPAREN
TSNAP LPAREN expr RPAREN
p_expr_tmap_function(t)[source]

expr : TMAP LPAREN stds RPAREN

p_expr_tmerge_function(t)[source]
expr : MERGE LPAREN stds COMMA stds RPAREN
MERGE LPAREN expr COMMA stds RPAREN
MERGE LPAREN stds COMMA expr RPAREN
MERGE LPAREN expr COMMA expr RPAREN
p_number(t)[source]

number : INT | FLOAT

p_paren_expr(t)[source]

expr : LPAREN expr RPAREN

p_statement_assign(t)[source]

statement : stds EQUALS expr

p_stds_1(t)[source]

stds : NAME

p_t_hash(t)[source]
t_hash_var : stds HASH stds
expr HASH stds
stds HASH expr
expr HASH expr
p_t_hash2(t)[source]
t_hash_var : stds T_HASH_OPERATOR stds
stds T_HASH_OPERATOR expr
expr T_HASH_OPERATOR stds
expr T_HASH_OPERATOR expr
p_t_hash_paren(t)[source]

t_hash_var : LPAREN t_hash_var RPAREN

p_t_td_var(t)[source]
t_td_var : TD LPAREN stds RPAREN
TD LPAREN expr RPAREN
p_t_time_var(t)[source]
t_var : START_DOY
START_DOW
START_YEAR
START_MONTH
START_WEEK
START_DAY
START_HOUR
START_MINUTE
START_SECOND
END_DOY
END_DOW
END_YEAR
END_MONTH
END_WEEK
END_DAY
END_HOUR
END_MINUTE
END_SECOND
p_t_var_expr_comp(t)[source]
t_var_expr : t_var_expr AND AND t_var_expr
t_var_expr OR OR t_var_expr
p_t_var_expr_comp_op(t)[source]

t_var_expr : t_var_expr T_COMP_OPERATOR t_var_expr

p_t_var_expr_number(t)[source]
t_var_expr : t_var LPAREN stds RPAREN comp_op number
t_var LPAREN expr RPAREN comp_op number
p_t_var_expr_td_hash(t)[source]
t_var_expr : t_td_var comp_op number
t_hash_var comp_op number
p_t_var_expr_time(t)[source]
t_var_expr : START_TIME LPAREN stds RPAREN comp_op TIME
START_DATE LPAREN stds RPAREN comp_op DATE
START_DATETIME LPAREN stds RPAREN comp_op DATETIME
END_TIME LPAREN stds RPAREN comp_op TIME
END_DATE LPAREN stds RPAREN comp_op DATE
END_DATETIME LPAREN stds RPAREN comp_op DATETIME
START_TIME LPAREN expr RPAREN comp_op TIME
START_DATE LPAREN expr RPAREN comp_op DATE
START_DATETIME LPAREN expr RPAREN comp_op DATETIME
END_TIME LPAREN expr RPAREN comp_op TIME
END_DATE LPAREN expr RPAREN comp_op DATE
END_DATETIME LPAREN expr RPAREN comp_op DATETIME
parse(expression, stdstype='strds', maptype='rast', mapclass=<class 'temporal.space_time_datasets.RasterDataset'>, basename=None, overwrite=False)[source]

Parse the algebra expression and run the computation

Parameters:
  • expression
  • stdstype
  • maptype
  • mapclass
  • basename
  • overwrite
Returns:

The process chain dictionary is dry-run was enabled, None otherwise

perform_temporal_selection(maplistA, maplistB, topolist=['EQUAL'], inverse=False, assign_val=False)[source]

This function performs temporal selection operation.

Parameters:
  • maplistA – List of maps representing the left side of a temporal expression.
  • maplistB – List of maps representing the right side of a temporal expression.
  • topolist – List of strings of temporal relations.
  • inverse – Boolean value that specifies if the selection should be inverted.
  • assign_val – Boolean for assigning a boolean map value based on the map_values from the compared map list by topological relationships.
Returns:

List of selected maps from maplistA.

>>> import grass.temporal as tgis
>>> tgis.init()
>>> l = tgis.TemporalAlgebraParser()
>>> # Example with two lists of maps
>>> # Create two list of maps with equal time stamps
>>> mapsA = []
>>> mapsB = []
>>> for i in range(10):
...     idA = "a%i@B"%(i)
...     mapA = tgis.RasterDataset(idA)
...     mapA.uid = idA
...     idB = "b%i@B"%(i)
...     mapB = tgis.RasterDataset(idB)
...     mapB.uid = idB
...     check = mapA.set_relative_time(i, i + 1, "months")
...     check = mapB.set_relative_time(i + 5, i + 6, "months")
...     mapsA.append(mapA)
...     mapsB.append(mapB)
>>> resultlist = l.perform_temporal_selection(mapsA, mapsB, ['EQUAL'],
...                                           False)
>>> for map in resultlist:
...     if map.get_equal():
...         relations = map.get_equal()
...         print("Map %s has equal relation to map %s"%(map.get_name(),
...               relations[0].get_name()))
Map a5 has equal relation to map b0
Map a6 has equal relation to map b1
Map a7 has equal relation to map b2
Map a8 has equal relation to map b3
Map a9 has equal relation to map b4
>>> resultlist = l.perform_temporal_selection(mapsA, mapsB, ['EQUAL'],
...                                           True)
>>> for map in resultlist:
...     if not map.get_equal():
...         print("Map %s has no equal relation to mapset mapsB"%(map.get_name()))
Map a0 has no equal relation to mapset mapsB
Map a1 has no equal relation to mapset mapsB
Map a2 has no equal relation to mapset mapsB
Map a3 has no equal relation to mapset mapsB
Map a4 has no equal relation to mapset mapsB
precedence = (('left', 'T_SELECT_OPERATOR', 'T_SELECT', 'T_NOT_SELECT', 'T_HASH_OPERATOR', 'HASH'), ('left', 'AND', 'OR', 'T_COMP_OPERATOR'))
remove_maps()[source]

Removes empty or intermediate maps of different type.

set_granularity(maplistA, maplistB, toperator='l', topolist=['EQUAL'])[source]
This function sets the temporal extends of a list of maps based on
another map list.
Parameters:
  • maplistB – List of maps.
  • maplistB – List of maps.
  • toperator – String containing the temporal operator: l, r, d, i, u.
  • topolist – List of topological relations.
Returns:

List of maps with the new temporal extends.

>>> import grass.temporal as tgis
>>> tgis.init()
>>> p = tgis.TemporalAlgebraParser()
>>> # Create two list of maps with equal time stamps
>>> mapsA = []
>>> mapsB = []
>>> for i in range(10):
...     idA = "a%i@B"%(i)
...     mapA = tgis.RasterDataset(idA)
...     mapA.uid = idA
...     idB = "b%i@B"%(i)
...     mapB = tgis.RasterDataset(idB)
...     mapB.uid = idB
...     check = mapA.set_relative_time(i, i + 1, "months")
...     check = mapB.set_relative_time(i*2, i*2 + 2, "months")
...     mapsA.append(mapA)
...     mapsB.append(mapB)
>>> resultlist = p.set_granularity(mapsA, mapsB, toperator = "u", topolist = ["during"])
>>> for map in resultlist:
...     start,end,unit = map.get_relative_time()
...     print(map.get_id() + ' - start: ' + str(start) + ' end: ' + str(end))
a1@B - start: 0 end: 2
a0@B - start: 0 end: 2
a3@B - start: 2 end: 4
a2@B - start: 2 end: 4
a5@B - start: 4 end: 6
a4@B - start: 4 end: 6
a7@B - start: 6 end: 8
a6@B - start: 6 end: 8
a9@B - start: 8 end: 10
a8@B - start: 8 end: 10
set_temporal_extent_list(maplist, topolist=['EQUAL'], temporal='l')[source]
Change temporal extent of map list based on temporal relations to
other map list and given temporal operator.
Parameters:
  • maplist – List of map objects for which relations has been build correctly.
  • topolist – List of strings of temporal relations.
  • temporal – The temporal operator specifying the temporal extent operation (intersection, union, disjoint union, right reference, left reference).
Returns:

Map list with specified temporal extent.

setup_common_granularity(expression, stdstype='strds', lexer=None)[source]

Configure the temporal algebra to use the common granularity of all space time datasets in the expression to generate the map lists.

This function will analyze the expression to detect space time datasets and computes the common granularity from all granularities of the input space time datasets.

This granularity is then be used to generate the map lists. Hence, all maps from all STDS will have equidistant temporal extents. The only meaningful temporal relation is therefore “equal”.

Parameters:
  • expression – The algebra expression to analyze
  • lexer – The temporal algebra lexer (select, raster, voxel, vector) that should be used to parse the expression, default is TemporalAlgebraLexer
Returns:

True if successful, False otherwise

tokens = ('DATETIME', 'TIME', 'DATE', 'INT', 'FLOAT', 'LPAREN', 'RPAREN', 'COMMA', 'CEQUALS', 'EQUALS', 'UNEQUALS', 'LOWER', 'LOWER_EQUALS', 'GREATER', 'GREATER_EQUALS', 'HASH', 'OR', 'AND', 'T_SELECT_OPERATOR', 'T_HASH_OPERATOR', 'T_COMP_OPERATOR', 'T_REL_OPERATOR', 'T_SELECT', 'T_NOT_SELECT', 'NAME', 'QUOTE', 'START_DATETIME', 'END_DATE', 'START_TIME', 'END_DATETIME', 'START_DATE', 'END_TIME', 'START_MONTH', 'START_YEAR', 'START_MINUTE', 'END_MINUTE', 'START_DOW', 'START_DOY', 'START_WEEK', 'START_HOUR', 'END_HOUR', 'START_DAY', 'END_YEAR', 'END_MONTH', 'END_DOW', 'END_DAY', 'START_SECOND', 'END_SECOND', 'TD', 'END_DOY', 'END_WEEK', 'MERGE', 'TMAP', 'STVDS', 'STR3DS', 'STRDS', 'BUFF_T', 'TSNAP', 'TSHIFT', 'IF')

temporal.temporal_extent module

Temporal extent classes

Usage:

>>> import grass.temporal as tgis
>>> from datetime import datetime
>>> tgis.init()
>>> t = tgis.RasterRelativeTime()
>>> t = tgis.RasterAbsoluteTime()

(C) 2012-2013 by the GRASS Development Team This program is free software under the GNU General Public License (>=v2). Read the file COPYING that comes with GRASS for details.

authors:Soeren Gebbert
class temporal.temporal_extent.AbsoluteTemporalExtent(table=None, ident=None, start_time=None, end_time=None)[source]

Bases: temporal.temporal_extent.TemporalExtent

This is the absolute time class for all maps and spacetime datasets

start_time and end_time must be of type datetime

print_info()[source]

Print information about this class in human readable style

print_shell_info()[source]

Print information about this class in shell style

class temporal.temporal_extent.Raster3DAbsoluteTime(ident=None, start_time=None, end_time=None)[source]

Bases: temporal.temporal_extent.AbsoluteTemporalExtent

class temporal.temporal_extent.Raster3DRelativeTime(ident=None, start_time=None, end_time=None, unit=None)[source]

Bases: temporal.temporal_extent.RelativeTemporalExtent

class temporal.temporal_extent.RasterAbsoluteTime(ident=None, start_time=None, end_time=None)[source]

Bases: temporal.temporal_extent.AbsoluteTemporalExtent

class temporal.temporal_extent.RasterRelativeTime(ident=None, start_time=None, end_time=None, unit=None)[source]

Bases: temporal.temporal_extent.RelativeTemporalExtent

class temporal.temporal_extent.RelativeTemporalExtent(table=None, ident=None, start_time=None, end_time=None, unit=None)[source]

Bases: temporal.temporal_extent.TemporalExtent

This is the relative time class for all maps and space time datasets

start_time and end_time must be of type integer

Usage:

>>> init()
>>> A = RelativeTemporalExtent(table="raster_relative_time",
... ident="soil@PERMANENT", start_time=0, end_time=1, unit="years")
>>> A.id
'soil@PERMANENT'
>>> A.start_time
0
>>> A.end_time
1
>>> A.unit
'years'
>>> A.print_info()
 +-------------------- Relative time -----------------------------------------+
 | Start time:................. 0
 | End time:................... 1
 | Relative time unit:......... years
>>> A.print_shell_info()
start_time=0
end_time=1
unit=years
get_unit()[source]

Get the unit of the relative time :return: None if not found

print_info()[source]

Print information about this class in human readable style

print_shell_info()[source]

Print information about this class in shell style

set_unit(unit)[source]

Set the unit of the relative time. Valid units are:

  • years
  • months
  • days
  • hours
  • minutes
  • seconds
temporal_relation(map)[source]

Returns the temporal relation between temporal objects Temporal relationships are implemented after [Allen and Ferguson 1994 Actions and Events in Interval Temporal Logic]

unit

Get the unit of the relative time :return: None if not found

class temporal.temporal_extent.STDSAbsoluteTime(table=None, ident=None, start_time=None, end_time=None, granularity=None, map_time=None)[source]

Bases: temporal.temporal_extent.AbsoluteTemporalExtent

This class implements the absolute time extent for space time dataset

In addition to the existing functionality the granularity and the map_time are added.

Usage:

>>> init()
>>> A = STDSAbsoluteTime(table="strds_absolute_time",
... ident="strds@PERMANENT", start_time=datetime(2001, 01, 01),
... end_time=datetime(2005,01,01), granularity="1 days",
... map_time="interval")
>>> A.id
'strds@PERMANENT'
>>> A.start_time
datetime.datetime(2001, 1, 1, 0, 0)
>>> A.end_time
datetime.datetime(2005, 1, 1, 0, 0)
>>> A.granularity
'1 days'
>>> A.map_time
'interval'
>>> A.print_info()
 +-------------------- Absolute time -----------------------------------------+
 | Start time:................. 2001-01-01 00:00:00
 | End time:................... 2005-01-01 00:00:00
 | Granularity:................ 1 days
 | Temporal type of maps:...... interval
>>> A.print_shell_info()
start_time=2001-01-01 00:00:00
end_time=2005-01-01 00:00:00
granularity=1 days
map_time=interval
get_granularity()[source]

Get the granularity of the space time dataset :return: None if not found

get_map_time()[source]

Get the type of the map time

Registered maps may have different types of time:

  • Single point of time “point”
  • Time intervals “interval”
  • Single point and interval time “mixed”

This variable will be set automatically when maps are registered.

granularity

Get the granularity of the space time dataset :return: None if not found

map_time

Get the type of the map time

Registered maps may have different types of time:

  • Single point of time “point”
  • Time intervals “interval”
  • Single point and interval time “mixed”

This variable will be set automatically when maps are registered.

print_info()[source]

Print information about this class in human readable style

print_shell_info()[source]

Print information about this class in shell style

set_granularity(granularity)[source]

Set the granularity of the space time dataset

set_map_time(map_time)[source]

Set the type of the map time

Registered maps may have different types of time:

  • Single point of time “point”
  • Time intervals “interval”
  • Single point and interval time “mixed”

This variable will be set automatically when maps are registered.

class temporal.temporal_extent.STDSRelativeTime(table=None, ident=None, start_time=None, end_time=None, unit=None, granularity=None, map_time=None)[source]

Bases: temporal.temporal_extent.RelativeTemporalExtent

This is the relative time class for all maps and space time datasets

start_time and end_time must be of type integer

Usage:

>>> init()
>>> A = STDSRelativeTime(table="strds_relative_time",
... ident="strds@PERMANENT", start_time=0, end_time=1, unit="years",
... granularity=5, map_time="interval")
>>> A.id
'strds@PERMANENT'
>>> A.start_time
0
>>> A.end_time
1
>>> A.unit
'years'
>>> A.granularity
5
>>> A.map_time
'interval'
>>> A.print_info()
 +-------------------- Relative time -----------------------------------------+
 | Start time:................. 0
 | End time:................... 1
 | Relative time unit:......... years
 | Granularity:................ 5
 | Temporal type of maps:...... interval
>>> A.print_shell_info()
start_time=0
end_time=1
unit=years
granularity=5
map_time=interval
get_granularity()[source]

Get the granularity of the space time dataset :return: None if not found

get_map_time()[source]

Get the type of the map time

Registered maps may have different types of time:

  • Single point of time “point”
  • Time intervals “interval”
  • Single point and interval time “mixed”

This variable will be set automatically when maps are registered.

granularity

Get the granularity of the space time dataset :return: None if not found

map_time

Get the type of the map time

Registered maps may have different types of time:

  • Single point of time “point”
  • Time intervals “interval”
  • Single point and interval time “mixed”

This variable will be set automatically when maps are registered.

print_info()[source]

Print information about this class in human readable style

print_shell_info()[source]

Print information about this class in shell style

set_granularity(granularity)[source]

Set the granularity of the space time dataset

set_map_time(map_time)[source]

Set the type of the map time

Registered maps may have different types of time:

  • Single point of time “point”
  • Time intervals “interval”
  • Single point and interval time “mixed”

This variable will be set automatically when maps are registered.

class temporal.temporal_extent.STR3DSAbsoluteTime(ident=None, start_time=None, end_time=None, granularity=None)[source]

Bases: temporal.temporal_extent.STDSAbsoluteTime

class temporal.temporal_extent.STR3DSRelativeTime(ident=None, start_time=None, end_time=None, unit=None, granularity=None, map_time=None)[source]

Bases: temporal.temporal_extent.STDSRelativeTime

class temporal.temporal_extent.STRDSAbsoluteTime(ident=None, start_time=None, end_time=None, granularity=None)[source]

Bases: temporal.temporal_extent.STDSAbsoluteTime

class temporal.temporal_extent.STRDSRelativeTime(ident=None, start_time=None, end_time=None, unit=None, granularity=None, map_time=None)[source]

Bases: temporal.temporal_extent.STDSRelativeTime

class temporal.temporal_extent.STVDSAbsoluteTime(ident=None, start_time=None, end_time=None, granularity=None)[source]

Bases: temporal.temporal_extent.STDSAbsoluteTime

class temporal.temporal_extent.STVDSRelativeTime(ident=None, start_time=None, end_time=None, unit=None, granularity=None, map_time=None)[source]

Bases: temporal.temporal_extent.STDSRelativeTime

class temporal.temporal_extent.TemporalExtent(table=None, ident=None, start_time=None, end_time=None)[source]

Bases: temporal.base.SQLDatabaseInterface

This is the abstract time base class for relative and absolute time objects.

It abstract class implements the interface to absolute and relative time. Absolute time is represented by datetime time stamps, relative time is represented by a unit an integer value.

This class implements temporal topology relationships computation after [Allen and Ferguson 1994 Actions and Events in Interval Temporal Logic].

Usage:

>>> init()
>>> A = TemporalExtent(table="raster_absolute_time",
... ident="soil@PERMANENT", start_time=datetime(2001, 01, 01),
... end_time=datetime(2005,01,01) )
>>> A.id
'soil@PERMANENT'
>>> A.start_time
datetime.datetime(2001, 1, 1, 0, 0)
>>> A.end_time
datetime.datetime(2005, 1, 1, 0, 0)
>>> A.print_info()
 | Start time:................. 2001-01-01 00:00:00
 | End time:................... 2005-01-01 00:00:00
>>> A.print_shell_info()
start_time=2001-01-01 00:00:00
end_time=2005-01-01 00:00:00
>>> # relative time
>>> A = TemporalExtent(table="raster_absolute_time",
... ident="soil@PERMANENT", start_time=0, end_time=1 )
>>> A.id
'soil@PERMANENT'
>>> A.start_time
0
>>> A.end_time
1
>>> A.print_info()
 | Start time:................. 0
 | End time:................... 1
>>> A.print_shell_info()
start_time=0
end_time=1
adjacent(extent)[source]

Return True if this temporal extent (A) is a meeting neighbor the provided temporal extent (B)

A            |---------|
B  |---------|
A  |---------|
B            |---------|
Parameters:extent – The temporal extent object that is a meeting neighbor of this extent

Usage:

>>> A = TemporalExtent(start_time=5, end_time=7 )
>>> B = TemporalExtent(start_time=7, end_time=9 )
>>> A.adjacent(B)
True
>>> B.adjacent(A)
True
>>> A = TemporalExtent(start_time=5, end_time=7 )
>>> B = TemporalExtent(start_time=3, end_time=5 )
>>> A.adjacent(B)
True
>>> B.adjacent(A)
True
after(extent)[source]

Return True if this temporal extent (A) is located after the provided temporal extent (B)

A             |---------|
B  |---------|
Parameters:extent – The temporal extent object that is located before this extent

Usage:

>>> A = TemporalExtent(start_time=8, end_time=9 )
>>> B = TemporalExtent(start_time=6, end_time=7 )
>>> A.after(B)
True
>>> B.after(A)
False
before(extent)[source]

Return True if this temporal extent (A) is located before the provided temporal extent (B)

A  |---------|
B             |---------|
Parameters:extent – The temporal extent object that is located after this extent

Usage:

>>> A = TemporalExtent(start_time=6, end_time=7 )
>>> B = TemporalExtent(start_time=8, end_time=9 )
>>> A.before(B)
True
>>> B.before(A)
False
contains(extent)[source]

Return True if this temporal extent (A) contains the provided temporal extent (B)

A  |---------|
B   |-------|
Parameters:extent – The temporal extent object that is located during this extent

Usage:

>>> A = TemporalExtent(start_time=4, end_time=9 )
>>> B = TemporalExtent(start_time=5, end_time=8 )
>>> A.contains(B)
True
>>> B.contains(A)
False
disjoint_union(extent)[source]

Creates a disjoint union with this temporal extent and the provided one. Return a new temporal extent with the new start and end time.

Parameters:extent – The temporal extent to create a union with
Returns:The new temporal extent with start and end time

Usage:

>>> A = TemporalExtent(start_time=5, end_time=6 )
>>> inter = A.intersect(A)
>>> inter.print_info()
 | Start time:................. 5
 | End time:................... 6

>>> A = TemporalExtent(start_time=5, end_time=6 )
>>> B = TemporalExtent(start_time=5, end_time=7 )
>>> inter = A.disjoint_union(B)
>>> inter.print_info()
 | Start time:................. 5
 | End time:................... 7
>>> inter = B.disjoint_union(A)
>>> inter.print_info()
 | Start time:................. 5
 | End time:................... 7

>>> A = TemporalExtent(start_time=3, end_time=6 )
>>> B = TemporalExtent(start_time=5, end_time=7 )
>>> inter = A.disjoint_union(B)
>>> inter.print_info()
 | Start time:................. 3
 | End time:................... 7
>>> inter = B.disjoint_union(A)
>>> inter.print_info()
 | Start time:................. 3
 | End time:................... 7

>>> A = TemporalExtent(start_time=3, end_time=8 )
>>> B = TemporalExtent(start_time=5, end_time=6 )
>>> inter = A.disjoint_union(B)
>>> inter.print_info()
 | Start time:................. 3
 | End time:................... 8
>>> inter = B.disjoint_union(A)
>>> inter.print_info()
 | Start time:................. 3
 | End time:................... 8

>>> A = TemporalExtent(start_time=5, end_time=8 )
>>> B = TemporalExtent(start_time=3, end_time=6 )
>>> inter = A.disjoint_union(B)
>>> inter.print_info()
 | Start time:................. 3
 | End time:................... 8
>>> inter = B.disjoint_union(A)
>>> inter.print_info()
 | Start time:................. 3
 | End time:................... 8

>>> A = TemporalExtent(start_time=5, end_time=None )
>>> B = TemporalExtent(start_time=3, end_time=6 )
>>> inter = A.disjoint_union(B)
>>> inter.print_info()
 | Start time:................. 3
 | End time:................... 6
>>> inter = B.disjoint_union(A)
>>> inter.print_info()
 | Start time:................. 3
 | End time:................... 6

>>> A = TemporalExtent(start_time=5, end_time=8 )
>>> B = TemporalExtent(start_time=3, end_time=4 )
>>> inter = A.disjoint_union(B)
>>> inter.print_info()
 | Start time:................. 3
 | End time:................... 8
>>> inter = B.disjoint_union(A)
>>> inter.print_info()
 | Start time:................. 3
 | End time:................... 8
>>> A = TemporalExtent(start_time=5, end_time=8 )
>>> B = TemporalExtent(start_time=3, end_time=None )
>>> inter = A.disjoint_union(B)
>>> inter.print_info()
 | Start time:................. 3
 | End time:................... 8
>>> inter = B.disjoint_union(A)
>>> inter.print_info()
 | Start time:................. 3
 | End time:................... 8
>>> A = TemporalExtent(start_time=5, end_time=None )
>>> B = TemporalExtent(start_time=3, end_time=8 )
>>> inter = A.disjoint_union(B)
>>> inter.print_info()
 | Start time:................. 3
 | End time:................... 8
>>> inter = B.disjoint_union(A)
>>> inter.print_info()
 | Start time:................. 3
 | End time:................... 8
>>> A = TemporalExtent(start_time=5, end_time=None )
>>> B = TemporalExtent(start_time=3, end_time=None )
>>> inter = A.disjoint_union(B)
>>> inter.print_info()
 | Start time:................. 3
 | End time:................... 5
>>> inter = B.disjoint_union(A)
>>> inter.print_info()
 | Start time:................. 3
 | End time:................... 5

>>> A = RelativeTemporalExtent(start_time=5, end_time=None, unit="years" )
>>> B = RelativeTemporalExtent(start_time=3, end_time=None, unit="years" )
>>> inter = A.disjoint_union(B)
>>> inter.print_info()
 +-------------------- Relative time -----------------------------------------+
 | Start time:................. 3
 | End time:................... 5
 | Relative time unit:......... years

>>> inter = B.disjoint_union(A)
>>> inter.print_info()
 +-------------------- Relative time -----------------------------------------+
 | Start time:................. 3
 | End time:................... 5
 | Relative time unit:......... years


>>> from datetime import datetime as dt
>>> A = AbsoluteTemporalExtent(start_time=dt(2001,1,10), end_time=dt(2003,1,1))
>>> B = AbsoluteTemporalExtent(start_time=dt(2005,1,10), end_time=dt(2008,1,1))
>>> inter = A.disjoint_union(B)
>>> inter.print_info()
 +-------------------- Absolute time -----------------------------------------+
 | Start time:................. 2001-01-10 00:00:00
 | End time:................... 2008-01-01 00:00:00

>>> inter = B.disjoint_union(A)
>>> inter.print_info()
 +-------------------- Absolute time -----------------------------------------+
 | Start time:................. 2001-01-10 00:00:00
 | End time:................... 2008-01-01 00:00:00
during(extent)[source]

Return True if this temporal extent (A) is located during the provided temporal extent (B)

A   |-------|
B  |---------|
Parameters:extent – The temporal extent object that contains this extent

Usage:

>>> A = TemporalExtent(start_time=5, end_time=7 )
>>> B = TemporalExtent(start_time=4, end_time=9 )
>>> A.during(B)
True
>>> B.during(A)
False
end_time

Get the valid end time of the extent :return: None if not found

equal(extent)[source]

Return True if this temporal extent (A) is equal to the provided temporal extent (B)

A  |---------|
B  |---------|
Parameters:extent – The temporal extent object that is equal during this extent

Usage:

>>> A = TemporalExtent(start_time=5, end_time=6 )
>>> B = TemporalExtent(start_time=5, end_time=6 )
>>> A.equal(B)
True
>>> B.equal(A)
True
finished(extent)[source]

Return True if this temporal extent (A) starts before the start of the provided temporal extent (B) and finishes with it

A  |---------|
B      |-----|
Parameters:extent – The temporal extent object with which this extent finishes

Usage:

>>> A = TemporalExtent(start_time=5, end_time=7 )
>>> B = TemporalExtent(start_time=6, end_time=7 )
>>> A.finished(B)
True
>>> B.finished(A)
False
finishes(extent)[source]

Return True if this temporal extent (A) starts after the start of the provided temporal extent (B) and finishes with it

A      |-----|
B  |---------|
Parameters:extent – The temporal extent object with which this extent finishes

Usage:

>>> A = TemporalExtent(start_time=6, end_time=7 )
>>> B = TemporalExtent(start_time=5, end_time=7 )
>>> A.finishes(B)
True
>>> B.finishes(A)
False
follows(extent)[source]

Return True if this temporal extent (A) follows the provided temporal extent (B)

A            |---------|
B  |---------|
Parameters:extent – The temporal extent object that is the predecessor of this extent

Usage:

>>> A = TemporalExtent(start_time=5, end_time=7 )
>>> B = TemporalExtent(start_time=3, end_time=5 )
>>> A.follows(B)
True
>>> B.follows(A)
False
get_end_time()[source]

Get the valid end time of the extent :return: None if not found

get_id()[source]

Convenient method to get the unique identifier (primary key) :return: None if not found

get_start_time()[source]

Get the valid start time of the extent :return: None if not found

id

Convenient method to get the unique identifier (primary key) :return: None if not found

intersect(extent)[source]

Intersect this temporal extent with the provided temporal extent and return a new temporal extent with the new start and end time

Parameters:extent – The temporal extent to intersect with
Returns:The new temporal extent with start and end time, or None in case of no intersection

Usage:

>>> A = TemporalExtent(start_time=5, end_time=6 )
>>> inter = A.intersect(A)
>>> inter.print_info()
 | Start time:................. 5
 | End time:................... 6

>>> A = TemporalExtent(start_time=5, end_time=6 )
>>> B = TemporalExtent(start_time=5, end_time=7 )
>>> inter = A.intersect(B)
>>> inter.print_info()
 | Start time:................. 5
 | End time:................... 6
>>> inter = B.intersect(A)
>>> inter.print_info()
 | Start time:................. 5
 | End time:................... 6

>>> A = TemporalExtent(start_time=3, end_time=6 )
>>> B = TemporalExtent(start_time=5, end_time=7 )
>>> inter = A.intersect(B)
>>> inter.print_info()
 | Start time:................. 5
 | End time:................... 6
>>> inter = B.intersect(A)
>>> inter.print_info()
 | Start time:................. 5
 | End time:................... 6

>>> A = TemporalExtent(start_time=3, end_time=8 )
>>> B = TemporalExtent(start_time=5, end_time=6 )
>>> inter = A.intersect(B)
>>> inter.print_info()
 | Start time:................. 5
 | End time:................... 6
>>> inter = B.intersect(A)
>>> inter.print_info()
 | Start time:................. 5
 | End time:................... 6

>>> A = TemporalExtent(start_time=5, end_time=8 )
>>> B = TemporalExtent(start_time=3, end_time=6 )
>>> inter = A.intersect(B)
>>> inter.print_info()
 | Start time:................. 5
 | End time:................... 6
>>> inter = B.intersect(A)
>>> inter.print_info()
 | Start time:................. 5
 | End time:................... 6

>>> A = TemporalExtent(start_time=5, end_time=None )
>>> B = TemporalExtent(start_time=3, end_time=6 )
>>> inter = A.intersect(B)
>>> inter.print_info()
 | Start time:................. 5
 | End time:................... None
>>> inter = B.intersect(A)
>>> inter.print_info()
 | Start time:................. 5
 | End time:................... None

>>> A = TemporalExtent(start_time=5, end_time=8 )
>>> B = TemporalExtent(start_time=3, end_time=4 )
>>> inter = A.intersect(B)
>>> print(inter)
None

>>> A = TemporalExtent(start_time=5, end_time=8 )
>>> B = TemporalExtent(start_time=3, end_time=None )
>>> inter = A.intersect(B)
>>> print(inter)
None
overlapped(extent)[source]

Return True if this temporal extent (A) overlapps the provided temporal extent (B)

A    |---------|
B  |---------|
Parameters:extent – The temporal extent object that is overlapped this extent

Usage:

>>> A = TemporalExtent(start_time=6, end_time=8 )
>>> B = TemporalExtent(start_time=5, end_time=7 )
>>> A.overlapped(B)
True
>>> B.overlapped(A)
False

>>> A = TemporalExtent(start_time=6, end_time=8 )
>>> B = TemporalExtent(start_time=5, end_time=6 )
>>> A.overlapped(B)
False
>>> B.overlapped(A)
False
overlaps(extent)[source]

Return True if this temporal extent (A) overlapped the provided temporal extent (B)

A  |---------|
B    |---------|
Parameters:extent – The temporal extent object that is overlaps this extent

Usage:

>>> A = TemporalExtent(start_time=5, end_time=7 )
>>> B = TemporalExtent(start_time=6, end_time=8 )
>>> A.overlaps(B)
True
>>> B.overlaps(A)
False

>>> A = TemporalExtent(start_time=5, end_time=6 )
>>> B = TemporalExtent(start_time=6, end_time=8 )
>>> A.overlaps(B)
False
>>> B.overlaps(A)
False
precedes(extent)[source]

Return True if this temporal extent (A) precedes the provided temporal extent (B)

A  |---------|
B            |---------|
Parameters:extent – The temporal extent object that is the successor of this extent

Usage:

>>> A = TemporalExtent(start_time=5, end_time=7 )
>>> B = TemporalExtent(start_time=7, end_time=9 )
>>> A.precedes(B)
True
>>> B.precedes(A)
False
print_info()[source]

Print information about this class in human readable style

print_shell_info()[source]

Print information about this class in shell style

set_end_time(end_time)[source]

Set the valid end time of the extent

set_id(ident)[source]

Convenient method to set the unique identifier (primary key)

set_start_time(start_time)[source]

Set the valid start time of the extent

start_time

Get the valid start time of the extent :return: None if not found

started(extent)[source]

Return True if this temporal extent (A) started at the start of the provided temporal extent (B) and finishes after it

A  |---------|
B  |-----|
Parameters:extent – The temporal extent object with which this extent started

Usage:

>>> A = TemporalExtent(start_time=5, end_time=7 )
>>> B = TemporalExtent(start_time=5, end_time=6 )
>>> A.started(B)
True
>>> B.started(A)
False
starts(extent)[source]

Return True if this temporal extent (A) starts at the start of the provided temporal extent (B) and finishes within it

A  |-----|
B  |---------|
Parameters:extent – The temporal extent object with which this extent starts

Usage:

>>> A = TemporalExtent(start_time=5, end_time=6 )
>>> B = TemporalExtent(start_time=5, end_time=7 )
>>> A.starts(B)
True
>>> B.starts(A)
False
temporal_relation(extent)[source]

Returns the temporal relation between temporal objects Temporal relationships are implemented after [Allen and Ferguson 1994 Actions and Events in Interval Temporal Logic]

The following temporal relationships are supported:

  • equal
  • during
  • contains
  • overlaps
  • overlapped
  • after
  • before
  • starts
  • finishes
  • started
  • finished
  • follows
  • precedes
Parameters:extent – The temporal extent
Returns:The name of the temporal relation or None if no relation found
union(extent)[source]

Creates a union with this temporal extent and the provided one. Return a new temporal extent with the new start and end time.

Parameters:extent – The temporal extent to create a union with
Returns:The new temporal extent with start and end time, or None in case the temporal extents are unrelated (before or after)
>>> A = TemporalExtent(start_time=5, end_time=8 )
>>> B = TemporalExtent(start_time=3, end_time=4 )
>>> inter = A.intersect(B)
>>> print(inter)
None

>>> A = TemporalExtent(start_time=5, end_time=8 )
>>> B = TemporalExtent(start_time=3, end_time=None )
>>> inter = A.intersect(B)
>>> print(inter)
None
class temporal.temporal_extent.VectorAbsoluteTime(ident=None, start_time=None, end_time=None)[source]

Bases: temporal.temporal_extent.AbsoluteTemporalExtent

class temporal.temporal_extent.VectorRelativeTime(ident=None, start_time=None, end_time=None, unit=None)[source]

Bases: temporal.temporal_extent.RelativeTemporalExtent

temporal.temporal_granularity module

Functions to compute the temporal granularity of a map list

Usage:

import grass.temporal as tgis

tgis.compute_relative_time_granularity(maps)

(C) 2012-2013 by the GRASS Development Team This program is free software under the GNU General Public License (>=v2). Read the file COPYING that comes with GRASS for details.

authors:Soeren Gebbert
temporal.temporal_granularity.check_granularity_string(granularity, temporal_type)[source]

Check if the granularity string is valid

Parameters:
  • granularity – The granularity string
  • temporal_type – The temporal type of the granularity relative or absolute
Returns:

True if valid, False if invalid

>>> check_granularity_string("1 year", "absolute")
True
>>> check_granularity_string("1 month", "absolute")
True
>>> check_granularity_string("1 day", "absolute")
True
>>> check_granularity_string("1 minute", "absolute")
True
>>> check_granularity_string("1 hour", "absolute")
True
>>> check_granularity_string("1 second", "absolute")
True
>>> check_granularity_string("5 months", "absolute")
True
>>> check_granularity_string("5 days", "absolute")
True
>>> check_granularity_string("5 minutes", "absolute")
True
>>> check_granularity_string("5 years", "absolute")
True
>>> check_granularity_string("5 hours", "absolute")
True
>>> check_granularity_string("2 seconds", "absolute")
True
>>> check_granularity_string("1 secondo", "absolute")
False
>>> check_granularity_string("bla second", "absolute")
False
>>> check_granularity_string("bla", "absolute")
False
>>> check_granularity_string(1, "relative")
True
>>> check_granularity_string("bla", "relative")
False
temporal.temporal_granularity.compute_absolute_time_granularity(maps)[source]

Compute the absolute time granularity

Attention: The computation of the granularity is only correct in case of not overlapping intervals. Hence a correct temporal topology is required for computation.

The computed granularity is returned as number of seconds or minutes or hours or days or months or years.

Parameters:maps – a ordered by start_time list of map objects
Returns:The temporal topology as string “integer unit”
>>> import grass.temporal as tgis
>>> import datetime
>>> dt = datetime.datetime
>>> tgis.init()
>>> maps = []
>>> count = 0
>>> timelist = ((dt(2000,01,01),None), (dt(2000,02,01),None))
>>> for t in timelist:
...   map = tgis.RasterDataset("a%i@P"%count)
...   check = map.set_absolute_time(t[0],t[1])
...   if check:
...     maps.append(map)
...   count += 1
>>> tgis.compute_absolute_time_granularity(maps)
'1 month'

>>> maps = []
>>> count = 0
>>> timelist = ((dt(2000,01,01),None), (dt(2000,01,02),None), (dt(2000,01,03),None))
>>> for t in timelist:
...   map = tgis.RasterDataset("a%i@P"%count)
...   check = map.set_absolute_time(t[0],t[1])
...   if check:
...     maps.append(map)
...   count += 1
>>> tgis.compute_absolute_time_granularity(maps)
'1 day'

>>> maps = []
>>> count = 0
>>> timelist = ((dt(2000,01,01),None), (dt(2000,01,02),None), (dt(2000,05,04,0,5,30),None))
>>> for t in timelist:
...   map = tgis.RasterDataset("a%i@P"%count)
...   check = map.set_absolute_time(t[0],t[1])
...   if check:
...     maps.append(map)
...   count += 1
>>> tgis.compute_absolute_time_granularity(maps)
'30 seconds'

>>> maps = []
>>> count = 0
>>> timelist = ((dt(2000,01,01),dt(2000,05,02)), (dt(2000,05,04,2),None))
>>> for t in timelist:
...   map = tgis.RasterDataset("a%i@P"%count)
...   check = map.set_absolute_time(t[0],t[1])
...   if check:
...     maps.append(map)
...   count += 1
>>> tgis.compute_absolute_time_granularity(maps)
'2 hours'

>>> maps = []
>>> count = 0
>>> timelist = ((dt(2000,01,01),dt(2000,02,01)), (dt(2005,05,04,12),dt(2007,05,20,6)))
>>> for t in timelist:
...   map = tgis.RasterDataset("a%i@P"%count)
...   check = map.set_absolute_time(t[0],t[1])
...   if check:
...     maps.append(map)
...   count += 1
>>> tgis.compute_absolute_time_granularity(maps)
'6 hours'
temporal.temporal_granularity.compute_common_absolute_time_granularity(gran_list, start_date_list=None)[source]

Compute the greatest common granule from a list of absolute time granules, considering the start times of the related space time datasets in the common granularity computation.

The list of start dates is optional. If you use this function to compute a common granularity between space time datasets, then you should provide their start times to avoid wrong synchronization.

Parameters:
  • gran_list – List of granularities
  • start_date_list – List of the start times of related space time datasets
Returns:

The common granularity

>>> from datetime import datetime
>>> import grass.temporal as tgis
>>> tgis.init()
>>> grans = ["20 second", "10 minutes", "2 hours"]
>>> dates = [datetime(2001,1,1,0,0,0),
...          datetime(2001,1,1,0,0,0),
...          datetime(2001,1,1,0,0,0),]
>>> tgis.compute_common_absolute_time_granularity(grans, dates)
'20 seconds'

>>> grans = ["20 second", "10 minutes", "2 hours"]
>>> dates = [datetime(2001,1,1,0,0,20),
...          datetime(2001,1,1,0,0,0),
...          datetime(2001,1,1,0,0,0),]
>>> tgis.compute_common_absolute_time_granularity(grans, dates)
'1 second'

>>> grans = ["7200 second", "240 minutes", "1 year"]
>>> dates = [datetime(2001,1,1,0,0,10),
...          datetime(2001,1,1,0,0,0),
...          datetime(2001,1,1,0,0,0),]
>>> tgis.compute_common_absolute_time_granularity(grans, dates)
'1 second'

>>> grans = ["7200 second", "89 minutes", "1 year"]
>>> dates = [datetime(2001,1,1,0,0,0),
...          datetime(2001,1,1,0,0,0),
...          datetime(2001,1,1,0,0,0),]
>>> tgis.compute_common_absolute_time_granularity(grans, dates)
'60 seconds'

>>> grans = ["120 minutes", "2 hours"]
>>> dates = [datetime(2001,1,1,0,0,0),
...          datetime(2001,1,1,0,0,0),]
>>> tgis.compute_common_absolute_time_granularity(grans, dates)
'60 minutes'

>>> grans = ["120 minutes", "2 hours"]
>>> dates = [datetime(2001,1,1,0,30,0),
...          datetime(2001,1,1,0,0,0),]
>>> tgis.compute_common_absolute_time_granularity(grans, dates)
'1 minute'

>>> grans = ["360 minutes", "3 hours"]
>>> dates = [datetime(2001,1,1,0,0,0),
...          datetime(2001,1,1,0,0,0),]
>>> tgis.compute_common_absolute_time_granularity(grans, dates)
'60 minutes'

>>> grans = ["2 hours", "4 hours", "8 hours"]
>>> dates = [datetime(2001,1,1,0,0,0),
...          datetime(2001,1,1,0,0,0),
...          datetime(2001,1,1,0,0,0),]
>>> tgis.compute_common_absolute_time_granularity(grans, dates)
'2 hours'

>>> grans = ["2 hours", "4 hours", "8 hours"]
>>> dates = [datetime(2001,1,1,2,0,0),
...          datetime(2001,1,1,4,0,0),
...          datetime(2001,1,1,8,0,0),]
>>> tgis.compute_common_absolute_time_granularity(grans, dates)
'1 hour'

>>> grans = ["8 hours", "2 days"]
>>> dates = [datetime(2001,1,1,0,0,0),
...          datetime(2001,1,1,0,0,0),]
>>> tgis.compute_common_absolute_time_granularity(grans, dates)
'8 hours'

>>> grans = ["8 hours", "2 days"]
>>> dates = [datetime(2001,1,1,10,0,0),
...          datetime(2001,1,1,0,0,0),]
>>> tgis.compute_common_absolute_time_granularity(grans, dates)
'1 hour'

>>> grans = ["120 months", "360 months", "4 years"]
>>> dates = [datetime(2001,1,1,0,0,0),
...          datetime(2001,1,1,0,0,0),
...          datetime(2001,1,1,0,0,0),]
>>> tgis.compute_common_absolute_time_granularity(grans, dates)
'12 months'

>>> grans = ["30 days", "10 days", "5 days"]
>>> dates = [datetime(2001,2,1,0,0,0),
...          datetime(2001,1,1,0,0,0),
...          datetime(2001,1,1,0,0,0),]
>>> tgis.compute_common_absolute_time_granularity(grans, dates)
'5 days'

>>> grans = ["30 days", "10 days", "5 days"]
>>> dates = [datetime(2001,2,2,0,0,0),
...          datetime(2001,1,1,0,0,0),
...          datetime(2001,1,1,0,0,0),]
>>> tgis.compute_common_absolute_time_granularity(grans, dates)
'1 day'

>>> grans = ["2 days", "360 months", "4 years"]
>>> dates = [datetime(2001,1,1,0,0,0),
...          datetime(2001,1,1,0,0,0),
...          datetime(2001,1,1,0,0,0),]
>>> tgis.compute_common_absolute_time_granularity(grans, dates)
'2 days'

>>> grans = ["2 days", "360 months", "4 years"]
>>> dates = [datetime(2001,1,2,0,0,0),
...          datetime(2001,1,1,0,0,0),
...          datetime(2001,1,1,0,0,0),]
>>> tgis.compute_common_absolute_time_granularity(grans, dates)
'1 day'

>>> grans = ["120 months", "360 months", "4 years"]
>>> dates = [datetime(2001,2,1,0,0,0),
...          datetime(2001,1,1,0,0,0),
...          datetime(2001,1,1,0,0,0),]
>>> tgis.compute_common_absolute_time_granularity(grans, dates)
'1 month'

>>> grans = ["120 months", "361 months", "4 years"]
>>> dates = [datetime(2001,1,1,0,0,0),
...          datetime(2001,1,1,0,0,0),
...          datetime(2001,1,1,0,0,0),]
>>> tgis.compute_common_absolute_time_granularity(grans, dates)
'1 month'

>>> grans = ["120 months", "360 months", "4 years"]
>>> dates = [datetime(2001,1,1,0,0,0),
...          datetime(2001,1,1,0,0,0),
...          datetime(2001,1,1,0,0,0),]
>>> tgis.compute_common_absolute_time_granularity(grans, dates)
'12 months'
temporal.temporal_granularity.compute_common_absolute_time_granularity_simple(gran_list)[source]

Compute the greatest common granule from a list of absolute time granules

Parameters:gran_list – List of granularities
Returns:The common granularity
>>> import grass.temporal as tgis
>>> tgis.init()
>>> grans = ["1 second", "2 seconds", "30 seconds"]
>>> tgis.compute_common_absolute_time_granularity(grans)
'1 second'

>>> grans = ["3 second", "6 seconds", "30 seconds"]
>>> tgis.compute_common_absolute_time_granularity(grans)
'3 seconds'

>>> grans = ["12 second", "18 seconds", "30 seconds", "10 minutes"]
>>> tgis.compute_common_absolute_time_granularity(grans)
'6 seconds'

>>> grans = ["20 second", "10 minutes", "2 hours"]
>>> tgis.compute_common_absolute_time_granularity(grans)
'20 seconds'

>>> grans = ["7200 second", "240 minutes", "1 year"]
>>> tgis.compute_common_absolute_time_granularity(grans)
'7200 seconds'

>>> grans = ["7200 second", "89 minutes", "1 year"]
>>> tgis.compute_common_absolute_time_granularity(grans)
'60 seconds'

>>> grans = ["10 minutes", "20 minutes", "30 minutes", "40 minutes", "2 hours"]
>>> tgis.compute_common_absolute_time_granularity(grans)
'10 minutes'

>>> grans = ["120 minutes", "2 hours"]
>>> tgis.compute_common_absolute_time_granularity(grans)
'120 minutes'

>>> grans = ["360 minutes", "3 hours"]
>>> tgis.compute_common_absolute_time_granularity(grans)
'180 minutes'

>>> grans = ["2 hours", "4 hours", "8 hours"]
>>> tgis.compute_common_absolute_time_granularity(grans)
'2 hours'

>>> grans = ["8 hours", "2 days"]
>>> tgis.compute_common_absolute_time_granularity(grans)
'8 hours'

>>> grans = ["48 hours", "1 month"]
>>> tgis.compute_common_absolute_time_granularity(grans)
'24 hours'

>>> grans = ["48 hours", "1 year"]
>>> tgis.compute_common_absolute_time_granularity(grans)
'24 hours'

>>> grans = ["2 months", "4 months", "1 year"]
>>> tgis.compute_common_absolute_time_granularity(grans)
'2 months'

>>> grans = ["120 months", "360 months", "4 years"]
>>> tgis.compute_common_absolute_time_granularity(grans)
'24 months'

>>> grans = ["120 months", "361 months", "4 years"]
>>> tgis.compute_common_absolute_time_granularity(grans)
'1 month'

>>> grans = ["2 years", "3 years", "4 years"]
>>> tgis.compute_common_absolute_time_granularity(grans)
'1 year'
temporal.temporal_granularity.compute_common_relative_time_granularity(gran_list)[source]

Compute the greatest common granule from a list of relative time granules

>>> import grass.temporal as tgis
>>> tgis.init()
>>> grans = [1,2,30]
>>> tgis.compute_common_relative_time_granularity(grans)
1

>>> import grass.temporal as tgis
>>> tgis.init()
>>> grans = [10,20,30]
>>> tgis.compute_common_relative_time_granularity(grans)
10
temporal.temporal_granularity.compute_relative_time_granularity(maps)[source]

Compute the relative time granularity

Attention: The computation of the granularity is only correct in case of not overlapping intervals. Hence a correct temporal topology is required for computation.

Parameters:maps – a ordered by start_time list of map objects
Returns:An integer
>>> import grass.temporal as tgis
>>> tgis.init()
>>> maps = []
>>> for i in range(5):
...   map = tgis.RasterDataset("a%i@P"%i)
...   check = map.set_relative_time(i,i + 1,"seconds")
...   if check:
...     maps.append(map)
>>> tgis.compute_relative_time_granularity(maps)
1

>>> maps = []
>>> count = 0
>>> timelist = ((0,3), (3,6), (6,9))
>>> for t in timelist:
...   map = tgis.RasterDataset("a%i@P"%count)
...   check = map.set_relative_time(t[0],t[1],"years")
...   if check:
...     maps.append(map)
...   count += 1
>>> tgis.compute_relative_time_granularity(maps)
3

>>> maps = []
>>> count = 0
>>> timelist = ((0,3), (4,6), (8,11))
>>> for t in timelist:
...   map = tgis.RasterDataset("a%i@P"%count)
...   check = map.set_relative_time(t[0],t[1],"years")
...   if check:
...     maps.append(map)
...   count += 1
>>> tgis.compute_relative_time_granularity(maps)
1

>>> maps = []
>>> count = 0
>>> timelist = ((0,8), (2,6), (5,9))
>>> for t in timelist:
...   map = tgis.RasterDataset("a%i@P"%count)
...   check = map.set_relative_time(t[0],t[1],"months")
...   if check:
...     maps.append(map)
...   count += 1
>>> tgis.compute_relative_time_granularity(maps)
4

>>> maps = []
>>> count = 0
>>> timelist = ((0,8), (8,12), (12,18))
>>> for t in timelist:
...   map = tgis.RasterDataset("a%i@P"%count)
...   check = map.set_relative_time(t[0],t[1],"days")
...   if check:
...     maps.append(map)
...   count += 1
>>> tgis.compute_relative_time_granularity(maps)
2

>>> maps = []
>>> count = 0
>>> timelist = ((0,None), (8,None), (12,None), (24,None))
>>> for t in timelist:
...   map = tgis.RasterDataset("a%i@P"%count)
...   check = map.set_relative_time(t[0],t[1],"minutes")
...   if check:
...     maps.append(map)
...   count += 1
>>> tgis.compute_relative_time_granularity(maps)
4

>>> maps = []
>>> count = 0
>>> timelist = ((0,None), (8,14), (18,None), (24,None))
>>> for t in timelist:
...   map = tgis.RasterDataset("a%i@P"%count)
...   check = map.set_relative_time(t[0],t[1],"hours")
...   if check:
...     maps.append(map)
...   count += 1
>>> tgis.compute_relative_time_granularity(maps)
2

>>> maps = []
>>> count = 0
>>> timelist = ((0,21),)
>>> for t in timelist:
...   map = tgis.RasterDataset("a%i@P"%count)
...   check = map.set_relative_time(t[0],t[1],"hours")
...   if check:
...     maps.append(map)
...   count += 1
>>> tgis.compute_relative_time_granularity(maps)
21
temporal.temporal_granularity.gcd(a, b)[source]

The Euclidean Algorithm

temporal.temporal_granularity.gcd_list(list)[source]

Finds the GCD of numbers in a list.

Parameters:list – List of numbers you want to find the GCD of E.g. [8, 24, 12]
Returns:GCD of all numbers

temporal.temporal_operator module

@package grass.temporal

Temporal operator evaluation with PLY

(C) 2013 by the GRASS Development Team This program is free software under the GNU General Public License (>=v2). Read the file COPYING that comes with GRASS for details.

authors:Thomas Leppelt and Soeren Gebbert
>>> p = TemporalOperatorParser()
>>> expression =  "{equal| during}"
>>> p.parse(expression, optype = 'relation')
>>> print((p.relations, p.temporal, p.function))
(['equal', 'during'], None, None)
>>> p = TemporalOperatorParser()
>>> expression =  "{contains | starts}"
>>> p.parse(expression)
>>> print((p.relations, p.temporal, p.function))
(['contains', 'starts'], None, None)
>>> p = TemporalOperatorParser()
>>> expression =  "{&&, during}"
>>> p.parse(expression, optype = 'boolean')
>>> print((p.relations, p.temporal, p.function, p.aggregate))
(['during'], 'l', '&&', '&')
>>> p = TemporalOperatorParser()
>>> expression =  "{||, equal | during}"
>>> p.parse(expression, optype = 'boolean')
>>> print((p.relations, p.temporal, p.function, p.aggregate))
(['equal', 'during'], 'l', '||', '|')
>>> p = TemporalOperatorParser()
>>> expression =  "{||, equal | during, &}"
>>> p.parse(expression, optype = 'boolean')
>>> print((p.relations, p.temporal, p.function, p.aggregate))
(['equal', 'during'], 'l', '||', '&')
>>> p = TemporalOperatorParser()
>>> expression =  "{&&, during, |}"
>>> p.parse(expression, optype = 'boolean')
>>> print((p.relations, p.temporal, p.function, p.aggregate))
(['during'], 'l', '&&', '|')
>>> p = TemporalOperatorParser()
>>> expression =  "{&&, during, |, r}"
>>> p.parse(expression, optype = 'boolean')
>>> print((p.relations, p.temporal, p.function, p.aggregate))
(['during'], 'r', '&&', '|')
>>> p = TemporalOperatorParser()
>>> expression =  "{&&, during, u}"
>>> p.parse(expression, optype = 'boolean')
>>> print((p.relations, p.temporal, p.function, p.aggregate))
(['during'], 'u', '&&', '&')
>>> p = TemporalOperatorParser()
>>> expression =  "{:, during, r}"
>>> p.parse(expression, optype = 'select')
>>> print((p.relations, p.temporal, p.function))
(['during'], 'r', ':')
>>> p = TemporalOperatorParser()
>>> expression =  "{!:, equal | contains, d}"
>>> p.parse(expression, optype = 'select')
>>> print((p.relations, p.temporal, p.function))
(['equal', 'contains'], 'd', '!:')
>>> p = TemporalOperatorParser()
>>> expression =  "{#, during, r}"
>>> p.parse(expression, optype = 'hash')
>>> print((p.relations, p.temporal, p.function))
(['during'], 'r', '#')
>>> p = TemporalOperatorParser()
>>> expression =  "{#, equal | contains}"
>>> p.parse(expression, optype = 'hash')
>>> print((p.relations, p.temporal, p.function))
(['equal', 'contains'], 'l', '#')
>>> p = TemporalOperatorParser()
>>> expression =  "{+, during, r}"
>>> p.parse(expression, optype = 'raster')
>>> print((p.relations, p.temporal, p.function))
(['during'], 'r', '+')
>>> p = TemporalOperatorParser()
>>> expression =  "{/, equal | contains}"
>>> p.parse(expression, optype = 'raster')
>>> print((p.relations, p.temporal, p.function))
(['equal', 'contains'], 'l', '/')
>>> p = TemporalOperatorParser()
>>> expression =  "{+, equal | contains,intersect}"
>>> p.parse(expression, optype = 'raster')
>>> print((p.relations, p.temporal, p.function))
(['equal', 'contains'], 'i', '+')
>>> p = TemporalOperatorParser()
>>> expression =  "{*, contains,disjoint}"
>>> p.parse(expression, optype = 'raster')
>>> print((p.relations, p.temporal, p.function))
(['contains'], 'd', '*')
>>> p = TemporalOperatorParser()
>>> expression =  "{~, equal,left}"
>>> p.parse(expression, optype = 'overlay')
>>> print((p.relations, p.temporal, p.function))
(['equal'], 'l', '~')
>>> p = TemporalOperatorParser()
>>> expression =  "{^, over,right}"
>>> p.parse(expression, optype = 'overlay')
>>> print((p.relations, p.temporal, p.function))
(['overlaps', 'overlapped'], 'r', '^')
>>> p = TemporalOperatorParser()
>>> expression =  "{&&, equal | during | contains | starts, &}"
>>> p.parse(expression, optype = 'boolean')
>>> print((p.relations, p.temporal, p.function, p.aggregate))
(['equal', 'during', 'contains', 'starts'], 'l', '&&', '&')
>>> p = TemporalOperatorParser()
>>> expression =  "{&&, equal | during | contains | starts, &&&&&}"
>>> p.parse(expression, optype = 'boolean')
Traceback (most recent call last):
SyntaxError: Unexpected syntax error in expression "{&&, equal | during | contains | starts, &&&&&}" at position 42 near &
>>> p = TemporalOperatorParser()
>>> expression =  "{+, starting}"
>>> p.parse(expression)
Traceback (most recent call last):
SyntaxError: syntax error on line 1 position 4 near 'starting'
>>> p = TemporalOperatorParser()
>>> expression =  "{nope, start, |, l}"
>>> p.parse(expression)
Traceback (most recent call last):
SyntaxError: syntax error on line 1 position 1 near 'nope'
>>> p = TemporalOperatorParser()
>>> expression =  "{++, start, |, l}"
>>> p.parse(expression)
Traceback (most recent call last):
SyntaxError: Unexpected syntax error in expression "{++, start, |, l}" at position 2 near +
>>> p = TemporalOperatorParser()
>>> expression =  "{^, over, right}"
>>> p.parse(expression, optype='rter')
Traceback (most recent call last):
SyntaxError: Unknown optype rter, must be one of ['select', 'boolean', 'raster', 'hash', 'relation', 'overlay']
Traceback (most recent call last):
SyntaxError: Unknown optype rter, must be one of ['select', 'boolean', 'raster', 'hash', 'relation', 'overlay']
class temporal.temporal_operator.TemporalOperatorLexer[source]

Bases: object

Lexical analyzer for the GRASS GIS temporal operator

build(**kwargs)[source]
relations = {'overlaps': 'OVERLAPS', 'finishes': 'FINISHES', 'started': 'STARTED', 'over': 'OVER', 'finished': 'FINISHED', 'precedes': 'PRECEDES', 'during': 'DURING', 'overlapped': 'OVERLAPPED', 'follows': 'FOLLOWS', 'contains': 'CONTAINS', 'equal': 'EQUAL', 'starts': 'STARTS'}
t_ADD = '[\\+]'
t_AND = '[&]'
t_CLPAREN = '\\{'
t_COMMA = ','
t_CRPAREN = '\\}'
t_DISJOINT = '^[d|disjoint]'
t_DISOR = '\\+'
t_DIV = '[\\/]'
t_HASH = '\\#'
t_INTERSECT = '^[i|intersect]'
t_LEFTREF = '^[l|left]'
t_MOD = '[\\%]'
t_MULT = '[\\*]'
t_NAME(t)[source]

[a-zA-Z_][a-zA-Z_0-9]*

t_NOT = '\\~'
t_OR = '[\\|]'
t_RIGHTREF = '^[r|right]'
t_SUB = '[-]'
t_T_NOT_SELECT = '!:'
t_T_SELECT = ':'
t_UNION = '^[u|union]'
t_XOR = '\\^'
t_error(t)[source]
t_ignore = ' \t\n'
t_newline(t)[source]

n+

temporal_symbol(t)[source]
test(data)[source]
tokens = ('COMMA', 'LEFTREF', 'RIGHTREF', 'UNION', 'DISJOINT', 'INTERSECT', 'HASH', 'OR', 'AND', 'DISOR', 'XOR', 'NOT', 'MOD', 'DIV', 'MULT', 'ADD', 'SUB', 'T_SELECT', 'T_NOT_SELECT', 'CLPAREN', 'CRPAREN', 'OVERLAPS', 'FINISHES', 'STARTED', 'OVER', 'FINISHED', 'PRECEDES', 'DURING', 'OVERLAPPED', 'FOLLOWS', 'CONTAINS', 'EQUAL', 'STARTS')
class temporal.temporal_operator.TemporalOperatorParser[source]

Bases: object

The temporal operator class

p_arithmetic_operator(t)[source]
arithmetic : MOD
DIV
MULT
ADD
SUB
p_error(t)[source]
p_hash_relation_operator(t)[source]
operator : CLPAREN HASH CRPAREN
CLPAREN HASH COMMA relation CRPAREN
CLPAREN HASH COMMA relationlist CRPAREN
CLPAREN HASH COMMA relation COMMA temporal CRPAREN
CLPAREN HASH COMMA relationlist COMMA temporal CRPAREN
p_over(t)[source]

relation : OVER

p_overlay_operator(t)[source]
overlay : AND
OR
XOR
DISOR
NOT
p_overlay_relation_operator(t)[source]
operator : CLPAREN overlay CRPAREN
CLPAREN overlay COMMA relation CRPAREN
CLPAREN overlay COMMA relationlist CRPAREN
CLPAREN overlay COMMA relation COMMA temporal CRPAREN
CLPAREN overlay COMMA relationlist COMMA temporal CRPAREN
p_raster_relation_operator(t)[source]
operator : CLPAREN arithmetic CRPAREN
CLPAREN arithmetic COMMA relation CRPAREN
CLPAREN arithmetic COMMA relationlist CRPAREN
CLPAREN arithmetic COMMA relation COMMA temporal CRPAREN
CLPAREN arithmetic COMMA relationlist COMMA temporal CRPAREN
p_relation(t)[source]
relation : EQUAL
FOLLOWS
PRECEDES
OVERLAPS
OVERLAPPED
DURING
STARTS
FINISHES
CONTAINS
STARTED
FINISHED
p_relation_bool_combi_operator(t)[source]
operator : CLPAREN OR OR COMMA relation COMMA OR CRPAREN
CLPAREN OR OR COMMA relation COMMA AND CRPAREN
CLPAREN AND AND COMMA relation COMMA OR CRPAREN
CLPAREN AND AND COMMA relation COMMA AND CRPAREN
CLPAREN OR OR COMMA relationlist COMMA OR CRPAREN
CLPAREN OR OR COMMA relationlist COMMA AND CRPAREN
CLPAREN AND AND COMMA relationlist COMMA OR CRPAREN
CLPAREN AND AND COMMA relationlist COMMA AND CRPAREN
p_relation_bool_combi_operator2(t)[source]
operator : CLPAREN OR OR COMMA relation COMMA temporal CRPAREN
CLPAREN AND AND COMMA relation COMMA temporal CRPAREN
CLPAREN OR OR COMMA relationlist COMMA temporal CRPAREN
CLPAREN AND AND COMMA relationlist COMMA temporal CRPAREN
p_relation_bool_combi_operator3(t)[source]
operator : CLPAREN OR OR COMMA relation COMMA OR COMMA temporal CRPAREN
CLPAREN OR OR COMMA relation COMMA AND COMMA temporal CRPAREN
CLPAREN AND AND COMMA relation COMMA OR COMMA temporal CRPAREN
CLPAREN AND AND COMMA relation COMMA AND COMMA temporal CRPAREN
CLPAREN OR OR COMMA relationlist COMMA OR COMMA temporal CRPAREN
CLPAREN OR OR COMMA relationlist COMMA AND COMMA temporal CRPAREN
CLPAREN AND AND COMMA relationlist COMMA OR COMMA temporal CRPAREN
CLPAREN AND AND COMMA relationlist COMMA AND COMMA temporal CRPAREN
p_relation_bool_operator(t)[source]
operator : CLPAREN OR OR COMMA relation CRPAREN
CLPAREN AND AND COMMA relation CRPAREN
CLPAREN OR OR COMMA relationlist CRPAREN
CLPAREN AND AND COMMA relationlist CRPAREN
p_relation_operator(t)[source]
operator : CLPAREN relation CRPAREN
CLPAREN relationlist CRPAREN
p_relationlist(t)[source]
relationlist : relation OR relation
relation OR relationlist
p_select_operator(t)[source]
select : T_SELECT
T_NOT_SELECT
p_select_relation_operator(t)[source]
operator : CLPAREN select CRPAREN
CLPAREN select COMMA relation CRPAREN
CLPAREN select COMMA relationlist CRPAREN
CLPAREN select COMMA relation COMMA temporal CRPAREN
CLPAREN select COMMA relationlist COMMA temporal CRPAREN
p_temporal_operator(t)[source]
temporal : LEFTREF
RIGHTREF
UNION
DISJOINT
INTERSECT
parse(expression, optype='relation')[source]

Parse the expression and fill the object variables

Parameters:
  • expression
  • optype – The parameter optype can be of type: - select { :, during, r} - boolean {&&, contains, |} - raster { *, equal, |} - overlay { |, starts, &} - hash { #, during, l} - relation {during}
Returns:

tokens = ('COMMA', 'LEFTREF', 'RIGHTREF', 'UNION', 'DISJOINT', 'INTERSECT', 'HASH', 'OR', 'AND', 'DISOR', 'XOR', 'NOT', 'MOD', 'DIV', 'MULT', 'ADD', 'SUB', 'T_SELECT', 'T_NOT_SELECT', 'CLPAREN', 'CRPAREN', 'OVERLAPS', 'FINISHES', 'STARTED', 'OVER', 'FINISHED', 'PRECEDES', 'DURING', 'OVERLAPPED', 'FOLLOWS', 'CONTAINS', 'EQUAL', 'STARTS')

temporal.temporal_raster3d_algebra module

!@package grass.temporal

Temporal raster algebra

(C) 2013 by the GRASS Development Team This program is free software under the GNU General Public License (>=v2). Read the file COPYING that comes with GRASS for details.

authors:Thomas Leppelt and Soeren Gebbert
class temporal.temporal_raster3d_algebra.TemporalRaster3DAlgebraParser(pid=None, run=False, debug=True, spatial=False, register_null=False, dry_run=False, nprocs=1)[source]

Bases: temporal.temporal_raster_base_algebra.TemporalRasterBaseAlgebraParser

The temporal raster algebra class

p_statement_assign(t)[source]

statement : stds EQUALS expr

p_ts_neighbor_operation(t)[source]
expr : stds L_SPAREN number COMMA number COMMA number R_SPAREN
stds L_SPAREN number R_SPAREN
stds L_SPAREN number COMMA number COMMA number COMMA number R_SPAREN
parse(expression, basename=None, overwrite=False)[source]

temporal.temporal_raster_algebra module

!@package grass.temporal

Temporal raster algebra

(C) 2013 by the GRASS Development Team This program is free software under the GNU General Public License (>=v2). Read the file COPYING that comes with GRASS for details.

authors:Thomas Leppelt and Soeren Gebbert
>>> p = TemporalRasterAlgebraLexer()
>>> p.build()
>>> p.debug = True
>>> expression =  'R = A[0,1,0] / B[0,0,1] * 20 + C[0,1,1] - 2.45'
>>> p.test(expression)
R = A[0,1,0] / B[0,0,1] * 20 + C[0,1,1] - 2.45
LexToken(NAME,'R',1,0)
LexToken(EQUALS,'=',1,2)
LexToken(NAME,'A',1,4)
LexToken(L_SPAREN,'[',1,5)
LexToken(INT,0,1,6)
LexToken(COMMA,',',1,7)
LexToken(INT,1,1,8)
LexToken(COMMA,',',1,9)
LexToken(INT,0,1,10)
LexToken(R_SPAREN,']',1,11)
LexToken(DIV,'/',1,13)
LexToken(NAME,'B',1,15)
LexToken(L_SPAREN,'[',1,16)
LexToken(INT,0,1,17)
LexToken(COMMA,',',1,18)
LexToken(INT,0,1,19)
LexToken(COMMA,',',1,20)
LexToken(INT,1,1,21)
LexToken(R_SPAREN,']',1,22)
LexToken(MULT,'*',1,24)
LexToken(INT,20,1,26)
LexToken(ADD,'+',1,29)
LexToken(NAME,'C',1,31)
LexToken(L_SPAREN,'[',1,32)
LexToken(INT,0,1,33)
LexToken(COMMA,',',1,34)
LexToken(INT,1,1,35)
LexToken(COMMA,',',1,36)
LexToken(INT,1,1,37)
LexToken(R_SPAREN,']',1,38)
LexToken(SUB,'-',1,40)
LexToken(FLOAT,2.45,1,42)
class temporal.temporal_raster_algebra.TemporalRasterAlgebraParser(pid=None, run=False, debug=True, spatial=False, register_null=False, dry_run=False, nprocs=1)[source]

Bases: temporal.temporal_raster_base_algebra.TemporalRasterBaseAlgebraParser

The temporal raster algebra class

p_statement_assign(t)[source]

statement : stds EQUALS expr

p_ts_neighbour_operation(t)[source]
expr : stds L_SPAREN number COMMA number R_SPAREN
stds L_SPAREN number R_SPAREN
stds L_SPAREN number COMMA number COMMA number R_SPAREN
parse(expression, basename=None, overwrite=False)[source]

temporal.temporal_raster_base_algebra module

@package grass.temporal

Temporal raster algebra

(C) 2013 by the GRASS Development Team This program is free software under the GNU General Public License (>=v2). Read the file COPYING that comes with GRASS for details.

authors:Thomas Leppelt and Soeren Gebbert
>>> p = TemporalRasterAlgebraLexer()
>>> p.build()
>>> p.debug = True
>>> expression =  'R = A {+,equal,l} B'
>>> p.test(expression)
R = A {+,equal,l} B
LexToken(NAME,'R',1,0)
LexToken(EQUALS,'=',1,2)
LexToken(NAME,'A',1,4)
LexToken(T_ARITH2_OPERATOR,'{+,equal,l}',1,6)
LexToken(NAME,'B',1,18)
>>> expression =  'R = A {*,equal|during,r} B'
>>> p.test(expression)
R = A {*,equal|during,r} B
LexToken(NAME,'R',1,0)
LexToken(EQUALS,'=',1,2)
LexToken(NAME,'A',1,4)
LexToken(T_ARITH1_OPERATOR,'{*,equal|during,r}',1,6)
LexToken(NAME,'B',1,25)
>>> expression =  'R = A {+,equal|during} B'
>>> p.test(expression)
R = A {+,equal|during} B
LexToken(NAME,'R',1,0)
LexToken(EQUALS,'=',1,2)
LexToken(NAME,'A',1,4)
LexToken(T_ARITH2_OPERATOR,'{+,equal|during}',1,6)
LexToken(NAME,'B',1,23)
class temporal.temporal_raster_base_algebra.TemporalRasterAlgebraLexer[source]

Bases: temporal.temporal_algebra.TemporalAlgebraLexer

Lexical analyzer for the GRASS GIS temporal algebra

map_functions = {'map': 'MAP'}
mapcalc_functions = {'asin': 'ASIN', 'cos': 'COS', 'log': 'LOG', 'int': 'INTEXP', 'double': 'DOUBLE', 'float': 'FLOATEXP', 'sqrt': 'SQRT', 'isnull': 'ISNULL', 'abs': 'ABS', 'exist': 'EXIST', 'exp': 'EXP', 'isntnull': 'ISNTNULL', 'acos': 'ACOS', 'null': 'NULL', 'sin': 'SIN', 'tan': 'TAN'}
raster_tokens = ('MOD', 'DIV', 'MULT', 'ADD', 'SUB', 'T_ARITH1_OPERATOR', 'T_ARITH2_OPERATOR', 'L_SPAREN', 'R_SPAREN')
t_ADD = '[\\+]'
t_DIV = '[\\/]'
t_L_SPAREN = '\\['
t_MOD = '[\\%]'
t_MULT = '[\\*]'
t_R_SPAREN = '\\]'
t_SUB = '[-]'
t_T_ARITH1_OPERATOR = '\\{[\\%\\*\\/][,]?[a-zA-Z\\| ]*([,])?([lrudi]|left|right|union|disjoint|intersect)?\\}'
t_T_ARITH2_OPERATOR = '\\{[+-][,]?[a-zA-Z\\| ]*([,])?([lrudi]|left|right|union|disjoint|intersect)?\\}'
temporal_symbol(t)[source]
tokens = ('DATETIME', 'TIME', 'DATE', 'INT', 'FLOAT', 'LPAREN', 'RPAREN', 'COMMA', 'CEQUALS', 'EQUALS', 'UNEQUALS', 'LOWER', 'LOWER_EQUALS', 'GREATER', 'GREATER_EQUALS', 'HASH', 'OR', 'AND', 'T_SELECT_OPERATOR', 'T_HASH_OPERATOR', 'T_COMP_OPERATOR', 'T_REL_OPERATOR', 'T_SELECT', 'T_NOT_SELECT', 'NAME', 'QUOTE', 'START_DATETIME', 'END_DATE', 'START_TIME', 'END_DATETIME', 'START_DATE', 'END_TIME', 'START_MONTH', 'START_YEAR', 'START_MINUTE', 'END_MINUTE', 'START_DOW', 'START_DOY', 'START_WEEK', 'START_HOUR', 'END_HOUR', 'START_DAY', 'END_YEAR', 'END_MONTH', 'END_DOW', 'END_DAY', 'START_SECOND', 'END_SECOND', 'TD', 'END_DOY', 'END_WEEK', 'MERGE', 'TMAP', 'STVDS', 'STR3DS', 'STRDS', 'BUFF_T', 'TSNAP', 'TSHIFT', 'IF', 'MOD', 'DIV', 'MULT', 'ADD', 'SUB', 'T_ARITH1_OPERATOR', 'T_ARITH2_OPERATOR', 'L_SPAREN', 'R_SPAREN', 'ASIN', 'COS', 'LOG', 'INTEXP', 'DOUBLE', 'FLOATEXP', 'SQRT', 'ISNULL', 'ABS', 'EXIST', 'EXP', 'ISNTNULL', 'ACOS', 'NULL', 'SIN', 'TAN', 'MAP')
class temporal.temporal_raster_base_algebra.TemporalRasterBaseAlgebraParser(pid=None, run=True, debug=False, spatial=False, register_null=False, dry_run=False, nprocs=1)[source]

Bases: temporal.temporal_algebra.TemporalAlgebraParser

The temporal algebra class

build_command_string(map_i, relmap, operator=None, cmd_type=None)[source]

This function build the r.mapcalc command string for conditionals, spatial variable combinations and boolean comparisons.

For Example: ‘if(a1 == 1, b1, c2)’ or ‘exist(a1) && sin(b1)’

Parameters:
  • map_i – map object with temporal extent and built relations.
  • relmap – map object with defined temporal relation to map_i.
  • operator – String representing operator between two spatial variables (&&,||,+,-,*,/).
  • cmd_type – map object with defined temporal relation to map_i: condition, conclusion or operator.
Returns:

the resulting command string for conditionals or spatial variable combinations

build_condition_cmd_list(iflist, thenlist, elselist=None, condition_topolist=['EQUAL'], conclusion_topolist=['EQUAL'], temporal='l', null=False)[source]

This function build the r.mapcalc command strings for spatial conditionals. For Example: ‘if(a1 == 1, b1, c2)’

Parameters:
  • iflist – Map list with temporal extents and command list.
  • thenlist – Map list with temporal extents and command list or numeric string.
  • elselist – Map list with temporal extents and command list or numeric string.
  • condition_topolist – List of strings for given temporal relations between conditions and conclusions.
  • conclusion_topolist – List of strings for given temporal relations between conditions (then and else).
  • temporal – The temporal operator specifying the temporal extent operation (intersection, union, disjoint union, right reference, left reference).
  • null – Boolean if null map support should be activated.
Returns:

map list with resulting command string for given condition type.

check_null(t)[source]
compare_cmd_value(map_i, tbrelations, compop, aggregate, topolist=['EQUAL'], convert=False)[source]

Function to evaluate two map lists with boolean values by boolean comparison operator.

Extended temporal algebra version with command list builder for temporal raster algebra.

Parameters:
  • map_i – Map object with temporal extent.
  • tbrelations – List of temporal relation to map_i.
  • topolist – List of strings for given temporal relations.
  • compop – Comparison operator, && or ||.
  • aggregate – Aggregation operator for relation map list, & or |.
  • convert – Boolean if conditional values should be converted to r.mapcalc command strings.
Returns:

Map object with conditional value that has been evaluated by comparison operators.

get_temporal_topo_list(maplistA, maplistB=None, topolist=['EQUAL'], assign_val=False, count_map=False, compare_bool=False, compare_cmd=False, compop=None, aggregate=None, new=False, convert=False, operator_cmd=False)[source]

Build temporal topology for two space time data sets, copy map objects for given relation into map list.

Parameters:
  • maplistA – List of maps.
  • maplistB – List of maps.
  • topolist – List of strings of temporal relations.
  • assign_val – Boolean for assigning a boolean map value based on the map_values from the compared map list by topological relationships.
  • count_map – Boolean if the number of topological related maps should be returned.
  • compare_bool – Boolean for comparing boolean map values based on related map list and compariosn operator.
  • compare_cmd – Boolean for comparing command list values based on related map list and compariosn operator.
  • compop – Comparison operator, && or ||.
  • aggregate – Aggregation operator for relation map list, & or |.
  • new – Boolean if new temporary maps should be created.
  • convert – Boolean if conditional values should be converted to r.mapcalc command strings.
  • operator_cmd – Boolean for aggregate arithmetic operators implicitly in command list values based on related map lists.
Returns:

List of maps from maplistA that fulfil the topological relationships to maplistB specified in topolist.

operator_cmd_value(map_i, tbrelations, operator, topolist=['EQUAL'])[source]

Function to evaluate two map lists by given arithmetic operator.

Parameters:
  • map_i – Map object with temporal extent.
  • tbrelations – List of temporal relation to map_i.
  • topolist – List of strings for given temporal relations.
  • operator – Arithmetic operator, +-*/%.
Returns:

Map object with command list with operators that has been evaluated by implicit aggregration.

p_arith1_operation(t)[source]
expr : stds MOD stds
expr MOD stds
stds MOD expr
expr MOD expr
stds DIV stds
expr DIV stds
stds DIV expr
expr DIV expr
stds MULT stds
expr MULT stds
stds MULT expr
expr MULT expr
stds MOD t_td_var
expr MOD t_td_var
stds DIV t_td_var
expr DIV t_td_var
stds MULT t_td_var
expr MULT t_td_var
p_arith1_operation_numeric1(t)[source]
expr : stds MOD number
expr MOD number
stds DIV number
expr DIV number
stds MULT number
expr MULT number
stds MOD numberstr
expr MOD numberstr
stds DIV numberstr
expr DIV numberstr
stds MULT numberstr
expr MULT numberstr
stds MOD mapexpr
expr MOD mapexpr
stds DIV mapexpr
expr DIV mapexpr
stds MULT mapexpr
expr MULT mapexpr
p_arith1_operation_numeric2(t)[source]
expr : number MOD stds
number MOD expr
number DIV stds
number DIV expr
number MULT stds
number MULT expr
numberstr MOD stds
numberstr MOD expr
numberstr DIV stds
numberstr DIV expr
numberstr MULT stds
numberstr MULT expr
mapexpr MOD stds
mapexpr MOD expr
mapexpr DIV stds
mapexpr DIV expr
mapexpr MULT stds
mapexpr MULT expr
p_arith1_operation_relation(t)[source]
expr : stds T_ARITH1_OPERATOR stds
expr T_ARITH1_OPERATOR stds
stds T_ARITH1_OPERATOR expr
expr T_ARITH1_OPERATOR expr
stds T_ARITH1_OPERATOR t_td_var
expr T_ARITH1_OPERATOR t_td_var
p_arith2_operation(t)[source]
expr : stds ADD stds
expr ADD stds
stds ADD expr
expr ADD expr
stds SUB stds
expr SUB stds
stds SUB expr
expr SUB expr
stds ADD t_td_var
expr ADD t_td_var
expr SUB t_td_var
stds SUB t_td_var
p_arith2_operation_numeric1(t)[source]
expr : stds ADD number
expr ADD number
stds SUB number
expr SUB number
stds ADD numberstr
expr ADD numberstr
stds SUB numberstr
expr SUB numberstr
stds ADD mapexpr
expr ADD mapexpr
stds SUB mapexpr
expr SUB mapexpr
p_arith2_operation_numeric2(t)[source]
expr : number ADD stds
number ADD expr
number SUB stds
number SUB expr
numberstr ADD stds
numberstr ADD expr
numberstr SUB stds
numberstr SUB expr
mapexpr ADD stds
mapexpr ADD expr
mapexpr SUB stds
mapexpr SUB expr
p_arith2_operation_relation(t)[source]
expr : stds T_ARITH2_OPERATOR stds
expr T_ARITH2_OPERATOR stds
stds T_ARITH2_OPERATOR expr
expr T_ARITH2_OPERATOR expr
stds T_ARITH2_OPERATOR t_td_var
expr T_ARITH2_OPERATOR t_td_var
p_arith_operation_numeric_string(t)[source]
numberstr : number ADD number
number SUB number
number DIV number
number MULT number
number MOD number
p_expr_spmap_function(t)[source]

mapexpr : MAP LPAREN stds RPAREN

p_hash_operation(t)[source]

expr : t_hash_var

p_mapcalc_function(t)[source]
mapcalc_arith : ABS
LOG
SQRT
EXP
COS
ACOS
SIN
ASIN
TAN
DOUBLE
FLOATEXP
INTEXP
p_mapcalc_operation1(t)[source]
expr : mapcalc_arith LPAREN stds RPAREN
mapcalc_arith LPAREN expr RPAREN
p_mapexpr_operation(t)[source]

mapexpr : mapcalc_arith LPAREN mapexpr RPAREN

p_s_expr_condition_elif(t)[source]
expr : IF LPAREN s_var_expr COMMA stds COMMA stds RPAREN
IF LPAREN s_var_expr COMMA stds COMMA expr RPAREN
IF LPAREN s_var_expr COMMA expr COMMA stds RPAREN
IF LPAREN s_var_expr COMMA expr COMMA expr RPAREN
IF LPAREN ts_var_expr COMMA stds COMMA stds RPAREN
IF LPAREN ts_var_expr COMMA stds COMMA expr RPAREN
IF LPAREN ts_var_expr COMMA expr COMMA stds RPAREN
IF LPAREN ts_var_expr COMMA expr COMMA expr RPAREN
p_s_expr_condition_elif_relation(t)[source]
expr : IF LPAREN T_REL_OPERATOR COMMA s_var_expr COMMA stds COMMA stds RPAREN
IF LPAREN T_REL_OPERATOR COMMA s_var_expr COMMA stds COMMA expr RPAREN
IF LPAREN T_REL_OPERATOR COMMA s_var_expr COMMA expr COMMA stds RPAREN
IF LPAREN T_REL_OPERATOR COMMA s_var_expr COMMA expr COMMA expr RPAREN
IF LPAREN T_REL_OPERATOR COMMA ts_var_expr COMMA stds COMMA stds RPAREN
IF LPAREN T_REL_OPERATOR COMMA ts_var_expr COMMA stds COMMA expr RPAREN
IF LPAREN T_REL_OPERATOR COMMA ts_var_expr COMMA expr COMMA stds RPAREN
IF LPAREN T_REL_OPERATOR COMMA ts_var_expr COMMA expr COMMA expr RPAREN
p_s_expr_condition_if(t)[source]
expr : IF LPAREN s_var_expr COMMA stds RPAREN
IF LPAREN s_var_expr COMMA expr RPAREN
IF LPAREN ts_var_expr COMMA stds RPAREN
IF LPAREN ts_var_expr COMMA expr RPAREN
p_s_expr_condition_if_relation(t)[source]
expr : IF LPAREN T_REL_OPERATOR COMMA s_var_expr COMMA stds RPAREN
IF LPAREN T_REL_OPERATOR COMMA s_var_expr COMMA expr RPAREN
IF LPAREN T_REL_OPERATOR COMMA ts_var_expr COMMA stds RPAREN
IF LPAREN T_REL_OPERATOR COMMA ts_var_expr COMMA expr RPAREN
p_s_numeric_condition_elif(t)[source]
expr : IF LPAREN s_var_expr COMMA number COMMA number RPAREN
IF LPAREN s_var_expr COMMA NULL LPAREN RPAREN COMMA number RPAREN
IF LPAREN s_var_expr COMMA number COMMA NULL LPAREN RPAREN RPAREN
IF LPAREN s_var_expr COMMA NULL LPAREN RPAREN COMMA NULL LPAREN RPAREN RPAREN
IF LPAREN ts_var_expr COMMA number COMMA number RPAREN
IF LPAREN ts_var_expr COMMA NULL LPAREN RPAREN COMMA number RPAREN
IF LPAREN ts_var_expr COMMA number COMMA NULL LPAREN RPAREN RPAREN
IF LPAREN ts_var_expr COMMA NULL LPAREN RPAREN COMMA NULL LPAREN RPAREN RPAREN
p_s_numeric_condition_if(t)[source]
expr : IF LPAREN s_var_expr COMMA number RPAREN
IF LPAREN s_var_expr COMMA NULL LPAREN RPAREN RPAREN
IF LPAREN ts_var_expr COMMA number RPAREN
IF LPAREN ts_var_expr COMMA NULL LPAREN RPAREN RPAREN
p_s_numeric_expr_condition_elif(t)[source]
expr : IF LPAREN s_var_expr COMMA number COMMA stds RPAREN
IF LPAREN s_var_expr COMMA NULL LPAREN RPAREN COMMA stds RPAREN
IF LPAREN s_var_expr COMMA number COMMA expr RPAREN
IF LPAREN s_var_expr COMMA NULL LPAREN RPAREN COMMA expr RPAREN
IF LPAREN s_var_expr COMMA stds COMMA number RPAREN
IF LPAREN s_var_expr COMMA stds COMMA NULL LPAREN RPAREN RPAREN
IF LPAREN s_var_expr COMMA expr COMMA number RPAREN
IF LPAREN s_var_expr COMMA expr COMMA NULL LPAREN RPAREN RPAREN
IF LPAREN ts_var_expr COMMA number COMMA stds RPAREN
IF LPAREN ts_var_expr COMMA NULL LPAREN RPAREN COMMA stds RPAREN
IF LPAREN ts_var_expr COMMA number COMMA expr RPAREN
IF LPAREN ts_var_expr COMMA NULL LPAREN RPAREN COMMA expr RPAREN
IF LPAREN ts_var_expr COMMA stds COMMA number RPAREN
IF LPAREN ts_var_expr COMMA stds COMMA NULL LPAREN RPAREN RPAREN
IF LPAREN ts_var_expr COMMA expr COMMA number RPAREN
IF LPAREN ts_var_expr COMMA expr COMMA NULL LPAREN RPAREN RPAREN
p_s_numeric_expr_condition_elif_relation(t)[source]
expr : IF LPAREN T_REL_OPERATOR COMMA s_var_expr COMMA number COMMA stds RPAREN
IF LPAREN T_REL_OPERATOR COMMA s_var_expr COMMA NULL LPAREN RPAREN COMMA stds RPAREN
IF LPAREN T_REL_OPERATOR COMMA s_var_expr COMMA number COMMA expr RPAREN
IF LPAREN T_REL_OPERATOR COMMA s_var_expr COMMA NULL LPAREN RPAREN COMMA expr RPAREN
IF LPAREN T_REL_OPERATOR COMMA s_var_expr COMMA stds COMMA number RPAREN
IF LPAREN T_REL_OPERATOR COMMA s_var_expr COMMA stds COMMA NULL LPAREN RPAREN RPAREN
IF LPAREN T_REL_OPERATOR COMMA s_var_expr COMMA expr COMMA number RPAREN
IF LPAREN T_REL_OPERATOR COMMA s_var_expr COMMA expr COMMA NULL LPAREN RPAREN RPAREN
IF LPAREN T_REL_OPERATOR COMMA ts_var_expr COMMA number COMMA stds RPAREN
IF LPAREN T_REL_OPERATOR COMMA ts_var_expr COMMA NULL LPAREN RPAREN COMMA stds RPAREN
IF LPAREN T_REL_OPERATOR COMMA ts_var_expr COMMA number COMMA expr RPAREN
IF LPAREN T_REL_OPERATOR COMMA ts_var_expr COMMA NULL LPAREN RPAREN COMMA expr RPAREN
IF LPAREN T_REL_OPERATOR COMMA ts_var_expr COMMA stds COMMA number RPAREN
IF LPAREN T_REL_OPERATOR COMMA ts_var_expr COMMA stds COMMA NULL LPAREN RPAREN RPAREN
IF LPAREN T_REL_OPERATOR COMMA ts_var_expr COMMA expr COMMA number RPAREN
IF LPAREN T_REL_OPERATOR COMMA ts_var_expr COMMA expr COMMA NULL LPAREN RPAREN RPAREN
p_s_var_expr_1(t)[source]
s_var_expr : ISNULL LPAREN stds RPAREN
ISNULL LPAREN expr RPAREN
p_s_var_expr_2(t)[source]
s_var_expr : ISNTNULL LPAREN stds RPAREN
ISNTNULL LPAREN expr RPAREN
p_s_var_expr_3(t)[source]
s_var_expr : stds comp_op number
expr comp_op number
p_s_var_expr_4(t)[source]
s_var_expr : EXIST LPAREN stds RPAREN
EXIST LPAREN expr RPAREN
p_s_var_expr_comp(t)[source]
s_var_expr : s_var_expr AND AND s_var_expr
s_var_expr OR OR s_var_expr
p_s_var_expr_comp_op(t)[source]

s_var_expr : s_var_expr T_COMP_OPERATOR s_var_expr

p_statement_assign(t)[source]

statement : stds EQUALS expr

p_ts_var_expr1(t)[source]
ts_var_expr : s_var_expr AND AND t_var_expr
t_var_expr AND AND s_var_expr
t_var_expr OR OR s_var_expr
s_var_expr OR OR t_var_expr
ts_var_expr AND AND s_var_expr
ts_var_expr AND AND t_var_expr
ts_var_expr OR OR s_var_expr
ts_var_expr OR OR t_var_expr
s_var_expr AND AND ts_var_expr
t_var_expr AND AND ts_var_expr
s_var_expr OR OR ts_var_expr
t_var_expr OR OR ts_var_expr
precedence = (('left', 'T_SELECT_OPERATOR', 'T_SELECT', 'T_NOT_SELECT'), ('left', 'ADD', 'SUB', 'T_ARITH2_OPERATOR', 'T_HASH_OPERATOR', 'HASH'), ('left', 'AND', 'OR', 'T_COMP_OPERATOR', 'MOD', 'DIV', 'MULT', 'T_ARITH1_OPERATOR'))
set_temporal_extent_list(maplist, topolist=['EQUAL'], temporal='l', cmd_bool=False, cmd_type=None, operator=None)[source]

Change temporal extent of map list based on temporal relations to other map list and given temporal operator.

Parameters:
  • maplist – List of map objects for which relations has been build correctely.
  • topolist – List of strings of temporal relations.
  • temporal – The temporal operator specifying the temporal extent operation (intersection, union, disjoint union, right reference, left reference).
  • cmd_bool – Boolean if command string should be merged for related maps.
  • cmd_type – map object with defined temporal relation to map_i: condition, conclusion or operator.
  • operator – String defining the type of operator.
Returns:

Map list with specified temporal extent and optional command string.

tokens = ('DATETIME', 'TIME', 'DATE', 'INT', 'FLOAT', 'LPAREN', 'RPAREN', 'COMMA', 'CEQUALS', 'EQUALS', 'UNEQUALS', 'LOWER', 'LOWER_EQUALS', 'GREATER', 'GREATER_EQUALS', 'HASH', 'OR', 'AND', 'T_SELECT_OPERATOR', 'T_HASH_OPERATOR', 'T_COMP_OPERATOR', 'T_REL_OPERATOR', 'T_SELECT', 'T_NOT_SELECT', 'NAME', 'QUOTE', 'START_DATETIME', 'END_DATE', 'START_TIME', 'END_DATETIME', 'START_DATE', 'END_TIME', 'START_MONTH', 'START_YEAR', 'START_MINUTE', 'END_MINUTE', 'START_DOW', 'START_DOY', 'START_WEEK', 'START_HOUR', 'END_HOUR', 'START_DAY', 'END_YEAR', 'END_MONTH', 'END_DOW', 'END_DAY', 'START_SECOND', 'END_SECOND', 'TD', 'END_DOY', 'END_WEEK', 'MERGE', 'TMAP', 'STVDS', 'STR3DS', 'STRDS', 'BUFF_T', 'TSNAP', 'TSHIFT', 'IF', 'MOD', 'DIV', 'MULT', 'ADD', 'SUB', 'T_ARITH1_OPERATOR', 'T_ARITH2_OPERATOR', 'L_SPAREN', 'R_SPAREN', 'ASIN', 'COS', 'LOG', 'INTEXP', 'DOUBLE', 'FLOATEXP', 'SQRT', 'ISNULL', 'ABS', 'EXIST', 'EXP', 'ISNTNULL', 'ACOS', 'NULL', 'SIN', 'TAN', 'MAP')

temporal.temporal_topology_dataset_connector module

Temporal topology dataset connector class

Usage:

>>> import grass.temporal as tgis
>>> tmr = tgis.TemporalTopologyDatasetConnector()

(C) 2012-2013 by the GRASS Development Team This program is free software under the GNU General Public License (>=v2). Read the file COPYING that comes with GRASS for details.

authors:Soeren Gebbert
class temporal.temporal_topology_dataset_connector.TemporalTopologyDatasetConnector[source]

Bases: object

This class implements a temporal topology access structure to connect temporal related datasets

This object will be set up by temporal topology creation method provided by the SpatioTemporalTopologyBuilder.

If correctly initialize the calls next() and prev() let the user walk temporally forward and backward in time.

The following temporal relations with access methods are supported:

  • equal
  • follows
  • precedes
  • overlaps
  • overlapped
  • during (including starts, finishes)
  • contains (including started, finished)
  • starts
  • started
  • finishes
  • finished
# We have build the temporal topology and we know the first map
start = first
while start:

    # Print all maps this map temporally contains
    dlist = start.get_contains()
    for map in dlist:
        map.print_info()

    start = start.next()

 >>> import grass.temporal as tgis
 >>> tgis.init()
 >>> map = tgis.RasterDataset("a@P")
 >>> tmr = tgis.TemporalTopologyDatasetConnector()
 >>> tmr.set_next(map)
 >>> tmr.set_prev(map)
 >>> tmr.append_equal(map)
 >>> tmr.append_follows(map)
 >>> tmr.append_precedes(map)
 >>> tmr.append_overlapped(map)
 >>> tmr.append_overlaps(map)
 >>> tmr.append_during(map)
 >>> tmr.append_contains(map)
 >>> tmr.append_starts(map)
 >>> tmr.append_started(map)
 >>> tmr.append_finishes(map)
 >>> tmr.append_finished(map)
 >>> tmr.print_temporal_topology_info()
  +-------------------- Temporal Topology -------------------------------------+
  | Next: ...................... a@P
  | Previous: .................. a@P
  | Equal:...................... a@P
  | Follows: ................... a@P
  | Precedes: .................. a@P
  | Overlaps: .................. a@P
  | Overlapped: ................ a@P
  | During: .................... a@P
  | Contains: .................. a@P
  | Starts:.. .................. a@P
  | Started:. .................. a@P
  | Finishes:................... a@P
  | Finished:................... a@P
 >>> tmr.print_temporal_topology_shell_info()
 next=a@P
 prev=a@P
 equal=a@P
 follows=a@P
 precedes=a@P
 overlaps=a@P
 overlapped=a@P
 during=a@P
 contains=a@P
 starts=a@P
 started=a@P
 finishes=a@P
 finished=a@P
 >>> rlist = tmr.get_temporal_relations()
 >>> if "FINISHED" in rlist.keys():
 ...    print(rlist["FINISHED"][0].get_id())
 a@P
append_contains(map)[source]

Append a map that this map temporally contains This includes temporal relationships started and finished

Parameters:map – This object should be of type AbstractMapDataset or derived classes
append_during(map)[source]

Append a map that this map is temporally located during This includes temporal relationships starts and finishes

Parameters:map – This object should be of type AbstractMapDataset or derived classes
append_equal(map)[source]

Append a map with equivalent temporal extent as this map

Parameters:map – This object should be of type AbstractMapDataset or derived classes
append_finished(map)[source]

Append a map that this map temporally finished with

Parameters:map – This object should be of type AbstractMapDataset or derived classes
append_finishes(map)[source]

Append a map that this map temporally finishes with

Parameters:map – This object should be of type AbstractMapDataset or derived classes
append_follows(map)[source]

Append a map that this map temporally follows

Parameters:map – This object should be of type AbstractMapDataset or derived classes
append_overlapped(map)[source]

Append a map that this map temporally overlapped

Parameters:map – This object should be of type AbstractMapDataset or derived classes
append_overlaps(map)[source]

Append a map that this map temporally overlaps

Parameters:map – This object should be of type AbstractMapDataset or derived classes
append_precedes(map)[source]

Append a map that this map temporally precedes

Parameters:map – This object should be of type AbstractMapDataset or derived classes
append_started(map)[source]

Append a map that this map temporally started with

Parameters:map – This object should be of type AbstractMapDataset or derived classes
append_starts(map)[source]

Append a map that this map temporally starts with

Parameters:map – This object should be of type AbstractMapDataset or derived classes
contains

Return a list of map objects that this map temporally contains This includes temporal relationships started and finished

Returns:A list of map objects or None
during

Return a list of map objects that this map is temporally located during This includes temporally relationships starts and finishes

Returns:A list of map objects or None
equal

Return a list of map objects with equivalent temporal extent as this map

Returns:A list of map objects or None
finished

Return a list of map objects that this map temporally finished with

Returns:A list of map objects or None
finishes

Return a list of map objects that this map temporally finishes with

Returns:A list of map objects or None
follows

Return a list of map objects that this map temporally follows

Returns:A list of map objects or None
get_contains()[source]

Return a list of map objects that this map temporally contains This includes temporal relationships started and finished

Returns:A list of map objects or None
get_during()[source]

Return a list of map objects that this map is temporally located during This includes temporally relationships starts and finishes

Returns:A list of map objects or None
get_equal()[source]

Return a list of map objects with equivalent temporal extent as this map

Returns:A list of map objects or None
get_finished()[source]

Return a list of map objects that this map temporally finished with

Returns:A list of map objects or None
get_finishes()[source]

Return a list of map objects that this map temporally finishes with

Returns:A list of map objects or None
get_follows()[source]

Return a list of map objects that this map temporally follows

Returns:A list of map objects or None
get_number_of_temporal_relations()[source]

Return a dictionary in which the keys are the relation names and the value are the number of relations.

The following relations are available:

  • equal
  • follows
  • precedes
  • overlaps
  • overlapped
  • during (including starts, finishes)
  • contains (including started, finished)
  • starts
  • started
  • finishes
  • finished

To access topological information the temporal topology must be build first using the SpatioTemporalTopologyBuilder.

Returns:the dictionary with relations as keys and number as values or None in case the topology wasn’t build
get_overlapped()[source]

Return a list of map objects that this map temporally overlapped

Returns:A list of map objects or None
get_overlaps()[source]

Return a list of map objects that this map temporally overlaps

Returns:A list of map objects or None
get_precedes()[source]

Return a list of map objects that this map temporally precedes

Returns:A list of map objects or None
get_started()[source]

Return a list of map objects that this map temporally started with

Returns:A list of map objects or None
get_starts()[source]

Return a list of map objects that this map temporally starts with

Returns:A list of map objects or None
get_temporal_relations()[source]

Return the dictionary of temporal relationships

Keys are the temporal relationships in upper case, values are abstract map objects.

Returns:The temporal relations dictionary
is_temporal_topology_build()[source]

Check if the temporal topology was build

next()[source]

Return the map with a start time temporally located after the start time of this map, but temporal closer than other maps

Returns:A map object or None
overlapped

Return a list of map objects that this map temporally overlapped

Returns:A list of map objects or None
overlaps

Return a list of map objects that this map temporally overlaps

Returns:A list of map objects or None
precedes

Return a list of map objects that this map temporally precedes

Returns:A list of map objects or None
prev()[source]

Return the map with a start time temporally located before the start time of this map, but temporal closer than other maps

Returns:A map object or None
print_temporal_topology_info()[source]

Print information about this class in human readable style

print_temporal_topology_shell_info()[source]

Print information about this class in shell style

reset_temporal_topology()[source]

Reset any information about temporal topology

set_next(map)[source]

Set the map that is temporally as closest located after this map.

Temporally located means that the start time of the “next” map is temporally located AFTER the start time of this map, but temporally near than other maps of the same dataset.

Parameters:map – This object should be of type AbstractMapDataset or derived classes
set_prev(map)[source]

Set the map that is temporally as closest located before this map.

Temporally located means that the start time of the “previous” map is temporally located BEFORE the start time of this map, but temporally near than other maps of the same dataset.

Parameters:map – This object should be of type AbstractMapDataset or derived classes
set_temporal_topology_build_false()[source]

Same as name

set_temporal_topology_build_true()[source]

Same as name

started

Return a list of map objects that this map temporally started with

Returns:A list of map objects or None
starts

Return a list of map objects that this map temporally starts with

Returns:A list of map objects or None

temporal.temporal_vector_algebra module

@package grass.temporal

Temporal vector algebra

(C) 2014 by the GRASS Development Team This program is free software under the GNU General Public License (>=v2). Read the file COPYING that comes with GRASS for details.

authors:Thomas Leppelt and Soeren Gebbert
>>> import grass.temporal as tgis
>>> tgis.init(True)
>>> p = tgis.TemporalVectorAlgebraLexer()
>>> p.build()
>>> p.debug = True
>>> expression =  'E = A : B ^ C : D'
>>> p.test(expression)
E = A : B ^ C : D
LexToken(NAME,'E',1,0)
LexToken(EQUALS,'=',1,2)
LexToken(NAME,'A',1,4)
LexToken(T_SELECT,':',1,6)
LexToken(NAME,'B',1,8)
LexToken(XOR,'^',1,10)
LexToken(NAME,'C',1,12)
LexToken(T_SELECT,':',1,14)
LexToken(NAME,'D',1,16)
>>> expression =  'E = buff_a(A, 10)'
>>> p.test(expression)
E = buff_a(A, 10)
LexToken(NAME,'E',1,0)
LexToken(EQUALS,'=',1,2)
LexToken(BUFF_AREA,'buff_a',1,4)
LexToken(LPAREN,'(',1,10)
LexToken(NAME,'A',1,11)
LexToken(COMMA,',',1,12)
LexToken(INT,10,1,14)
LexToken(RPAREN,')',1,16)
class temporal.temporal_vector_algebra.TemporalVectorAlgebraLexer[source]

Bases: temporal.temporal_algebra.TemporalAlgebraLexer

Lexical analyzer for the GRASS GIS temporal vector algebra

t_DISOR = '\\+'
t_NOT = '\\~'
t_T_OVERLAY_OPERATOR = '\\{[\\|&+\\^\\~][,]?[a-zA-Z\\| ]*([,])?([lrudi]|left|right|union|disjoint|intersect)?\\}'
t_XOR = '\\^'
temporal_symbol(t)[source]
tokens = ('DATETIME', 'TIME', 'DATE', 'INT', 'FLOAT', 'LPAREN', 'RPAREN', 'COMMA', 'CEQUALS', 'EQUALS', 'UNEQUALS', 'LOWER', 'LOWER_EQUALS', 'GREATER', 'GREATER_EQUALS', 'HASH', 'OR', 'AND', 'T_SELECT_OPERATOR', 'T_HASH_OPERATOR', 'T_COMP_OPERATOR', 'T_REL_OPERATOR', 'T_SELECT', 'T_NOT_SELECT', 'NAME', 'QUOTE', 'START_DATETIME', 'END_DATE', 'START_TIME', 'END_DATETIME', 'START_DATE', 'END_TIME', 'START_MONTH', 'START_YEAR', 'START_MINUTE', 'END_MINUTE', 'START_DOW', 'START_DOY', 'START_WEEK', 'START_HOUR', 'END_HOUR', 'START_DAY', 'END_YEAR', 'END_MONTH', 'END_DOW', 'END_DAY', 'START_SECOND', 'END_SECOND', 'TD', 'END_DOY', 'END_WEEK', 'MERGE', 'TMAP', 'STVDS', 'STR3DS', 'STRDS', 'BUFF_T', 'TSNAP', 'TSHIFT', 'IF', 'DISOR', 'XOR', 'NOT', 'T_OVERLAY_OPERATOR', 'BUFF_LINE', 'BUFF_POINT', 'BUFF_AREA')
vector_buff_functions = {'buff_l': 'BUFF_LINE', 'buff_p': 'BUFF_POINT', 'buff_a': 'BUFF_AREA'}
vector_tokens = ('DISOR', 'XOR', 'NOT', 'T_OVERLAY_OPERATOR')
class temporal.temporal_vector_algebra.TemporalVectorAlgebraParser(pid=None, run=False, debug=True, spatial=False)[source]

Bases: temporal.temporal_algebra.TemporalAlgebraParser

The temporal algebra class

get_temporal_topo_list(maplistA, maplistB=None, topolist=['EQUAL'], assign_val=False, count_map=False, compare_bool=False, compare_cmd=False, compop=None, aggregate=None, new=False, convert=False, overlay_cmd=False)[source]

Build temporal topology for two space time data sets, copy map objects for given relation into map list.

Parameters:
  • maplistA – List of maps.
  • maplistB – List of maps.
  • topolist – List of strings of temporal relations.
  • assign_val – Boolean for assigning a boolean map value based on the map_values from the compared map list by topological relationships.
  • count_map – Boolean if the number of topological related maps should be returned.
  • compare_bool – Boolean for comparing boolean map values based on related map list and compariosn operator.
  • compare_cmd – Boolean for comparing command list values based on related map list and compariosn operator.
  • compop – Comparison operator, && or ||.
  • aggregate – Aggregation operator for relation map list, & or |.
  • new – Boolean if new temporary maps should be created.
  • convert – Boolean if conditional values should be converted to r.mapcalc command strings.
  • overlay_cmd – Boolean for aggregate overlay operators implicitly in command list values based on related map lists.
Returns:

List of maps from maplistA that fulfil the topological relationships to maplistB specified in topolist.

overlay_cmd_value(map_i, tbrelations, function, topolist=['EQUAL'])[source]

Function to evaluate two map lists by given overlay operator.

Parameters:
  • map_i – Map object with temporal extent.
  • tbrelations – List of temporal relation to map_i.
  • topolist – List of strings for given temporal relations.
  • function – Overlay operator, &|+^~.
Returns:

Map object with command list with operators that has been evaluated by implicit aggregration.

p_buff_function(t)[source]

buff_function : BUFF_POINT | BUFF_LINE | BUFF_AREA

p_buffer_operation(t)[source]
expr : buff_function LPAREN stds COMMA number RPAREN
buff_function LPAREN expr COMMA number RPAREN
p_error(t)[source]
p_overlay_operation(t)[source]
expr : stds AND stds
expr AND stds
stds AND expr
expr AND expr
stds OR stds
expr OR stds
stds OR expr
expr OR expr
stds XOR stds
expr XOR stds
stds XOR expr
expr XOR expr
stds NOT stds
expr NOT stds
stds NOT expr
expr NOT expr
stds DISOR stds
expr DISOR stds
stds DISOR expr
expr DISOR expr
p_overlay_operation_relation(t)[source]
expr : stds T_OVERLAY_OPERATOR stds
expr T_OVERLAY_OPERATOR stds
stds T_OVERLAY_OPERATOR expr
expr T_OVERLAY_OPERATOR expr
p_statement_assign(t)[source]

statement : stds EQUALS expr

parse(expression, basename=None, overwrite=False)[source]
precedence = (('left', 'T_SELECT_OPERATOR', 'T_SELECT', 'T_NOT_SELECT', 'T_HASH_OPERATOR', 'HASH'), ('left', 'AND', 'OR', 'T_COMP_OPERATOR', 'T_OVERLAY_OPERATOR', 'DISOR', 'NOT', 'XOR'))
set_temporal_extent_list(maplist, topolist=['EQUAL'], temporal='l')[source]
Change temporal extent of map list based on temporal relations to
other map list and given temporal operator.
Parameters:
  • maplist – List of map objects for which relations has been build correctely.
  • topolist – List of strings of temporal relations.
  • temporal – The temporal operator specifying the temporal extent operation (intersection, union, disjoint union, right reference, left reference).
Returns:

Map list with specified temporal extent.

tokens = ('DATETIME', 'TIME', 'DATE', 'INT', 'FLOAT', 'LPAREN', 'RPAREN', 'COMMA', 'CEQUALS', 'EQUALS', 'UNEQUALS', 'LOWER', 'LOWER_EQUALS', 'GREATER', 'GREATER_EQUALS', 'HASH', 'OR', 'AND', 'T_SELECT_OPERATOR', 'T_HASH_OPERATOR', 'T_COMP_OPERATOR', 'T_REL_OPERATOR', 'T_SELECT', 'T_NOT_SELECT', 'NAME', 'QUOTE', 'START_DATETIME', 'END_DATE', 'START_TIME', 'END_DATETIME', 'START_DATE', 'END_TIME', 'START_MONTH', 'START_YEAR', 'START_MINUTE', 'END_MINUTE', 'START_DOW', 'START_DOY', 'START_WEEK', 'START_HOUR', 'END_HOUR', 'START_DAY', 'END_YEAR', 'END_MONTH', 'END_DOW', 'END_DAY', 'START_SECOND', 'END_SECOND', 'TD', 'END_DOY', 'END_WEEK', 'MERGE', 'TMAP', 'STVDS', 'STR3DS', 'STRDS', 'BUFF_T', 'TSNAP', 'TSHIFT', 'IF', 'DISOR', 'XOR', 'NOT', 'T_OVERLAY_OPERATOR', 'BUFF_LINE', 'BUFF_POINT', 'BUFF_AREA')

temporal.unit_tests module

Depricazed unittests

(C) 2008-2011 by the GRASS Development Team This program is free software under the GNU General Public License (>=v2). Read the file COPYING that comes with GRASS for details.

authors:Soeren Gebbert
temporal.unit_tests.test_1d_rtree()[source]

Testing the rtree ctypes wrapper

temporal.unit_tests.test_2d_rtree()[source]

Testing the rtree ctypes wrapper

temporal.unit_tests.test_3d_rtree()[source]

Testing the rtree ctypes wrapper

temporal.unit_tests.test_4d_rtree()[source]

Testing the rtree ctypes wrapper

temporal.unit_tests.test_adjust_datetime_to_granularity()[source]
temporal.unit_tests.test_compute_absolute_time_granularity()[source]
temporal.unit_tests.test_compute_datetime_delta()[source]
temporal.unit_tests.test_increment_datetime_by_string()[source]
temporal.unit_tests.test_map_list_sorting()[source]
temporal.unit_tests.test_spatial_extent_intersection()[source]
temporal.unit_tests.test_spatial_relations()[source]
temporal.unit_tests.test_temporal_topology_builder()[source]

temporal.univar_statistics module

Univariate statistic function for space time datasets

Usage:

import grass.temporal as tgis

tgis.print_gridded_dataset_univar_statistics(type, input, output, where, extended, no_header, fs, rast_region)

(C) 2012-2013 by the GRASS Development Team This program is free software under the GNU General Public License (>=v2). Read the file COPYING that comes with GRASS for details.

authors:Soeren Gebbert
temporal.univar_statistics.print_gridded_dataset_univar_statistics(type, input, output, where, extended, no_header=False, fs='|', rast_region=False)[source]

Print univariate statistics for a space time raster or raster3d dataset

Parameters:
  • type – Must be “strds” or “str3ds”
  • input – The name of the space time dataset
  • output – Name of the optional output file, if None stdout is used
  • where – A temporal database where statement
  • extended – If True compute extended statistics
  • no_header – Suppress the printing of column names
  • fs – Field separator
  • rast_region – If set True ignore the current region settings and use the raster map regions for univar statistical calculation. Only available for strds.
temporal.univar_statistics.print_vector_dataset_univar_statistics(input, output, twhere, layer, type, column, where, extended, no_header=False, fs='|')[source]

Print univariate statistics for a space time vector dataset

Parameters:
  • input – The name of the space time dataset
  • output – Name of the optional output file, if None stdout is used
  • twhere – A temporal database where statement
  • layer – The layer number used in case no layer is present in the temporal dataset
  • type – options: point,line,boundary,centroid,area
  • column – The name of the attribute column
  • where – A temporal database where statement
  • extended – If True compute extended statistics
  • no_header – Suppress the printing of column names
  • fs – Field separator

Module contents


Note: A new GRASS GIS stable version has been released: GRASS GIS 7.4. Go directly to the new manual page here

Help Index | Topics Index | Keywords Index | Full Index

© 2003-2019 GRASS Development Team, GRASS GIS 7.2.4svn Reference Manual