2

I've seen in several web pages and examples the next snippet: gdal.Polygonize(band, maskband, polygonizedLayer, ndField, [], callback=None) but I don't understand how to use the options parameter. In the examples everybody uses this []. Could anybody explain me how to set connectness 8?

0

1 Answer 1

2

That function is not well documented. But looking at the C docs and the tests, I can see that it's a list of options and values as strings, i.e. ["option_name=value", "another_option=value"]. The only two options supported are

8CONNECTED=8: May be set to "8" to use 8 connectedness. Otherwise 4 connectedness will be applied to the algorithm

DATASET_FOR_GEOREF=dataset_name: Name of a dataset from which to read the geotransform.

So to set 8CONNECTED you would use use ["8CONNECTED=8"]:

gdal.Polygonize(band, maskband, polygonizedLayer, ndField, ["8CONNECTED=8"], callback=None)

To set both options, you would use use

["8CONNECTED=8", "DATASET_FOR_GEOREF=path/to/dataset"]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.