Skip to main content

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

threedi-edits-1.2.tar.gz (6.9 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

threedi_edits-1.2-py3-none-any.whl (6.9 MB view details)

Uploaded Python 3

File details

Details for the file threedi-edits-1.2.tar.gz.

File metadata

  • Download URL: threedi-edits-1.2.tar.gz
  • Upload date:
  • Size: 6.9 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.6

File hashes

Hashes for threedi-edits-1.2.tar.gz
Algorithm Hash digest
SHA256 9f918854b5bda4f86a0431bef7c798c2a156300d2ab15ef9c640586a95075791
MD5 43e99bb1a237d6e99add213e9137f32e
BLAKE2b-256 5dc335f0588edeb923d301df12a7856d89a73993e45285cbbcfe47e11a163796

See more details on using hashes here.

File details

Details for the file threedi_edits-1.2-py3-none-any.whl.

File metadata

  • Download URL: threedi_edits-1.2-py3-none-any.whl
  • Upload date:
  • Size: 6.9 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.6

File hashes

Hashes for threedi_edits-1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 7c09025d565356664735dab3211071e11e387d90f94a2bc58f654a08695f68a4
MD5 d46eea634c88caf01ede67fcc2d06fbb
BLAKE2b-256 59b5f5130bacb7d08361be6e8483dc9ea2b8cfb40ff6053933643373213bc1b9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page