Xns11
Xns11(self, file_path=None, *args, **kwargs)A class to read and write xns11 files.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| file_path | str | Path | full path and file name to the xns11 file. | None |
Notes
The Xns11 class is a subclass of CrossSectionCollection. The main difference is that Xns11 has a file_path property to track where the file was last loaded from or saved to.
Examples
# Open an existing file
>>> xns = Xns11("file.xns11")
# Overview of the cross sections
>>> xns.to_dataframe()
# Read a specific cross section
>>> xs = xns.sel(location_id='basin_left1', chainage='122.042', topo_id='1')
# Plot a cross section
>>> xs.plot()
# Access cross section raw data
>>> xs.raw_data
# Access cross section processed data
>>> xs.processed_dataAttributes
| Name | Description |
|---|---|
| chainages | Unique chainages in the collection (as string with 3 decimals). |
| cross_section_data | The DHI.Mike1D.CrossSectionModule.CrossSectionData object. |
| data | The DHI.Mike1D.CrossSectionModule.CrossSectionData object. |
| file_path | Full path and file name to the xns11 file. |
| interpolation_type | Defines how an interpolated cross section is interpolated. |
| location_ids | Unique location IDs in the collection. |
| topo_ids | Unique topo IDs in the collection. |
Methods
| Name | Description |
|---|---|
| add | Add a cross section to the collection. |
| from_cross_section_collection | Create a Xns11 object from a CrossSectionCollection. |
| get_supported_file_extensions | Get supported file extensions for Xns11. |
| plot | Plot all cross sections in the collection. |
| remove | Remove a cross section from 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_xns11 | Save the collection to an Xns11 file. |
| write | Write cross section data to an xns11 file. |
add
Xns11.add(cross_section)Add a cross section to the collection.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| cross_section | CrossSection | Cross section to add. | required |
from_cross_section_collection
Xns11.from_cross_section_collection(xsections)Create a Xns11 object from a CrossSectionCollection.
get_supported_file_extensions
Xns11.get_supported_file_extensions()Get supported file extensions for Xns11.
plot
Xns11.plot(*args, **kwargs)Plot all cross sections in the collection.
remove
Xns11.remove(cross_section)Remove a cross section from the collection.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| cross_section | CrossSection | Cross section to remove. | required |
sel
Xns11.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
| Name | Type | Description |
|---|---|---|
| CrossSection or list[CrossSection] | Providing all arguments will return a CrossSection. Provinding partial arguments will always return a list, even if it only includes one CrossSection. |
to_dataframe
Xns11.to_dataframe()Convert the collection to a DataFrame.
to_geopandas
Xns11.to_geopandas(mode='sections')Convert the collection to a GeoDataFrame.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| mode | str | Mode of conversion. Options are “sections” and “markers”. Default is “sections”. | 'sections' |
Returns
| Name | Type | Description |
|---|---|---|
| gpd.GeoDataFrame | GeoDataFrame with the cross sections or markers. |
Note:
This method requires the geopandas package to be installed. Cross sections must have defined coordinates.
to_xns11
Xns11.to_xns11(file_name, **kwargs)Save the collection to an Xns11 file.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| file_name | str or Path | Path to the file to save. | required |
Examples
>>> csc.to_xns11("cross_sections.xns11")write
Xns11.write(file_path=None)Write cross section data to an xns11 file.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| file_path | str | Path | Full file path of the xns11 file to be written. Default is the file_path used to open the file. | None |