hydromt_wflow.components.WflowGeomsComponent#
Summary of Methods and Attributes#
Component class |
Methods |
Attributes |
|---|---|---|
|
|
- class WflowGeomsComponent(model: Model, *, filename: str = 'staticgeoms/{name}.geojson', region_component: str | None = None, region_filename: str = 'staticgeoms/geoms_region.geojson')[source]#
Bases:
GeomsComponentWflow Geoms Component to manage spatial geometries.
It extends the base GeomsComponent from hydromt and consists of a dictionary of geopandas GeoDataFrames.
- read(folder: str = 'staticgeoms')[source]#
Read static geometries and adds to
geoms.If
dir_inputis set in the config, the path where all static geometries are read, will be constructed as<model_root>/<dir_input>/<geoms_fn>. Where <dir_input> is relative to the model root. Depending on the config valuedir_input, the path will be constructed differently.- Parameters:
folder (str, optional) – Folder name/path where the static geometries are stored relative to the model root and
dir_inputif any. By default “staticgeoms”.
- write(folder: str = 'staticgeoms', to_wgs84: bool = False, precision: int | None = None, **kwargs) None[source]#
Write model geometries to vector file(s) (by default GeoJSON) at <dir_out>/*.geojson.
Checks the path of
geoms_fnusing both model root anddir_input. If not found uses the default pathstaticgeomsin the root folder.Key-word arguments are passed to
geopandas.GeoDataFrame.to_file()- Parameters:
folder (Path, optional) – The directory to write the geometry files to. If it does not exist, it will be created.
to_wgs84 (bool, optional) – If True, the geoms will be reprojected to WGS84(EPSG:4326) before being written.
precision (int, optional) – The precision to use for writing the geometries. If None, it will be set to 1 for projected CRS and 6 for geographic CRS.
**kwargs (dict) – Additional keyword arguments that are passed to the geopandas.to_file function.
- get(name: str) GeoDataFrame | GeoSeries[source]#
Get geometry by name.
- pop(name: str) GeoDataFrame | GeoSeries[source]#
Remove and return geometry by name.
- test_equal(other: ModelComponent) tuple[bool, dict[str, str]][source]#
Test if two GeomsComponents are equal.
- property bounds: Tuple[float, float, float, float] | None#
Return the total bounds of the model region.
- property data: Dict[str, GeoDataFrame | GeoSeries]#
Model geometries.
Return dict of geopandas.GeoDataFrame or geopandas.GeoSeries
- property data_catalog: DataCatalog#
Return the data catalog of the model this component is associated with.
- finish_write()#
Finish the write functionality after cleanup was called for all components in the model.
All DeferredFileClose objects can overwrite any lazy loaded files now.
- property model: Model#
Return the model object this component is associated with.
- property region: GeoDataFrame | None#
Provide access to the underlying GeoDataFrame data of the model region.
- property root: ModelRoot#
Return the root of the model this component is associated with.
- set(geom: GeoDataFrame | GeoSeries, name: str)#
Add data to the geom component.
- Parameters:
geom (geopandas.GeoDataFrame or geopandas.GeoSeries) – New geometry data to add
name (str) – Geometry name.
- write_region(filename: str | None = None, *, to_wgs84: bool = False, to_file_kwargs: dict[str, Any] | None = None) None#
Write the model region to file.
The region is an auxiliary file that is often not required by the model, but can be useful for getting data from the data catalog. Plugin implementors may choose to write this file on write for a specific component.
- Parameters:
filename (str, optional) – The filename to write the region to. If None, the filename provided at initialization is used.
to_wgs84 (bool) – If True, the region is reprojected to WGS84 before writing.
to_file_kwargs (dict, optional) – Additional keyword arguments passed to the geopandas.GeoDataFrame.to_file function.