0

I cannot understand if and how I can call with its parameters a GRASS function like v.transform through a Python script from e.g. PyCharm etc. Is there something comprehensible to understand? An example would be very enlightening

  • Do you want to call the GRASS algorithm using the API of some software for example pygis? – Leo Cardona Oct 17 '18 at 14:00
  • Sounds fine if it works and I could see an example maybe. – ODstuck Oct 17 '18 at 14:07
1

Using PyGIS you can call the algorithm v.transform as follows::

plot_layer = QgsProject.instance().mapLayersByName('plot')[0]
output_path = '/tmp/transform.gpkg'
processing.run("grass7:v.transform",
                       {'input': plot_layer,
                       'xshift': 0,
                       'yshift': 0,
                       'zshift': 0,
                       'xscale': 1,
                       'yscale': 1,
                       'zscale': 1,
                       'zrotation': 0,
                       'columns': '',
                       'output': output_path,
                       'GRASS_REGION_PARAMETER': None,
                       'GRASS_SNAP_TOLERANCE_PARAMETER': -1,
                       'GRASS_MIN_AREA_PARAMETER': 0.0001,
                       'GRASS_OUTPUT_TYPE_PARAMETER': 0,
                       'GRASS_VECTOR_DSCO': '',
                       'GRASS_VECTOR_LCO': ''})

transform_layer = QgsVectorLayer(output_path, "transform_layer", "ogr")
  • Oh, I now understood what PyGIS is. Thanks a lot, however I would prefer something different and more universal maybe? Is an API the only solution available? – ODstuck Oct 17 '18 at 15:03
0

Ok, the answer lies into PyQGIS API, documentation for QGIS 3 which is a very helpful integrated solution.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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