GeoSpace¶
GeoSpace¶
- class mesa_geo.geospace.GeoSpace(crs='epsg:3857', *, warn_crs_conversion=True)[source]¶
Space used to add a geospatial component to a model.
- 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.
- add_layer(layer: ImageLayer | RasterLayer | GeoDataFrame) None[source]¶
Add a layer to the Geospace.
- Parameters:
layer (ImageLayer | RasterLayer | gpd.GeoDataFrame) – The layer to add.
- property agents¶
Return a list of all agents in the Geospace.
- property crs: CRS | None¶
Return the coordinate reference system of the object.
- get_agents_as_GeoDataFrame(agent_cls=<class 'mesa_geo.geoagent.GeoAgent'>) GeoDataFrame[source]¶
Extract GeoAgents as a GeoDataFrame.
- Parameters:
agent_cls – The class of the GeoAgents to extract. Default is GeoAgent.
- Returns:
A GeoDataFrame of the GeoAgents.
- Return type:
gpd.GeoDataFrame
- 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.
- get_relation(agent, relation)[source]¶
Return a list of related agents.
- Parameters:
agent (GeoAgent) – The agent to find related agents for.
relation (str) – The relation to find. Must be one of ‘intersects’, ‘within’, ‘contains’, ‘touches’.
- property layers: list[ImageLayer | RasterLayer | GeoDataFrame]¶
Return a list of all layers in the Geospace.
- 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 total_bounds: ndarray | None¶
Return the bounds of the GeoSpace in [min_x, min_y, max_x, max_y] format.
- property transformer¶
Return the pyproj.Transformer that transforms the GeoSpace into epsg:4326. Mainly used for GeoJSON serialization.