GeoAgent¶
GeoAgent and AgentCreator classes¶
- class mesa_geo.geoagent.AgentCreator(agent_class, model=None, crs=None, agent_kwargs=None)[source]¶
Create GeoAgents from files, GeoDataFrames, GeoJSON or Shapely objects.
- create_agent(geometry, unique_id)[source]¶
Create a single agent from a geometry and a unique_id. Shape must be a valid Shapely object.
- Parameters:
geometry – The geometry of the agent.
unique_id – The unique_id of the agent.
- Returns:
The created agent.
- Return type:
self.agent_class
- property crs¶
Return the coordinate reference system of the GeoAgents.
- from_GeoDataFrame(gdf, unique_id='index', set_attributes=True)[source]¶
Create a list of agents from a GeoDataFrame.
- Parameters:
gdf – The GeoDataFrame to create agents from.
unique_id – The column name of the data to use as the agents unique_id. If “index”, the index of the GeoDataFrame is used. Default to “index”.
set_attributes – Set agent attributes from GeoDataFrame columns. Default True.
- from_GeoJSON(GeoJSON, unique_id='index', set_attributes=True)[source]¶
Create agents from a GeoJSON object or string. CRS is set to epsg:4326.
- Parameters:
GeoJSON – The GeoJSON object or string to create agents from.
unique_id – The column name of the data to use as the agents unique_id. If “index”, the index of the GeoDataFrame is used. Default to “index”.
set_attributes – Set agent attributes from GeoDataFrame columns. Default True.
- from_file(filename, unique_id='index', set_attributes=True)[source]¶
Create agents from vector data files (e.g. Shapefiles).
- Parameters:
filename – The vector data file to create agents from.
unique_id – The column name of the data to use as the agents unique_id. If “index”, the index of the GeoDataFrame is used. Default to “index”.
set_attributes – Set agent attributes from GeoDataFrame columns. Default True.
- class mesa_geo.geoagent.GeoAgent(unique_id, model, geometry, crs)[source]¶
Base class for a geo model agent.
- advance() None¶
- property crs: CRS | None¶
Return the coordinate reference system of the object.
- property random: Random¶
- remove() None¶
Remove and delete the agent from the model.
- to_crs(crs, inplace=False) GeoAgent | 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 object in [min_x, min_y, max_x, max_y] format.
- Returns:
The bounds of the object in [min_x, min_y, max_x, max_y] format.
- Return type:
np.ndarray | None