sptemp1.1 – Python2.7

The ‘sptemp’-Package allows the representation of spatio-temporal vector data and provides classes and methods to process and analyse this type of data. The package provides classes to represent timestamped objects (TS_Object) and moving objects (Moving_Object), which are a sequence of timestamped objects and are additionally associated with an Interpolator. This Interpolator is used to determine the value of a moving object at a point in time where the moving object does not contain an actual observation, represented by a timestamped object.

_images/data_model.png

Class hierachy of the main classes provided by the sptemp-package

As subclasses of the TS_Object and Moving_Object classes, the package provides classes to represent different types of timestamped geometries and moving geometries. Moving geometries are a sequence of timestamped geometries associated with an Interpolator. The concept is, that at any point in time, the value of a moving geometry is either a geometry that is compliant to the Open Geospatial Consortium Simple Feature Model or an undefined value.

The package additionally provides a set of interpolation functions for interpolating values of the different types of Moving_Objects.

The package also provides the class SPT_DataFrame, which utilizes the pandas-library, to represent spatio-temporal data in a relational data structure.

Created by Daniel Baumann, baumann-dan@outlook.com
05.07.2019

zeit-module

This module contains classes to represent temporal data. It can be used without any third-party libraries, but if the method ‘from_iso()’ of the Time_Period class is used, the library dateutil must be installed.

Time_Period

class sptemp.zeit.Time_Period(start, end)

This class can be used to represent time periods with a closed lower and closed upper border.

>>> tp1 = Time_Period(datetime.datetime(2017, 07, 25, 20, 0, 0), datetime.datetime(2017, 07, 25, 20, 0, 20))
>>> tp2 = Time_Period(datetime.datetime(2017, 07, 25, 20, 0, 25), datetime.datetime(2017, 07, 25, 20, 0, 45))
start

start time instant of the time_period

Type:datetime.datetime
end

end time instant of the time_period

Type:datetime.datetime
__eq__(another)

Checks if Time_Period is equal to another Time_Period

Note

This method will not raise an error when ‘another’ is not of type sptemp.zeit.Time_Period but instead will return False

Parameters:another (sptemp.zeit.Time_Period) – another Time_Period
Returns:Returns True if another.start == self.start AND another.end == self.end, else returns False
Return type:bool
__gt__(another)

Checks if Time_Period lays after a time instant or a Time_Period

>>> tp1 > tp2
False
Parameters:another (datetime.datetime or sptemp.zeit.Time_Period) – another Time_Period or a time instant
Returns:If type(another) == datetime.datetime -> returns True if self.start > another, else returns False. If type(another) == sptemp.zeit.Time_Period -> returns True if self.start > another.end, else returns False
Return type:bool
Raises:TypeError – If type(another) != datetime.datetime AND type(another) != sptemp.zeit.Time_Period
__init__(start, end)
Parameters:
Raises:
  • TypeError – if start or end is not of type datetime.datetime
  • ValueError – if start is larger or equal to end
__lt__(another)

Checks if Time_Period lays before a time instant or a Time_Period

>>> tp1 < tp2
True
Parameters:another (datetime.datetime or sptemp.zeit.Time_Period) – another Time_Period or a time instant
Returns:If type(another) == datetime.datetime -> returns True if self.end < another, else returns False. If type(another) == sptemp.zeit.Time_Period -> returns True if self.end < another.start, else returns False
Return type:bool
Raises:TypeError – If type(another) != datetime.datetime AND type(another) != sptemp.zeit.Time_Period
__ne__(another)

Checks if Time_Period is not equal to another Time_Period

Note

This method will not raise an error when ‘another’ is not of type sptemp.zeit.Time_Period but instead will return True

Parameters:another (sptemp.zeit.Time_Period) – another Time_Period
Returns:Returns True if another.start != self.start OR another.end != self.end, else returns True
Return type:bool
after(another)

Checks if Time_Period lays after a time instant or a Time_Period

Parameters:another (datetime.datetime or sptemp.zeit.Time_Period) – another Time_Period or a time instant
Returns:If type(another) == datetime.datetime -> returns True if self.start > another, else returns False. If type(another) == sptemp.zeit.Time_Period -> returns True if self.start > another.end, else returns False
Return type:bool
Raises:TypeError – If type(another) != datetime.datetime AND type(another) != sptemp.zeit.Time_Period
before(another)

Checks if Time_Period lays before a time instant or a Time_Period

Parameters:another (datetime.datetime or sptemp.zeit.Time_Period) – another Time_Period or a time instant
Returns:If type(another) == datetime.datetime -> returns True if self.end < another, else returns False. If type(another) == sptemp.zeit.Time_Period -> returns True if self.end < another.start, else returns False
Return type:bool
Raises:TypeError – If type(another) != datetime.datetime AND type(another) != sptemp.zeit.Time_Period
contains(another)

Checks if Time_Period contains a time instant or a Time_Period

Parameters:another (datetime.datetime or sptemp.zeit.Time_Period) – another Time_Period or a time instant
Returns:If type(another) == datetime.datetime -> returns True if self.start < another AND self.end > another, else returns False. If type(another) == sptemp.zeit.Time_Period -> returns True if self.start < another.start and self.end > another.end, else returns False
Return type:bool
Raises:TypeError – If type(another) != datetime.datetime AND type(another) != sptemp.zeit.Time_Period
during(another)

Checks if Time_Period is lays during another Time_Period

Parameters:another (sptemp.zeit.Time_Period) – another Time_Period
Returns:Returns True if another.contains(self), else returns False.
Return type:bool
Raises:TypeError – if another is not of type sptemp.zeit.Time_Period
equals(another)

Checks if Time_Period is equal to another Time_Period

Parameters:another (sptemp.zeit.Time_Period) – another Time_Period
Returns:Returns True if another.start == self.start AND another.end == self.end, else returns False.
Return type:bool
Raises:TypeError – if another is not of type sptemp.zeit.Time_Period
classmethod from_iso(start, end)
>>> tp1 = Time_Period.from_iso("2017-07-25T22:00:00", "2017-07-25T22:00:20")
Parameters:
  • start (string) – start time_instant of the time_period in the iso8601 format
  • end (string) – end time_instant of the time_period in the iso8601 format
Raises:

ValueError – if start is larger or equal to end

Returns:

Return type:

sptemp.zeit.Time_Period

includes(another)

Checks if Time_Period includes a time instant or a Time_Period

Parameters:another (datetime.datetime or sptemp.zeit.Time_Period) – another Time_Period or a time instant
Returns:If type(another) == datetime.datetime -> returns True if self.start <= another AND self.end >= another, else returns False. If type(another) == sptemp.zeit.Time_Period -> returns True if self.start <= another.start and self.end >= another.end, else returns False
Return type:bool
Raises:TypeError – If type(another) != datetime.datetime AND type(another) != sptemp.zeit.Time_Period
meets(another)

Checks if Time_Period meets a time instant or a Time_Period

Parameters:another (datetime.datetime or sptemp.zeit.Time_Period) – another Time_Period or a time instant
Returns:If type(another) == datetime.datetime -> returns True if self.end == another, else returns False. If type(another) == sptemp.zeit.Time_Period -> returns True if self.end == another.start, else returns False
Return type:bool
Raises:TypeError – If type(another) != datetime.datetime AND type(another) != sptemp.zeit.Time_Period
metBy(another)

Checks if Time_Period is met by a time instant or a Time_Period

Parameters:another (datetime.datetime or sptemp.zeit.Time_Period) – another Time_Period or a time instant
Returns:If type(another) == datetime.datetime -> returns True if self.start == another, else returns False. If type(another) == sptemp.zeit.Time_Period -> returns True if self.start == another.end, else returns False
Return type:bool
Raises:TypeError – If type(another) != datetime.datetime AND type(another) != sptemp.zeit.Time_Period
overlappedBy(another)

Checks if Time_Period is overlapped by another Time_Period

Parameters:another (sptemp.zeit.Time_Period) – another Time_Period
Returns:Returns True if another.overlaps(self), else returns False.
Return type:bool
Raises:TypeError – if another is not of type sptemp.zeit.Time_Period
overlaps(another)

Checks if Time_Period overlaps another Time_Period

Parameters:another (sptemp.zeit.Time_Period) – another Time_Period
Returns:Returns True if self.start < another.start AND self.end > another.start AND self.end < another.end, else returns False.
Return type:bool
Raises:TypeError – if another is not of type sptemp.zeit.Time_Period

TS_Object

class sptemp.zeit.TS_Object(value, ts)

With this class timestamped objects can be represented. Any type of object can be timestamped with a datetime.datetime object or a sptemp.zeit.Time_Period object.

>>> ts1 = TS_Object(10, datetime.datetime(2018, 07, 25, 18, 31, 23))
>>> ts2 = TS_Object(True, Time_Period(datetime.datetime(1999, 04, 21, 7, 22, 50),datetime.datetime(1999, 04, 21, 7, 22, 55)))
value

value that is timestamped. Raises TypeError if new value is assigned that is not of the same type of the old value.

Type:object
ts

timestamp value -> immutable

Type:datetime.datetime or sptemp.zeit.Time_Period
type

type of the value, the TS_Object represents -> immutable

Type:type
__eq__(another)

Checks if the TS_Object is equal to another TS_Object

>>> ts1 == ts2
False

Note

This method will not raise an error when ‘another’ is not of type sptemp.zeit.TS_Object but instead will return False

Parameters:another (sptemp.zeit.TS_Object) – another TS_Object
Returns:Returns True if another.value == value AND another.ts == ts, else returns False
Return type:bool
__init__(value, ts)
Parameters:
Raises:

TypeError – if ts is not of type datetime.datetime or sptemp.zeit.Time_Period

__ne__(another)

Checks if the TS_Object is not equal to another TS_Object

>>> ts1 != ts2
True

Note

This method will not raise an error when ‘another’ is not of type sptemp.zeit.TS_Object but instead will return True

Parameters:another (sptemp.zeit.TS_Object) – another TS_Object
Returns:Returns True if another.value != value or another.ts != ts, else returns False
Return type:bool
end_time()

Returns the end time instant of the TS_Object -> if type(self.ts) == datetime.datetime -> self.start_time == self.end_time

Returns:Returns the end time instant of the TS_Object
Return type:datetime.datetime
start_time()

Returns the start time instant of the TS_Object -> if type(self.ts) == datetime.datetime -> self.start_time == self.end_time

Returns:Returns the start time instant of the TS_Object
Return type:datetime.datetime

TS_Unit

class sptemp.zeit.TS_Unit(value, ts)

Instances of this class represent a timestamped function. The class is a subclass of the sptemp.zeit.TS_Object class and inherits all attributes and methods

>>> tsu1 = TS_Unit(ICollection.linear,
... Time_Period(datetime.datetime(2017, 07, 25, 20, 0, 0), datetime.datetime(2017, 07, 25, 20, 0, 20)))
value

function that is timestamped.

Type:types.FuntionType
ts

timestamp value -> immutable

Type:sptemp.zeit.Time_Period
type

type of the value the TS_Object represents -> immutable

Type:type
__init__(value, ts)
Parameters:
  • value (types.FuntionType) – Object value to be timestamped
  • ts (sptemp.zeit.Time_Period) – timestamp for value
Raises:

TypeError – if value is not of type types.FuntionType OR ts is not of type sptemp.zeit.Time_Period

interpolate(start_ts, end_ts, time, *args)

Calls function assigned to TS_Unit to interpolate value based on start_ts and end_ts at time instant ‘time’

>>> tsp1 = TS_Object(10.0, datetime.datetime(2017, 07, 25, 20, 0, 5))
>>> tsp2 = TS_Object(20.0, datetime.datetime(2017, 07, 25, 20, 0, 15))
>>> tsu1.interpolate(tsp1, tsp2, datetime.datetime(2017, 07, 25, 20, 0, 7))
TS_Object(12.0, datetime.datetime(2017, 07, 25, 20, 0, 7))
Parameters:
Returns:

returns TS_Object with the value beeing the interpolated value

Return type:

sptemp.zeit.TS_Object or NoneType

Raises:
  • TypeError – if start_ts or end_ts is not of type sptemp.zeit.TS_Object OR if time is not of type datetime.datetime
  • ValueError – if self.ts does not include start_ts.end OR if self.ts does not include time

Interpolator

class sptemp.zeit.Interpolator(ts_unit_list)

With this class, a sequence of TS_Unit objects can be represented

>>> tsu1 = TS_Unit(ICollection.linear,
... Time_Period(datetime.datetime(2017, 07, 25, 20, 0, 0), datetime.datetime(2017, 07, 25, 20, 0, 10)))
>>> tsu2 = TS_Unit(ICollection.constant,
... Time_Period(datetime.datetime(2017, 07, 25, 20, 0, 10), datetime.datetime(2017, 07, 25, 20, 0, 20)))
>>> ip = Interpolator([tsu1, tsu2])
__delitem__(key)

Deletes first or last item of the object

Parameters:key (int) – the index
Raises:ValueError – If key is not 0 AND the key does not index the last item of the object OR if deletion would leave object beeing empty
__getitem__(key)
Parameters:key (int or slice) – the index
Returns:returns indexed part of ts_unit_list
Return type:sptemp.zeit.TS_Unit or list of sptemp.zeit.TS_Unit
__init__(ts_unit_list)
Parameters:

ts_unit_list (list of sptemp.zeit.TS_Unit) – List of TS_Unit objects. The end_time() of each TS_Unit object must be equal to the start_time() of the next TS_Unit object in the list. Thus there must be no gaps in time between the objects and no overlaps.

Raises:
  • ValueError – If empty list is passed or ts_unit_list is not correctly sorted
  • TypeError – If ts_unit_list contains values that are not of type sptemp.zeit.TS_Unit
__len__()
Returns:Returns number of sptemp.zeit.TS_Unit objects stored in Interpolator
Return type:int
__setitem__(key, value)
Parameters:
  • key (int) – the index
  • value (sptemp.zeit.TS_Unit) – new TS_Unit -> Must have same Time_Period as TS_Unit that it replaces
Raises:
  • TypeError – If key is not of type integer or value is not of type sptemp.zeit.TS_Unit
  • IndexError – If key is out of range
  • ValueError – If value.ts is not equal to ts of TS_Unit that will be replaced
append(value)
Parameters:

value (sptemp.zeit.TS_Unit) – TS_Unit Object that will be appended to Interpolator

Raises:
  • TypeError – If value is not of type sptemp.zeit.TS_Unit
  • ValueError – If value.start_time() != Interpolator.end_time()
as_list()
Returns:returns copy of ts_unit_list stored in Interpolator object
Return type:list of sptemp.zeit.TS_Unit
delete(time)

Deletes TS_unit elements from Interpolator

Parameters:

time (sptemp.zeit.Time_Period) – Time Period that will be deleted from Interpolator

Raises:
  • TypeError – If time is not of type sptemp.zeit.Time_Period
  • ValueError – If Time_Period covers the whole timespan of the Interpolator -> Deletion would leave Interpolator empty OR if ime is contained by the timespan of the Interpolator and thus the deletion would create a gap
end_time()
Returns:Returns end_time of last element of the ts_unit_list of the object
Return type:datetime.datetime
i_unit(i)
Parameters:i (int) – index for Interpolator
Returns:returns TS_Unit at position i in Interpolator sequence (Interpolator[i])
insert(value)

Insert TS_Unit object into Interpolator

Note

Existing values will be overwritten or ajusted

Parameters:

value (sptemp.zeit.TS_Unit) – TS_Unit that will be inserted into Interpolator

Raises:
  • TypeError – If value is not of type sptemp.zeit.TS_Unit
  • ValueError – If value.ts lays outside existing time-coverage of Interpolator
interpolate(start_ts, end_ts, time, *args)

Interpolates value based on start_ts and end_ts at time instant ‘time’

>>> tsp1 = TS_Object(10.0, datetime.datetime(2017, 07, 25, 20, 0, 5))
>>> tsp2 = TS_Object(20.0, datetime.datetime(2017, 07, 25, 20, 0, 15))
>>> ip.interpolate(tsp1, tsp2, datetime.datetime(2017, 07, 25, 20, 0, 12))
TS_Object(15.0, datetime.datetime(2017, 07, 25, 20, 0, 12))
Parameters:
  • start_ts (sptemp.zeit.TS_Object) – previous TS_Object of ‘time’
  • end_ts (sptemp.zeit.TS_Object) – next TS_Object of ‘time’
  • time (datetime.datetime) – time for which value will be interpolated
  • *args – arbitrary arguments that will be additionally passed to interpolation functions
Returns:

returns TS_Object with the value beeing the interpolated value

Return type:

sptemp.zeit.TS_Object or NoneType

Raises:
  • TypeError – if type of start_ts or end_ts is not sptemp.zeit.TS_Object OR if type of time is not datetime.datetime
  • ValueError – if start_ts.end_time() < self.start_time() OR time < start_ts.end_time() or time > end_ts.start_time() OR time < self.start_time() or time > self.end_time() OR start_ts.end_time() >= end_ts.end_time().
length()
Returns:Returns number of sptemp.zeit.TS_Unit objects stored in Interpolator
Return type:int
slice(time)
Parameters:time (sptemp.zeit.Time_Period) – Time_Period for which slice will be created
Returns:Returns time-slice of original Interpolator, returns None if slice of Interpolator is empty
Return type:sptemp.zeit.Interpolator or NoneType
Raises:TypeError – if type(time) != sptemp.zeit.Time_Period
start_time()
Returns:Returns start_time of first element of the ts_unit_list of the object
Return type:datetime.datetime
value(time)
Parameters:time (datetime.datetime) – Point in time for which value will be returned
Returns:If ‘time’ is end_time of one Ts_Unit and start_time of another TS_Unit, the return list will contain two elements, else the list will contain one element. If time < self.start_time() or time > self.end_time(), the method will return an empty list.
Return type:list of sptemp.zeit.TS_Unit
Raises:TypeError – if time is not of type datetime.datetime

Moving_Object

class sptemp.zeit.Moving_Object(ts_object_list, interpolator)

With this class a sequence of disjoint TS_Objects can be represented

>>> tsu1 = TS_Unit(ICollection.linear,
... Time_Period(datetime.datetime(2017, 07, 25, 20, 0, 0), datetime.datetime(2017, 07, 25, 20, 0, 10)))
>>> tsu2 = TS_Unit(ICollection.constant,
... Time_Period(datetime.datetime(2017, 07, 25, 20, 0, 10), datetime.datetime(2017, 07, 25, 20, 0, 20)))
>>> ip = Interpolator([tsu1, tsu2])
>>> tsp1 = TS_Object(10.0, datetime.datetime(2017, 07, 25, 20, 0, 5))
>>> tsp2 = TS_Object(20.0, datetime.datetime(2017, 07, 25, 20, 0, 15))
>>> mo1 = Moving_Object([tsp1, tsp2], ip)
interpolator

Interpolator associated with the Moving_Object

Type:sptemp.zeit.Interpolator
__delitem__(key)
Parameters:

key (int or slice) – index of TS_Objects that will be deleted

Raises:
  • TyperError – if key is not of type int or slice
  • ValueError – if deletion would leave Moving_Object empty
__getitem__(key)
Parameters:key (int or slice) – the index
Returns:returns indexed part of ts_object_list
Return type:sptemp.zeit.TS_Object or list of sptemp.zeit.TS_Object
__init__(ts_object_list, interpolator)
Parameters:
  • ts_object_list (list of sptemp.zeit.TS_Object) – time-sorted list of disjoint TS_Object instances
  • interpolator (sptemp.zeit.Interpolator) – Interpolator object that will be used to interpolate values of the Moving_Object
Raises:
  • TypeError – if ts_object_list is not of type list OR if ts_object_list contains objects that are nor of type sptemp.zeit.TS_Object OR interpolator is not of type sptemp.zeit.Interpolator
  • ValueError – if len(ts_object_list) == 0 OR TS_Objects do not all have the same type OR if timestamps of TS_Objects are not disjoint
__len__()
Returns:Returns number of sptemp.zeit.TS_Object instances stored in Moving_Object
Return type:int
__setitem__(key, value)
Parameters:
Raises:
  • TypeError – If key is not of type integer, if value is not of type sptemp.zeit.TS_Object
  • IndexError – If key is out of range
  • ValueError – If value.ts is not disjoint to existing Ts_Objects in Moving_Object or value.type != self.type
append(value)
Parameters:

value (sptemp.zeit.TS_Object) – TS_Object that will be appended to Moving_Object

Raises:
  • TypeError – If value is not of type sptemp.zeit.TS_Object
  • ValueError – If value.start_time() <= Moving_Object.end_time()
as_list()
Returns:returns copy of ts_object_list stored in Moving_Object
Return type:list of sptemp.zeit.TS_Object
delete(time)

Deletes TS_Objects from Moving_Object. All TS_Object of which the timestamps are contained in the Time_Period are deleted, overlapping timestamps are adjusted. If ts of TS_Object is adjusted -> TS_Object.end_time() == time.start or TS_Object.start_time() == time.end IF type(time) == datetime.datetime, TS_Object is only deleted if TS_Object.ts == time.

Parameters:

time (datetime.datetime or sptemp.zeit.Time_Period) – Time that will be deleted from Moving Object

Raises:
  • TypeError – If time is not of type sptemp.zeit.Time_Period
  • ValueError – If Time_Period covers the whole timespan of the Moving_Object -> Deletion would leave Moving_Object empty
end_time()
Returns:Returns end_time of last element of the ts_unit_list of the Moving_Object
Return type:datetime.datetime
i_object(i)
Parameters:i (int) – index for Moving_Object
Returns:returns TS_Object at position i in Moving_Object sequence (Moving_Object[i])
insert(value)

Insert value into Moving_Object

Note

In contrary to Interpolator objects -> Values will not be overwritten or adjusted

Parameters:

value (sptemp.zeit.TS_Object) – TS_Object that will be inserted into Moving_Object

Raises:
  • TypeError – If value is not of type sptemp.zeit.TS_Object
  • ValueError – If value.ts and timestamps of Ts_Objects in Moving Object are not disjoint or if value.type != self.type
interpolate(time, *args)
Parameters:
  • time (datetime.datetime) – point in time for which value of Moving_Object will be returned
  • *args – arbitrary arguments that will be passed to Interpolator
Returns:

If ‘time’ is included in the timestamps than than a TS_Object is returned with the corresponding value, and the ‘time’ as timestamp. If ‘time’ lays between the TS_Objects, than the associated Interpolator is used, to interpolate the value at this point in time. Returns None if time < self.start_time() or time > self.end_time() or interpolation function returned None

Return type:

sptemp.zeit.TS_Object or NoneType

Raises:
  • TypeError – if type time is not datetime.datetime.
  • ValueError – if TS_Object.type returned by Interpolator != self.type
length()
Returns:Returns number of sptemp.zeit.TS_Object instances stored in Moving_Object
Return type:int
next_i(time)
Parameters:time (datetime.datetime) – time for which index of next TS_Object will be returned.
Returns:returns index of TS_Object that lays directly after time. If time is equal to a ts of a TS_object or is inlcuded in the ts of a Ts_Object, than index of this TS_Object is returned. Returns None, if time > self.end_time().
Return type:int or None
prev_i(time)
Parameters:time (datetime.datetime) – time for which index of previous TS_Object will be returned.
Returns:returns index of TS_Object that lays directly before time. If time is equal to a ts of a TS_object or is inlcuded in the ts of a Ts_Object, than index of this TS_Object is returned. Returns None, if time < self.start_time().
Return type:int or None
resampled_slice(times, time_args=None)

Returns slice between first time instant of times and last time instant of times. If Moving_Object is not defined at time instants in ‘times’, the interpolator is used, and a TS_Object is inserted into the slice.

Parameters:
  • times (list of datetime.datetime) – List of time instants
  • time_args (sptemp.zeit.Moving_Object, optional) – Moving_Object, which holds timestamped lists, that define which args are passed to Interpolator, at which points in time.
Returns:

Returns resampled-slice of original Moving_Object. Returns None if slice is empty

Return type:

sptemp.zeit.Moving_Object or NoneType

Raises:
slice(time)
Parameters:time (sptemp.zeit.Time_Period) – Time_Period for which slice will be created
Returns:Returns time-slice of original Moving_Object, returns None if slice is empty
Return type:sptemp.zeit.Moving_Object or NoneType
Raises:TypeError – if type(time) != sptemp.zeit.Time_Period
start_time()
Returns:Returns start_time of first element of the ts_unit_list of the Moving_Object
Return type:datetime.datetime

moving_geometry-module

This module provides classes to represent timestamped geometry values as well as moving geometries. This module requires the third party library shapely.
The classes in the module allow the assignment of a coordinate reference system. If this option is used, the pyproj library must be installed.

TS_Geometry

class sptemp.moving_geometry.TS_Geometry(value, ts, crs=None)

With this class timestamped shapely.geometry objects can be represented. This class is a subclass of the sptemp.zeit.TS_Object class and inherits all its attributes and methods

>>> TS_Geometry(shapely.geometry.Point(10.2, 47.4, 460), datetime.datetime(2017, 07, 25, 20, 0, 0), crs=pyproj.Proj(init="epsg:4326"))
value

Geometry that is timestamped.

Type:shapely.geometry
ts

timestamp value -> immutable

Type:datetime.datetime or sptemp.zeit.Time_Period
type

type of the value the TS_Geometry represents

Type:type
has_z

True if value.has_z is True

Type:bool
crs

returns coordinate reference system of the Geometry

Type:pyproj.Proj or NoneType
__eq__(another)

Checks if the TS_Geometry is equal to another TS_Geometry

Note

This method will not raise an error when ‘another’ is not of type sptemp.zeit.TS_Geometry but instead will return False

Parameters:another (sptemp.zeit.TS_Point) – another TS_Geometry
Returns:Returns True if another.value == value AND another.ts == ts AND another.crs == self.crs, else returns False
Return type:bool
__init__(value, ts, crs=None)
Parameters:
  • value (shapely.geometry) – Geometry that is timestamped.
  • ts (datetime.datetime or sptemp.zeit.Time_Period) – timestamp for value
  • crs (pyproj.Proj, optional) – coordinate reference system of the TS_Geometry
Raises:
  • TypeError – if value is not of type shapely.geometry OR ts is not of type datetime.datetime or sptemp.zeit.Time_Period OR crs is not of type pyproj.Proj
  • ValueError – if shapely.geometry.is_empty is True
reproject(to_crs)

Transforms self.value into new coordinate system

Parameters:

to_crs (pyproj.Proj) – coordinate reference system to which the coordinates of the geometry are converted to

Raises:
  • TypeError – if to_crs is not of type pyproj.Proj
  • ValueError – if TS_Geometry has no coordinate reference system

TS_Point

class sptemp.moving_geometry.TS_Point(value, ts, crs=None)

Instances of this class represent a timestamped shapely.geometry.Point. This class is a subclass of the TS_Geometry class and inherits all its attributes and methods.

value

Point that is timestamped.

Type:shapely.geometry.Point
ts

timestamp value -> immutable

Type:datetime.datetime or sptemp.zeit.Time_Period
type

type of the value the TS_Point represents -> shapely.geometry.Point

Type:type
has_z

True if value.has_z is True

Type:bool
crs

returns coordinate reference system of the Point

Type:pyproj.Proj or NoneType
__init__(value, ts, crs=None)
>>> tsp1 = TS_Point(shapely.geometry.Point(20.4, 10.8, 560), datetime.datetime(2018, 07, 25, 18, 31, 23), pyproj.Proj(init="epsg:4326"))
Parameters:
  • value (shapely.geometry.Point) – Point that is timestamped.
  • ts (datetime.datetime or sptemp.zeit.Time_Period) – timestamp for value
  • crs (pyproj.Proj, optional) – coordinate reference system of the Point
Raises:
  • TypeError – if value is not of type shapely.geometry.Point OR ts is not of type datetime.datetime or sptemp.zeit.Time_Period OR crs is not of type pyproj.Proj
  • ValueError – if shapely.geometry.Point.is_empty is True

TS_LineString

class sptemp.moving_geometry.TS_LineString(value, ts, crs=None)

Instances of this class represent a timestamped shapely.geometry.LineString. The class is a subclass of the TS_Geometry class and inherits all its attributes and methods

value

LineString that is timestamped.

Type:shapely.geometry.LineString
ts

timestamp value -> immutable

Type:datetime.datetime or sptemp.zeit.Time_Period
type

type of the value the TS_LineString represents -> shapely.geometry.LineString

Type:type
has_z

True if value.has_z is True

Type:bool
crs

returns coordinate reference system of the LineString

Type:pyproj.Proj or NoneType
__init__(value, ts, crs=None)
Parameters:
  • value (shapely.geometry.LineString) – LineString that is timestamped.
  • ts (datetime.datetime or sptemp.zeit.Time_Period) – timestamp for the value
  • crs (pyproj.Proj, optional) – coordinate reference system of the LineString
Raises:
  • TypeError – if value is not of type shapely.geometry.LineString OR ts is not of type datetime.datetime or sptemp.zeit.Time_Period OR crs is not of type pyproj.Proj
  • ValueError – if shapely.geometry.LineString.is_empty is True

TS_LinearRing

class sptemp.moving_geometry.TS_LinearRing(value, ts, crs=None)

Instances of this class represent a timestamped shapely.geometry.LinearRing. The class is a subclass of the TS_LineString class and inherites all its attributes and methods

value

LinearRing that is timestamped.

Type:shapely.geometry.LinearRing
ts

timestamp value -> immutable

Type:datetime.datetime or sptemp.zeit.Time_Period
type

type of the value the TS_LinearRing represents -> shapely.geometry.LinearRing

Type:type
has_z

True if value.has_z is True

Type:bool
crs

returns coordinate reference system of the LinearRing

Type:pyproj.Proj or NoneType
__init__(value, ts, crs=None)
Parameters:
  • value (shapely.geometry.LinearRing) – LinearRing that is timestamped.
  • ts (datetime.datetime or sptemp.zeit.Time_Period) – timestamp for value
  • crs (pyproj.Proj, optional) – coordinate reference system of the LinearRing
Raises:
  • TypeError – if value is not of type shapely.geometry.LinearRing OR ts is not of type datetime.datetime or sptemp.zeit.Time_Period OR crs is not of type pyproj.Proj
  • ValueError – if shapely.geometry.LinearRing.is_empty is True

Moving_Geometry

class sptemp.moving_geometry.Moving_Geometry(ts_object_list, interpolator)

Abstract class that defines methods for all moving_geometry types. The class is a subclass of the sptemp.zeit.Moving_Object class and inherits all its attributes and methods.

interpolator

Interpolator associated with the Moving_Geometry

Type:sptemp.zeit.Interpolator
has_z

True if all TS_Geometries in Moving_Geometry have z-coordinates, else False.

Type:boolean
crs

coordinate reference system of the Ts_Geometries

Type:pyproj.Proj or NoneType
reproject(to_crs)

Transforms TS_Geometry objects in Moving_Geometry to new coordinate system

Parameters:

to_crs (pyproj.Proj) – coordinate reference system to which the Point coordinates are converted to

Raises:
within(another, td1, td2, args1=None, args2=None)

Tests at which points in time the Moving_Geometry lays within ‘another’ geometry.

Parameters:
  • another (shapely.geometry or TS_Geometry or Moving_Geometry or Moving_Collection) – Geometry for which it will be checked if Moving_Geometry lays within.
  • td1 (datetime.timedelta) – timedelta object defining at which temporal resolution, the predicate ‘within’ is checked
  • td2 (datetime.timedelta) – timedelta object defining at which temporal resolution, changes of the predicate ‘within’ will be checked
  • args1 (sptemp.zeit.Moving_Object, optional) – Moving Objects holding timestamped args values, defining which args are passed to interpolator of moving_geometry at which times. Moving_Object must hold timestamped lists, which contain the args.
  • args2 (sptemp.zeit.Moving_Object, optional) – Moving Objects holding timestamped args values, defining which args are passed to interpolator of another at which times. Moving_Object should hold timestamped lists, which hold the args, if isintance(another, Moving_Geometry).
    Moving_Object should hold timestamped dicts, which hold the args, if isintance(another, Moving_Collection). With the dict complying to the specifications of the Moving_Collection.interpolate() method.
Returns:

returns Moving_object with type == bool. The Moving_Object represents the points in time at which the Moving_Geometry lays within ‘another’. Returned Moving_Object is assigned a constant interpolation

Return type:

sptemp.zeit.Moving_Object

Raises:
  • TypeError – If type(another) not in [shapely.geometry, TS_Geometry, Moving_Geometry, Moving_Collection]
  • ValueError – If td1 or td2 are not positive or if td2 > td1

Moving_Point

class sptemp.moving_geometry.Moving_Point(ts_object_list, interpolator)

With this class a sequence of TS_Points can be represented. The class is a subclass of the Moving_Geometry class and inherits all its attributes and methods.

interpolator

Interpolator associated with the Moving_Point

Type:sptemp.zeit.Interpolator
has_z

True if all TS_Points in Moving Point have z-coordinates, else False.

Type:boolean
crs

coordinate reference system of the Ts_Points

Type:pyproj.Proj or NoneType
__init__(ts_object_list, interpolator)
Parameters:
  • ts_object_list (list of sptemp.zeit.TS_Point) – time-sorted list of disjoint TS_Point instances
  • Interpolator (sptemp.zeit.Interpolator) – Interpolator object that will be used to interpolate values of Moving_Point.
Raises:
  • TypeError – if ts_object_list is not of type list OR ts_object_list contains objects that are nor of type sptemp.moving_geometry.TS_Point OR interpolator is not of type sptemp.zeit.Interpolator
  • ValueError – if len(ts_object_list) == 0 OR if timestamps of TS_Points are not disjoint OR TS_Point.has_z of objects in ts_object_list is inconsistent OR TS_Point.crs of objects in ts_object_list is inconsistent.

Moving_LineString

class sptemp.moving_geometry.Moving_LineString(ts_object_list, interpolator)

With this class a sequence of TS_LineStrings can be represented. The class is a subclass of the Moving_Geometry class and inherits all its attributes and methods.

interpolator

Interpolator associated with the Moving_LineString

Type:sptemp.zeit.Interpolator
has_z

True if all TS_LineStrings in Moving_LineString have z-coordinates, else False.

Type:boolean
crs

coordinate reference system of the TS_LineStrings

Type:pyproj.Proj or NoneType
__init__(ts_object_list, interpolator)
Parameters:
  • ts_object_list (list of sptemp.zeit.TS_LineString) – time-sorted list of disjoint TS_LineString instances
  • Interpolator (sptemp.zeit.Interpolator) – Interpolator object that will be used to interpolate values of Moving_LineString.
Raises:
  • TypeError – if ts_object_list is not of type list OR if ts_object_list contains objects that are nor of type sptemp.zeit.TS_LineString or interpolator is not of type sptemp.zeit.Interpolator
  • ValueError – if len(ts_object_list) == 0 OR TS_LineStrings do not all have the same type OR if timestamps of TS_LineString are not disjoint

Moving_LinearRing

class sptemp.moving_geometry.Moving_LinearRing(ts_object_list, interpolator)

With this class a sequence of TS_LinearRings can be represented. The class is a subclass of the Moving_LineString class and inherits all its attributes and methods.

interpolator

Interpolator associated with the Moving_LinearRing

Type:sptemp.zeit.Interpolator
has_z

True if all TS_LinearRings in Moving_LinearRing have z-coordinates, else False.

Type:boolean
crs

coordinate reference system of the TS_LinearRings

Type:pyproj.Proj or NoneType
__init__(ts_object_list, interpolator)
Parameters:
  • ts_object_list (list of sptemp.zeit.TS_LinearRing) – time-sorted list of disjoint TS_LinearRing instances
  • Interpolator (sptemp.zeit.Interpolator) – Interpolator object that will be used to interpolate values of Moving_LinearRing.
Raises:
  • TypeError – if ts_object_list is not of type list ,if ts_object_list contains objects that are nor of type sptemp.zeit.TS_LinearRing or interpolator is not of type sptemp.zeit.Interpolator
  • ValueError – if len(ts_object_list) == 0 OR TS_LinearRings do not all have the same type OR if timestamps of TS_LinearRing are not disjoint

Moving_Collection

class sptemp.moving_geometry.Moving_Collection(moving_list)

With this class a collection of moving geometries can be represented.

Note

Objects stored in the collection are not copied. The user must manage the objects in the Moving_Collection.moving_list

moving_list

List of objects stored in Moving_Collection

Type:list
has_z

True if all objects in collection have z-coordinates, else False.

Type:boolean
crs

coordinate reference system of the objects stored in the collection

Type:pyproj.Proj or NoneType
__init__(moving_list)
Parameters:

moving_list (list) – List of objects of the types: Moving_Point, Moving_LineString and MovingPolygon

Raises:
  • ValueError – If moving_list is empty, if ‘has_z’ or ‘crs’ is not consistent among objects of moving_list .
  • TypeError – If moving list is not of type list OR object in moving_list is not of type: Moving_Point, Moving_LineString or MovingPolygon.
end_time()
Returns:Returns largest end_time of all objects in Moving_Collection.moving_list
Return type:datetime.datetime
interpolate(time, args_dict={})
Parameters:
  • time (datetime.datetime) – point in time for which value of Moving_Collection will be returned
  • args_dict (dict, optional) – dictionary with arbitrary arguments that will be passed to Interpolators of objects stored in collection. Keys in dictionary must correspond to position of objects in the Moving_Collection.moving_list. For Moving_Points and Moving_LineStrings the value should be a list holding the additional arguments, while for Moving_Polygons the value in the args_dict should be another args_dict, specifying which args should be passed to which LinearRing of the Moving_Polygon.
Returns:

Returns TS_Geometry with GeometryCollection as value and ‘time’ as timestamp. Returns None if time < self.start_time() or time > self.end_time() or interpolation function of all Moving_Geometries returned None

Return type:

sptemp.moving_geometry.TS_Geometry or NoneType

Raises:
  • TypeError – if type time is not datetime.datetime OR type arg_dict is not of type dict
  • ValueError – if crs of Moving_Collection is inconsistent
reproject(to_crs)

Transforms objects in moving_list into new coordinate reference system

Parameters:

to_crs (pyproj.Proj) – coordinate reference system to which the coordinates are converted to

Raises:
resampled_slice(times, time_args={})

Call resampled slice method of all object in the Moving_Collection

Parameters:
  • times (list of datetime.datetime) – List of time instants
  • time_args (dict) – dictionary holding index of moving_geometry in moving_list as key and Moving_Object that defines which additional arguments are passed to Interpolator at which points in time. For Moving_Polygons the value must be a dictionary holding the time_args Moving _Object for each Moving_LinearRing.
Returns:

Returns resampled-slice of original Moving_Collection returns None if resampled_slice method of all items in Moving_Collection return None

Return type:

sptemp.zeit.Moving_Collection or NoneType

Raises:
  • TypeError – if type of times is not list OR if type interpolator_dict is not of type dict
  • ValueError – if len(times) < 2
slice(time)
Parameters:time (sptemp.zeit.Time_Period) – Time_Period for which the slice will be created.
Returns:Calls slice method of all objects in Moving_Collection returns None if all slice of all objects in the collection are None
Return type:sptemp.zeit.Moving_Collection or NoneType
Raises:TypeError – if type(time) != sptemp.zeit.Time_Period
start_time()
Returns:Returns smallest start_time of all objects in Moving_Collection.moving_list
Return type:datetime.datetime

Moving_Polygon

class sptemp.moving_geometry.Moving_Polygon(exterior_ring, interior_rings=[])

With this class a collection of Moving_LinearRings can be represented which represent the rings of a moving polygon

Note

Objects stored in the collection are not copied. The user must manage the Moving_LinearRings of the Moving_Polygon

exterior_ring

exterior ring of the Moving_Polygon

Type:sptemp.moving_geometry.Moving_LinearRing
interior_rings

interior rings of the Moving_Polygon

Type:list of sptemp.moving_geometry.Moving_LinearRing, optional
has_z

True if all objects in collection have z-coordinates, else False.

Type:boolean
crs

coordinate reference system of the objects stored in the collection

Type:pyproj.Proj or NoneType
__init__(exterior_ring, interior_rings=[])
Parameters:
  • exterior_ring (sptemp.moving_geometry.Moving_LinearRing) – exterior ring of the Moving_Polygon
  • interior_rings (list of sptemp.moving_geometry.Moving_LinearRing, optional) – interior rings of the Moving_Polygon
Raises:

TypeError – if exterior_ring is not of type sptemp.moving_geometry.Moving_LinearRing OR interior_rings is not of type list OR interior_rings contains elements that are not of type sptemp.moving_geometry.Moving_LinearRing

end_time()
Returns:Returns end_time of exterior_ring
Return type:datetime.datetime
interpolate(time, args_dict={})
Parameters:
  • time (datetime.datetime) – point in time for which value of Moving_Polygon will be returned
  • args_dict (dict, optional) – dictionary holding arbitrary arguments for the Interpolators of the Moving_LinearRings stored in the collection. The args of the exterior ring should be stored under the key ‘exterior’ The args for the interior rings should have the index of the LinearRing in the interior_rings list as key.
Returns:

Returns TS_Geometry with Polygon as value and ‘time’ as timestamp. Returns None if time < self.start_time() or time > self.end_time() or interpolation function of exterior_ring returned None.

Return type:

sptemp.moving_geometry.TS_Geometry or NoneType

Raises:
  • TypeError – if type time is not of type datetime.datetime OR type of arg_dict is not dict
  • ValueError – if crs of Moving_Polygon is inconsistent
reproject(to_crs)

Transforms coordinates of Moving_LinearRings into new coordinate reference system

Parameters:

to_crs (pyproj.Proj) – coordinate reference system to which the coordinates are converted to

Raises:
resampled_slice(times, time_args={})

Returns Moving_Polygon, holding the resampled_slices of all Moving_LinearRings

Parameters:
  • times (list of datetime.datetime) – List of time instants
  • time_args (dict) – Dictionary holding Moving_Objects as values, defining which additional arguments are passed to the Interpolators of the Moving_LinearRings at which points in time. For the exterior_ring the key must be ‘exterior’, for the interior rings, the key must be the index of the Moving_LinearRing in the interior_rings list.
Returns:

Returns Moving_Polygon, holding the resampled_slices of all Moving_LinearRings. Returns None of resampled_slice method of all Moving_LinearRings returned None.

Return type:

sptemp.zeit.Moving_Polygon or NoneType

Raises:
slice(time)
Parameters:

time (sptemp.zeit.Time_Period) – Time_Period for which the slice will be created

Returns:

Calls slice method of all objects in Moving_Polygon. Returns None if slice of all objects in the collection returned None

Return type:

sptemp.zeit.Moving_Polygon or NoneType

Raises:
  • TypeError – if type(time) != sptemp.zeit.Time_Period
  • ValueError – if slice does not include any TS_LinearRings of the exterior ring
start_time()
Returns:Returns start_time of exterior_ring
Return type:datetime.datetime

Moving_MultiPoint

class sptemp.moving_geometry.Moving_MultiPoint(moving_list)

With this class a collection of Moving_Points can be represented

Note

Objects stored in the collection are not copied. The user must manage the objects in the Moving_Point.moving_list

moving_list

List of Moving_Point-objects

Type:list
has_z

True if all objects in collection have z-coordinates, else False.

Type:bool
crs

coordinate reference system of the objects stored in the collection

Type:pyproj.Proj or NoneType
__init__(moving_list)
Parameters:

moving_list (list) – List of Moving_Point-objects

Raises:
  • ValueError – If moving_list is empty, if ‘has_z’ or ‘crs’ is not consistent among objects of moving_list .
  • TypeError – If moving list is not of type list OR object in moving_list is not of type Moving_Point

Moving_MultiLineString

class sptemp.moving_geometry.Moving_MultiLineString(moving_list)

With this class a collection of Moving_LineStrings can be represented

Note

Objects stored in the collection are not copied. The user must manage the objects in the Moving_MultiLineString.moving_list

moving_list

List of objects stored in Moving_MultiLineString

Type:list
has_z

True if all objects in collection have z-coordinates, else False.

Type:boolean
crs

coordinate reference system of the objects stored in the collection

Type:pyproj.Proj or NoneType
__init__(moving_list)
Parameters:

moving_list (list) – List of Moving_LineString-objects

Raises:
  • ValueError – If moving_list is empty, if ‘has_z’ or ‘crs’ is not consistent among objects of moving_list .
  • TypeError – If moving list is not of type list OR object in moving_list is not of type Moving_LineString

Moving_MultiPolygon

class sptemp.moving_geometry.Moving_MultiPolygon(moving_list)

With this class a collection of Moving_Polygons can be represented

Note

Objects stored in the collections are not copied. The user must manage the objects in the Moving_MultiPolygon.moving_list

moving_list

List of objects stored in Moving_MultiPolygon

Type:list
has_z

True if all objects in collection have z-coordinates, else False.

Type:boolean
crs

coordinate reference system of the objects stored in the collection

Type:pyproj.Proj or NoneType
__init__(moving_list)
Parameters:

moving_list (listof sptemp.moving_geometry.Moving_Polygon) – List of Moving_Polygon-objects

Raises:
  • ValueError – If moving_list is empty, if ‘has_z’ or ‘crs’ is not consistent among objects of moving_list .
  • TypeError – If moving list is not of type list OR object in moving_list is not of type Moving_Polygon

interpolation-module

This module provides a set of classes which contain interpolation methods for specific types of temporal data.
The user can write his/her own interpolation functions.
Such a function should excpect these three parameters first:

  • start_ts (TS_Object): previous TS_Object
  • end_ts (TS_Object): next TS_Object
  • time (datetime.datetime): time for which value will be interpolated

The function can then have an arbitrary number of additional parameters.

ICollection

class sptemp.interpolation.ICollection

This class provides a collection of general interpolation functionality

static constant(start_ts, end_ts, time, *args)

Constant Movement where value of start_ts is returned

Parameters:
Returns:

a TS_Object is returned
TS_Object.ts = time
if time < end_ts.start_time(): TS_Object.value = start_ts
else: TS_Object.value = end_ts

Return type:

TS_Object or NoneType

static linear(start_ts, end_ts, time, *args)

Linear interpolation-function for numeric values

Note

Value of TS_Objects should be of numeric type!

Parameters:
Returns:

a TS_Object is returned
TS_Object.ts = time
TS_Object.value: interpolated value at ‘time’

Return type:

TS_Object

Raises:
  • ValueError – if start_ts.type != end_ts.type OR start_ts.end_time() >= end_ts.start_time().
  • TypeError – if type(time) != datetime.datetime
static next_ts(start_ts, end_ts, time, *args)

Constant Movement where value of end_ts is returned

Parameters:
Returns:

a TS_Object is returned
TS_Object.ts = time
if time > start_ts.end_time(): TS_Object.value = end_ts
else: TS_Object.value = start_ts

Return type:

TS_Object

static undefined(start_ts, end_ts, time, *args)
Parameters:
Returns:

Function always returns None

Return type:

NoneType

IPoint

class sptemp.interpolation.IPoint

This class provides interpolation functionality for TS_Point objects.

Note

The interpolation functionality provided by this class is only suited for cartesian coordinates.

static curve_point(start_ts, end_ts, time, curve)

Linear Interpolation between TS_Point objects, where the point follows the course defined by a LineString.

Parameters:
Returns:

TS_Point with ts = time

Return type:

sptemp.moving_geometry.TS_Point

Raises:
  • TypeError – if start_ts or end_ts is not of type sptemp.moving_object.TS_Point OR time is not of type datetime.datetime OR curve is not of type shapely.geometry.LineString
  • ValueError – If start_ts.end_time > end_ts.start_time() OR start_ts.has_z, end_ts.has_z and curve.has_z are not equal OR start_ts.crs != end_ts.crs OR time < start_ts.end_time() OR time > end_ts.start_time() OR start_ts.value is not equal to start point of curve OR end_ts.value is not equal to end point of curve
static linear_point(start_ts, end_ts, time, *args)

Linear Interpolation between TS_Point objects

Parameters:
Returns:

TS_Point with ts = time

Return type:

sptemp.moving_geometry.TS_Point

Raises:
  • TypeError – if start_ts or end_ts is not of type sptemp.moving_geometry.TS_Point OR time is not of type datetime.datetime
  • ValueError – If start_ts.has_z != end_ts.has_z OR if start_ts.end_time() > end_ts.start_time() OR if time < start_ts.end_time() OR if time > end_ts.start_time()

ICurve

class sptemp.interpolation.ICurve

This class provides interpolation functionality for TS_LineString objects.

Note

The interpolation functionality provided by this class is only suited for cartesian coordinates.

static basic_linear(start_ts, end_ts, time, s_type='angle')

Linear Interpolation between two LineStrings.

Note

only x- and y-coordinate values are taken into account for linestring simplification

Parameters:
Returns:

returns TS_Linestring with ts = time

Return type:

sptemp.moving_geometry.TS_LineString

Raises:
  • TypeError – if start_ts or end_ts is not of type sptemp.moving_object.TS_LineString OR time is not of type datetime.datetime
  • ValueError – If start_ts.has_z != end_ts.has_z OR if start_ts.end_time > end_ts.start_time() OR start_ts.crs != end_ts.crs OR time < start_ts.end_time() OR time > end_ts.start_time()

IRing

class sptemp.interpolation.IRing

This class provides interpolation functionality for TS_LinearRing objects.

Note

The interpolation functionality provided by this class is only suited for cartesian coordinates.

static basic_linear(start_ts, end_ts, time, s_type='angle')

Linear Interpolation of LinearRings.

Note

matching of control points only based on x and y-coordinates

Parameters:
Returns:

TS_LinearRing with ts = time

Return type:

sptemp.moving_geometry.TS_LinearRing

Raises:
  • TypeError – if start_ts or end_ts is not of type sptemp.moving_object.TS_LinearRing OR time is not of type datetime.datetime
  • ValueError – If start_ts.has_z != end_ts.has_z OR if start_ts.end_time > end_ts.start_time() OR start_ts.crs != end_ts.crs OR time < start_ts.end_time() OR time > end_ts.start_time()
static linear_translation(start_ts, end_ts, time)

Linear translation of start_ts.value towards end_ts.value.centroid. Shape of LinearRings of start_ts and end_ts should be equal.

Note

translation only based on x and y-coordinates

Parameters:
Returns:

TS_LinearRing with ts = time

Return type:

sptemp.moving_geometry.TS_LinearRing

Raises:
  • TypeError – if start_ts or end_ts is not of type sptemp.moving_object.TS_LinearRing OR time is not of type datetime.datetime
  • ValueError – If start_ts.has_z != end_ts.has_z OR if start_ts.end_time > end_ts.start_time() OR start_ts.crs != end_ts.crs OR time < start_ts.end_time() OR time > end_ts.start_time()

analysis-module

This modul requires the third-party libraries shapely and pandas to be installed.
For the usage of a coordinate reference system, the pyproj library must be installed.

SPT_DataFrame

With this class a spatio-temporal dataset can be represented with a relational data structure.

class sptemp.analysis.SPT_DataFrame(dataframe, crs=None)

This class represents a wrapper for a pandas.DataFrame containing spatio-temporal features. The class provides functionality to interpolate and slice the features. The pandas dataframe has to be managed by the user.

>>> geo = [TS_Point(shapely.geometry.Point(11, 10), datetime.datetime(2017, 07, 25, 20, 0, 2)),
... TS_Point(shapely.geometry.Point(10, 15), datetime.datetime(2017, 07, 25, 20, 0, 5)),
... TS_Point(shapely.geometry.Point(11, 21), datetime.datetime(2017, 07, 25, 20, 0, 4)),
... TS_Point(shapely.geometry.Point(11.5, 23.1), Time_Period(datetime.datetime(2017, 07, 25, 20, 0, 0), datetime.datetime(2017, 07, 25, 20, 0, 20)))]
>>> row_id = ["a", "b", "c", "d"]
>>> df = pandas.DataFrame({"id":row_id, "geometry":geo})
>>> SPT_DataFrame(df)
dataframe

the pandas dataframe associated with the SPT_DataFrame

Type:pandas.DataFrame
crs

The coordinate reference system of the geometries stored in the dataframe. Only relevant if geometries are of type ‘shapely.geometry’.

Type:pyproj.Proj or NoneType
geometry_type

Type of the objects in the geometry column, returns None if dataframe is empty

Type:type or NoneType
__init__(dataframe, crs=None)

Note

The columns of the dataframe should only contain objects of one type!

Parameters:
  • dataframe (pandas.dataframe) – the pandas dataframe associated with the SPT_DataFrame. The geometries of the dataframe must be stored in a column named “geometry”. The geometry column can contain objects of all TS_Geometry-classes, all shapely.geometry classes and all Moving_Geometry Classes
  • crs (pyproj.Proj or NoneType) – The coordinate reference system of the geometries stored in the dataframe. Only relevant if geometries are represented as shapely.geometry objects.
Raises:
  • TypeError – if dataframe is not of type pandas.Dataframe OR if crs not of type pyproj.Proj Or if geometry column does contain data that is not of type TS_Geometry, shapely.geometry or Moving_Point, Moving_LineString, Moving_Linear_Ring or Moving_Collection
  • ValueError – if dataframe does not contain a column named ‘geometry’
interpolate(time, args_dict={})
Parameters:
  • time (datetime.datetime) – time for which values will be interpolated
  • args_dict (dict, optional) – Dictionary holding the args that will be passed two interpolators. The keys of the dictionary should correspond to the index of the relevant row. The values should be dictionaries, in which the keys identify the column name of the object. For Moving_Objects the value should be a list holding the args, For Moving_Collections the value should be an args_dict that is specific to the interpolated object type.
Returns:

dataframe with interpolated values

Return type:

sptemp.analysis.SPT_DataFrame

Raises:

TypeError – If time not of type datetime.datetime OR if args in args_dict not of type dict or of type list

reproject(to_crs)

Transforms coordinate values in dataframe into new coordinate system

Parameters:

to_crs (pyproj.Proj) – coordinate reference system to which the coordinates are converted to

Raises:
  • TypeError – if to_crs is not of type pyproj.Proj
  • ValueError – if geometry column holds values of type shapely.geometry and self.crs is None
resampled_slice(times, time_args={})

Returns slice between first time instant of times and last time instant of times. Calls resampled slice method of all Moving_Objects in dataframe

Parameters:
  • times (list of datetime.datetime) – List of time instants
  • time_args (dict, optional) – Dictionary holding the time_args that will be passed two Interpolators. The keys of the dictionary should correspond to the index of the relevant row. The values should be dictionaries, in which the keys identify the column name of the object. The value then should be a Moving_Object for Moving_Objects and Moving_Geometries and for Moving_Collection it should be a dictionary holding Moving_Objects.
Returns:

Returns resampled-slice of original DataFrame, returns None if slice is empty.

Return type:

sptemp.analysis.SPT_DataFrame or None

Raises:
slice(time)
Parameters:time (sptemp.zeit.Time_Period) – time period for which slice will be returned
Returns:dataframe with sliced values
Return type:sptemp.analysis.SPT_DataFrame
Raises:TypeError – if time not of type sptemp.zeit.Time_Period