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
  • Thank you very much! I will wait for the HCMGIS ver 20.4.20. In ver 20.4.12 I get the message that the parametervalue of "input" is wrong..
    – Julz_Mos
    Commented Apr 22, 2020 at 6:19
  • 1
    Done! plugins.qgis.org/plugins/stable/… Commented Apr 22, 2020 at 9:02
  • Many thanks for the super fast support! Works perfectly!
    – Julz_Mos
    Commented Apr 22, 2020 at 9:11
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 you have read our privacy policy.

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