Input/Output¶
We primarily support two types of data ingestion:
- From CSV files.
- From PostGIS databases.
CSV File Import¶
-
trackintel.io.file.
read_positionfixes_csv
(*args, **kwargs)¶ Wraps the pandas read_csv function, extracts longitude and latitude and builds a geopandas GeoDataFrame. This also validates that the ingested data conforms to the trackintel understanding of positionfixes. See Model.
Returns: - GeoDataFrame
A GeoDataFrame containing the positionfixes.
PostGIS Import¶
-
trackintel.io.postgis.
read_positionfixes_postgis
(conn_string, table_name, *args, **kwargs)¶ Reads positionfixes from a PostGIS database.
Parameters: - conn_string : str
A connection string to connect to a database, e.g.,
postgresql://username:password@host:socket/database
.- table_name : str
The table to read the positionfixes from.
Returns: - GeoDataFrame
A GeoDataFrame containing the positionfixes.
-
trackintel.io.postgis.
write_positionfixes_postgis
(positionfixes, conn_string, table_name)¶ Stores positionfixes to PostGIS. Usually, this is directly called on a positionfixes dataframe (see example below).
Attention! This replaces the table if it already exists!
Parameters: - positionfixes : GeoDataFrame
The positionfixes to store to the database.
- conn_string : str
A connection string to connect to a database, e.g.,
postgresql://username:password@host:socket/database
.- table_name : str
The name of the table to write to.
Examples
>>> df.as_positionfixes.to_postgis(conn_string, table_name)