cross_sections.CrossSectionCollection
cross_sections.CrossSectionCollection(self, *args, **kwargs)
A collection of CrossSection objects.
The collection is a dict-like object where the keys are tuples of location ID, chainage and topo ID.
Parameters
Name | Type | Description | Default |
---|---|---|---|
args |
list of CrossSection | A list of CrossSection objects. | () |
Examples
>>> from mikeio1d.cross_sections import CrossSectionCollection, CrossSection
>>> x = [0, 1, 2, 3, 4, 5]
>>> z = [0, 1, 2, 3, 4, 5]
>>> xs1 = CrossSection.from_xz(x, z, location_id="loc1", chainage=100, topo_id="topo1")
>>> xs2 = CrossSection.from_xz(x, z, location_id="loc2", chainage=200, topo_id="topo1")
>>> csc = CrossSectionCollection([xs1, xs2])
# csc is a collection of two cross sections
Attributes
Name | Description |
---|---|
chainages | Unique chainages in the collection (as string with 3 decimals). |
location_ids | Unique location IDs in the collection. |
topo_ids | Unique topo IDs in the collection. |
Methods
Name | Description |
---|---|
add_xsection | Add a cross section to the collection. |
plot | Plot all cross sections in the collection. |
sel | Select cross sections from the collection. |
to_dataframe | Convert the collection to a DataFrame. |
to_geopandas | Convert the collection to a GeoDataFrame. |
to_geopandas_markers | Convert the collection to a GeoDataFrame of the markers as points. |
add_xsection
cross_sections.CrossSectionCollection.add_xsection(xsection)
Add a cross section to the collection.
plot
cross_sections.CrossSectionCollection.plot(*args, **kwargs)
Plot all cross sections in the collection.
sel
cross_sections.CrossSectionCollection.sel(location_id=..., chainage=..., topo_id=...)
Select cross sections from the collection.
Parameters
Name | Type | Description | Default |
---|---|---|---|
location_id |
str | Location ID of the cross section. | ... |
chainage |
str | float | Chainage of the cross section. | ... |
topo_id |
str | Topo ID of the cross section. | ... |
Returns
Type | Description |
---|---|
CrossSection or list of CrossSection | Providing all arguments will return a CrossSection. Provinding partial arguments will always return a list, even if it only has one CrossSection. |
to_dataframe
cross_sections.CrossSectionCollection.to_dataframe()
Convert the collection to a DataFrame.
to_geopandas
cross_sections.CrossSectionCollection.to_geopandas()
Convert the collection to a GeoDataFrame.
Note:
This method requires the geopandas package to be installed. Cross sections must have defined coordinates.
to_geopandas_markers
cross_sections.CrossSectionCollection.to_geopandas_markers()
Convert the collection to a GeoDataFrame of the markers as points.