I run the qgis:creategrid processing tool. When I write output path as OUTPUT parameter, it creates the shapefile in given directory. However when I run parameter again after changing some parameters except OUTPUT parameter, it does not write on same file with changes.

But I want to write it on same *.shp file. Here is my code:

param = {'TYPE': 2,
         'EXTENT': "329727.56769520865,336312.5556485866,1288173.5555638324,1292085.1509720355",
         'HSPACING': 150,
         'VSPACING': 150,
         'HOVERLAY': 0,
         'VOVERLAY': 0,
         'CRS': "32637",
         'OUTPUT': QgsProcessingOutputLayerDefinition("D:/grid/grid.shp")}

processing.runAndLoadResults("qgis:creategrid", param)

For instance when I run it again after changing HSPACING parameter, I want to write it on D:/grid/grid.shp again.


Actually I could not find the solution of my exact question. However I found a way for my request. If I run the script as processing.run instead of processing.runAndLoadResults, I can write on file as much as I want. In OUTPUT parameter I write shape path D:/grid/grid.shp. After that you can add it layer panel by calling defined path.

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.