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.2.2 (2022-11-29)

  • Decoding fix.

1.2.1 (2022-11-29)

  • Versioning support for schema 0210.

  • FID column fix.

  • Updated sideview example.

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.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.2-py3-none-any.whl (6.9 MB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: threedi-edits-1.2.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.2.tar.gz
Algorithm Hash digest
SHA256 911632d9d8f39c4271fdb3a9c6e8f365398b293f7400bac82db1453c748fe422
MD5 4b1c77bbf9d60e00430ca5c200760306
BLAKE2b-256 1561e52f1a9c1340339a91eccea780e4e5d930560e062f55c6182f4c810ab8ab

See more details on using hashes here.

File details

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

File metadata

  • Download URL: threedi_edits-1.2.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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c542179e931cf101c185cc1cb22a6c4eb61128e743b383029c4efb77c061cbbf
MD5 563476c0a3def8c13e4c0b294ecca40d
BLAKE2b-256 9da250452d3947f51e3be153a3e2a223cae7ee6b1f85f986a82057864159aa22

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