An experimental pythonic 3Di schematisation api. Using this api, we can access, alter en write a 3Di database within python. Within the package gis tools are provided as well.
Project description
Threedi-edits
An experimental pythonic 3Di schematisation api. Using this api, we can access, alter en write a 3Di database within python. Within the package gis tools are provided as well. Currently version 0209 of the schematisation is supported. If your 3Di database is not up to date, please use: threedi_modelchecker (0.30) –sqlite path_to_sqlite.sqlite migrate to migrate your database to version 0209.
This package is the continuation of threedi-raster-edits (0.27)
Usage - 3Di schematisation edits
Importing the module:
>>> import threedi_edits as te
Creating a new schematisation:
>>> schema = te.ThreediEdits.from_scratch()
Basic schematisation reading:
>>> schema = te.ThreediEdits(sqlite_path, mode="read") >>> schema = te.ThreediEdits(sqlite_path, mode="memory")
Copying a schematisation:
>>> copied = schema.copy()
Writing a schematisation:
>>> schema.write(sqlite_output_path, rasters=True)
Investigate the data:
>>> cross_section_locations = schema.cross_section_locations >>> channels = schema.channels >>> print(cross_section_locations.first()) # show data of the first cross section location >>> print(schema.tables) # show all tables >>> shapely_geom = schema.channels.first().geometry.shape # retrieve the shapely geometry
Creating the grid:
>>> grid = schema.grid()
>>> cells = grid['cells']
>>> nodes = grid['nodes']
>>> lines = grid['lines']
>>> cells.write("path_to_lines.gpkg") # write cells only
>>> grid.write("path_to_grid.gpkg") # Write lines, cells and nodes
Adding a feature using a template:
>>> from te.globals import SUPPORTED_THREEDI_VERSIONS >>> from te.threedi.constants import get_version >>> templates = get_version(SUPPORTED_THREEDI_VERSIONS[0]).Templates() >>> node = templates.node >>> print(node) # show what you should fill >>> node["initial_waterlevel"] = 1 >>> node["the_geom"] = Point.from_point((1, 1)) >>> new_fid = schema.nodes.add(node)
Adding a feature using items and geometry:
>>> items = {"initial_waterlevel": 0.1, "storage_are": 0.64, "code": "x"}
>>> geometry = te.Point.from_point((1, 1))
>>> new_fid = schema.nodes.add(items=items, geometry=geometry)
Adding a feature using another feature:
>>> feature = other_schema.nodes.first() >>> new_fid = schema.add(feature)
Editing and writing rasters:
>>> schema.rasters # initialize rasters >>> dem = schema.dem >>> new_dem = dem.copy() >>> array = new_dem.array >>> array[0, 0] = 2 >>> new_dem.array = array >>> schema.dem = new_dem
For more examples:
>>> te.get_examples("example_folder")
Changelog of threedi-edits
1.0 (2022-11-15)
Evolution from threedi-raster-edits (v0.27)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file threedi-edits-1.1.tar.gz.
File metadata
- Download URL: threedi-edits-1.1.tar.gz
- Upload date:
- Size: 6.3 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
331d6b69e813da3618f659832e5b3b71f9a9acd955cc225807c6eac818192f28
|
|
| MD5 |
455bf12c53961c543cdd4f651820bbc9
|
|
| BLAKE2b-256 |
e199d60e7ac949f95af32d76260262fb58a4cb3f63f035c9dd4c386c38969443
|
File details
Details for the file threedi_edits-1.1-py_310-none-win_amd64.whl.
File metadata
- Download URL: threedi_edits-1.1-py_310-none-win_amd64.whl
- Upload date:
- Size: 6.4 MB
- Tags: Python _.310, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2a42a9cf8845d638a35ca172ad612fcf5082715c4f9af003c7a91f6f2351c5ca
|
|
| MD5 |
dcefe67e1f880945d857695283a0789f
|
|
| BLAKE2b-256 |
d052458059610aa2c94e9d86b9518b04af4c26a2e0181ee0756811dca1d880a3
|