services module
- geourban.services.aggregate(client: GeoRapidClient, region_code: str, simulation_datetime: datetime, vehicle_type: VehicleType, grid_type: GridType, out_format: OutFormat = OutFormat.GEOJSON)
Returns a spatially enabled traffic grid representing aggregated simulated movements of pedestrians, bikes and cars.
- Parameters:
client (
georapid.client.GeoRapidClient) – The client instance to use for this query.region_code (str) – The simulations endpoint returns all available urban regions. You have to use the region code, e.g. DEA22 for the city of Bonn, Germany.
simulation_datetime (
datetime.datetime) – Represents the simulated start time. The simulations endpoint list the available urban regions with their simulation dates. The time must be defined using the simulation date and the time being on the hour, e.g. 2023-08-24T07:00:00.vehicle_type (
geourban.types.VehicleType) – Car, Bike and Pedestrian are possible vehicle types.grid_type (
geourban.types.GridType) – The values agent, speed and emissions are supported grid types. agent: The number of unique agents is calculated. speed: The speed average of every agent is calculated. emissions: The sum of carbon dioxide emissions of every agent is calculated. This makes only sense for vehicle being cars!out_format (
geourban.formats.OutFormat, optional) – The output format. Defaults to OutFormat.GEOJSON.
- Returns:
The JSON response from the geourban service.
- Return type:
Example:
from datetime import datetime from georapid.client import GeoRapidClient from georapid.factory import EnvironmentClientFactory from geourban.services import aggregate from geourban.types import GridType, VehicleType host = 'geourban.p.rapidapi.com' client: GeoRapidClient = EnvironmentClientFactory.create_client_with_host(host) simulation_datetime: datetime = datetime(2023, 8, 24, 8, 0, 0) region_code: str = 'DEA22' vehicle_type: VehicleType = VehicleType.CAR grid_type: GridType = GridType.AGENT aggregated_traffic_grid_cells = aggregate(client, region_code, simulation_datetime, vehicle_type, grid_type)
- geourban.services.query(client: GeoRapidClient, simulation_datetime: datetime, vehicle_type: VehicleType, latitude: float, longitude: float, seconds: int = 60, meters: float = 500, out_format: OutFormat = OutFormat.GEOJSON)
Queries the simulated agent positions in space and time. Returns all positions within a certain radius of a given location and within a certain time frame.
- Parameters:
client (
georapid.client.GeoRapidClient) – The client instance to use for this query.simulation_datetime (
datetime.datetime) – The datetime of the simulation.vehicle_type (
geourban.types.VehicleType) – Car, Bike and Pedestrian are possible vehicle types.latitude (float) – The latitude of the location to query.
longitude (float) – The longitude of the location to query.
seconds (int, optional) – The time frame in seconds. Defaults to 60.
meters (float, optional) – The radius in meters. Defaults to 500.
out_format (
geourban.formats.OutFormat, optional) – The output format. Defaults to OutFormat.GEOJSON.
- Raises:
ValueError – If latitude is not in the range of [-90.0, 90.0].
ValueError – If longitude is not in the range of [-180.0, 180.0].
ValueError – If seconds is not in the range of [1, 120].
ValueError – If meters is not in the range of [1.0, 1000.0].
- Returns:
The JSON response from the geourban service.
- Return type:
Example:
from datetime import datetime from georapid.client import GeoRapidClient from georapid.factory import EnvironmentClientFactory from geourban.services import query from geourban.types import VehicleType host = 'geourban.p.rapidapi.com' client: GeoRapidClient = EnvironmentClientFactory.create_client_with_host(host) simulation_datetime: datetime = datetime(2023, 8, 24, 8, 45, 0) vehicle_type: VehicleType = VehicleType.CAR (latitude, longitude) = (50.746708, 7.074405) (seconds, meters) = (120, 1000) agent_positions = query(client, simulation_datetime, vehicle_type, latitude, longitude, seconds, meters)
- geourban.services.simulations(client: GeoRapidClient)
Returns all the available simulations using the urban region and the simulation date. The client instance must refer to a valid geourban services host like ‘geourban.p.rapidapi.com’.
- Parameters:
client (
georapid.client.GeoRapidClient) – The client instance to use for this query.- Returns:
The JSON response from the geourban service.
- Return type:
Example:
from georapid.client import GeoRapidClient from georapid.factory import EnvironmentClientFactory from geourban.services import simulations host = 'geourban.p.rapidapi.com' client: GeoRapidClient = EnvironmentClientFactory.create_client_with_host(host) urban_simulations = simulations(client)
- geourban.services.top(client: GeoRapidClient, region_code: str, simulation_date: date, vehicle_type: VehicleType, grid_type: GridType, limit: int = 10, out_format: OutFormat = OutFormat.GEOJSON)
Returns the top most accumulated traffic grid cells for an urban region.
- Parameters:
client (
georapid.client.GeoRapidClient) – The client instance to use for this query.region_code (str) – The simulations endpoint returns all available urban regions. You have to use the region code, e.g. DEA22 for the city of Bonn, Germany.
simulation_date (
datetime.date) – Represents the simulated date. The simulations endpoint list the available urban regions with their simulation dates. The date must be defined using ISO format, e.g. 2023-08-24.vehicle_type (
geourban.types.VehicleType) – Car, Bike and Pedestrian are possible vehicle types.grid_type (
geourban.types.GridType) – The values agent, speed and emissions are supported grid types. agent: The number of unique agents is calculated. speed: The speed average of every agent is calculated. emissions: The sum of carbon dioxide emissions of every agent is calculated. This makes only sense for vehicle being cars!limit (int, optional) – The maximum number of returned features. Defaults to 10.
out_format (
geourban.formats.OutFormat, optional) – The output format. Defaults to OutFormat.GEOJSON.
- Returns:
The JSON response from the geourban service.
- Return type:
Example:
from datetime import date from georapid.client import GeoRapidClient from georapid.factory import EnvironmentClientFactory from geourban.services import top from geourban.types import GridType, VehicleType host = 'geourban.p.rapidapi.com' client: GeoRapidClient = EnvironmentClientFactory.create_client_with_host(host) simulation_date: date = date(2023, 8, 24) region_code: str = 'DEA22' vehicle_type: VehicleType = VehicleType.CAR grid_type: GridType = GridType.AGENT top_traffic_grid_cells = top(client, region_code, simulation_date, vehicle_type, grid_type)