Programming examples
Tutorials for learning to program console applications with the Digi3D.AI Python API. Each topic starts with a practical goal and shows complete code.
For detailed class and method descriptions, see Reference. Each digi21.io format module also has a page with reading, creation and conversion examples: see digi21.io.
Topics
- Reading a drawing file: open a file and iterate over its geometries.
- Creating a drawing file: write geometries to a new file and convert formats.
- Creating a shapefile: write one layer per code and configure the codes table.
- Converting to GeoPackage: convert shapefile layers to GeoPackage.
- Exporting to KML and GeoJSON: write longitude and latitude for web viewers.
- Exporting to SVG, WKT and PDF: formats without a coordinate system.
- Exporting to VEC, IFC, GeoMedia and PostGIS: building faces and databases with existing layers.
- Creating geometries: construct points, lines, polygons, texts and complexes.
- Geometry relationships: query whether geometries cross, touch, contain one another, etc.
- Transforming coordinates with crskit: convert points between reference systems using Digi3D.AI's EPSG database, read a system's WKT and use Digi3D.AI-specific codes. Requires
crskit(pip install crskit).