Breakline Mapping

23 views
Skip to first unread message

Michael Humphrey

unread,
Jun 15, 2023, 9:21:12 AM6/15/23
to WhiteboxTools
I am new to Python and I am having trouble with the breakline mapping in WBW Pro.
The error appears to related to the shapefile output. I tried to define the output file in a couple of different ways, but I am missing something.  I would appreciate any help. Thanks,
Here is the error and an example:
error: "thread '<unnamed>' panicked at 'Error adding part to ShapefileGeometry. Points and measures array must be equal length.', src\data_structures\shapefile\geometry.rs:503:13"

import whitebox_workflows as wbw
from whitebox_workflows import AttributeField, FieldData, FieldDataType, VectorGeometryType

wbe = wbw.WbEnvironment()
wbe.verbose = True
wbe.max_procs = -1
dem = wbe.read_raster('path to raster')
out_configs = wbe.read_vector('path to shapefile')
output1 = wbe.new_vector(VectorGeometryType.PolyLineZ, None, proj=out_configs.projection)
wbe.working_directory = 'path to directory'
print("Performing Feature Preserving Smoothing Tool")
wbe.breakline_mapping(
dem,
    threshold=3.0,
min_length=2
)
wbe.write_vector(output1, file_name='smooth.shp')

thread '<unnamed>' panicked at 'Error adding part to ShapefileGeometry. Points and measures array must be equal length.', src\data_structures\shapefile\geometry.rs:503:13

Whitebox Geospatial Inc

unread,
Jun 15, 2023, 9:28:20 AM6/15/23
to Michael Humphrey, WhiteboxTools

Hello Michael,

 

Your script has a few oddities with it. Can you try the following, being sure to update your working directory and DEM file names as appropriate:

 

import whitebox_workflows as wbw

 

wbe = wbw.WbEnvironment()

wbe.verbose = True

wbe.working_directory = 'path of working directory goes here'

 

dem = wbe.read_raster('name of raster file goes here')

output1 = wbe.breakline_mapping(

    dem,

    threshold=3.0,

    min_length=2

)

wbe.write_vector(output1, file_name='breaklines.shp')

 

Of particular note, unlike with WhiteboxTools, Whitebox Workflows for Python functions take in-memory data objects (in this case a raster) and output in-memory data objects (in this case a vector). I hope that helps to resolve your issue.

 

Regards,

 

John

--
You received this message because you are subscribed to the Google Groups "WhiteboxTools" group.
To unsubscribe from this group and stop receiving emails from it, send an email to whiteboxtool...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/whiteboxtools/c7c52d39-57a3-45b6-93a8-605abfd1dd9fn%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages