Geography Utils

To make handling of mobility and geodata easier, trackintel features several geographic utility functions and distance functions for points and trajectories

Filtering

trackintel.geogr.spatial_filter(source, areas, method='within', re_project=False)[source]

Filter a GeoDataFrame on a geo extent. Using spatial indexing for improved performance.

Parameters:
  • source (GeoDataFrame) – The source feature to perform the spatial filtering

  • areas (GeoDataFrame) – The areas used to perform the spatial filtering. Note, you can have multiple Polygons and it will return all the features intersect with ANY of those geometries.

  • method ({'within', 'intersects', 'crosses'}, optional) –

    The method to filter the ‘source’ GeoDataFrame, by default ‘within’

    • within: return instances in ‘source’ where no points of these instances lies in the exterior of the ‘areas’ and at least one point of the interior of these instances lies in the interior of ‘areas’.

    • intersects: return instances in ‘source’ where the boundary or interior of these instances intersect in any way with those of the ‘areas’

    • crosses: return instances in ‘source’ where the interior of these instances intersects the interior of the ‘areas’ but does not contain it, and the dimension of the intersection is less than the dimension of the one of the ‘areas’.

  • re_project (bool, default False) – If this is set to True, the ‘source’ will be projected to the coordinate reference system of ‘areas’

Returns:

A new GeoDataFrame containing the features after the spatial filtering.

Return type:

GeoDataFrame

Examples

>>> sp.spatial_filter(areas, method="within", re_project=False)