0

I use QGIS 3.10 (Python 3.7 via the console) and want to automate a few processes through a Python script (I'm a beginner in programming with Python). I have a layer with many polygons ('polygons') and want to create the centerline between them. When I do this step without a script I use the HCMGIS plugin --> "Geometry Processing" --> "Centerline in polygons' gaps". How can I call this function in my script?

2 Answers 2

2

In HCMGIS ver 20.4.20 (approved soon), try this in QGIS Console:

from HCMGIS.hcmgis_library import *
input = "D:\\osm\\block.shp" # your polygon input
output = "D:\\osm\\centerline.shp" #  your centerline output in .sqlite, .shp, .geojson, .gpkg,  or kml
hcmgis_centerline(input, 1, True, 2,output,status_callback = None)
##hcmgis_centerline(layer,density,chksurround,distance,output,status_callback = None):
##density (float value): densify geometries with given an interval (in this case the density is 1 meter). Smaller density value returns smoother centerline but slower
##chksurround: if chksurround is True, then the function will also create a surrounding 'centerline' with a "distance" to the bounding box of building block

You can also call other functions of HCMGIS Plugin Library in QGIS Python Console or even in stand alone PyQGIS application in HCMGIS Plugin Library Call

Call QGIS Plugin Library in QGIS Pythong Console

3
1

I'm going to upload new version of HCMGIS Plugin and I will show u how to call HCMGIS function in QGIS Python console or PyQGIS as soon as it's approved on HCMGIS Plugin repo.

0

Your Answer

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

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