GeoSpace#
- class GeoSpace(crs='epsg:3857', *, warn_crs_conversion=True)[source]#
Space used to add a geospatial component to a model.
Create a GeoSpace for GIS enabled mesa modeling.
- Parameters:
crs – The coordinate reference system of the GeoSpace. If crs is not set, epsg:3857 (Web Mercator) is used as default. However, this system is only accurate at the equator and errors increase with latitude.
warn_crs_conversion – Whether to warn when converting layers and GeoAgents of different crs into the crs of GeoSpace. Default to True.
- to_crs(crs, inplace=False) GeoSpace | None [source]#
Transform the object to a new coordinate reference system.
- Parameters:
crs – The coordinate reference system to transform to.
inplace – Whether to transform the object in place or return a new object. Defaults to False.
- Returns:
The transformed object if not inplace.
- Return type:
GeoBase | None
- property transformer#
Return the pyproj.Transformer that transforms the GeoSpace into epsg:4326. Mainly used for GeoJSON serialization.
- property agents#
Return a list of all agents in the Geospace.
- property layers: list[ImageLayer | RasterLayer | GeoDataFrame]#
Return a list of all layers in the Geospace.
- property total_bounds: ndarray | None#
Return the bounds of the GeoSpace in [min_x, min_y, max_x, max_y] format.
- add_layer(layer: ImageLayer | RasterLayer | GeoDataFrame) None [source]#
Add a layer to the Geospace.
- Parameters:
layer (ImageLayer | RasterLayer | gpd.GeoDataFrame) – The layer to add.
- add_agents(agents)[source]#
Add a list of GeoAgents to the Geospace.
GeoAgents must have a geometry attribute. This function may also be called with a single GeoAgent.
- Parameters:
agents – A list of GeoAgents or a single GeoAgent to be added into GeoSpace.
- Raises:
AttributeError – If the GeoAgents do not have a geometry attribute.
- get_neighbors_within_distance(agent, distance, center=False, relation='intersects')[source]#
Return a list of agents within distance of agent.
Distance is measured as a buffer around the agent’s geometry, set center=True to calculate distance from center.