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?
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