6

I have a pretty simple model in QGIS that I am trying to use as a batch process.

The model takes a line shapefile input, creates a temporary buffer, extracts by location using that created buffer, and then merges the extracted location shapefile with originally inputted line file.

When I execute it on a single layer it works fine and outputs as desired, however, when I try to use it as a batch process it errors out.

The Python error that kicks up:

Traceback (most recent call last):

File "C:/PROGRA~1/QGIS3~1.6/apps/qgis/./python/plugins\processing\gui\BatchAlgorithmDialog.py", line 88, in runAlgorithm parameters[param.name()] = wrapper.parameterValue()
AttributeError: 'NoneType' object has no attribute 'parameterValue'

And the model:

model

3
  • I'm having the same problem! @Enrich Purpur (sorry I can't reply directly to you because of my insufficient reputation), your solution sounds promising. How would you run the script for multiple layers though? I.e. as a stand-in for the faulty batch process. Thank you in advance!
    – brue
    Commented Jun 25, 2019 at 13:40
  • This does not really answer the question. If you have a different question, you can ask it by clicking Ask Question. You can also add a bounty to draw more attention to this question once you have enough reputation. - From Review
    – Erik
    Commented Jun 25, 2019 at 14:38
  • If you have a new question, please ask it by clicking the Ask Question button. Include a link to this question if it helps provide context. - From Review
    – JGH
    Commented Jun 25, 2019 at 15:17

1 Answer 1

2

Here is a python solution for you.

But before starting, you can always ask the python console for help in populating the parameters like this:

print(help(processing.algorithmHelp('qgis:buffer'))
print(help(processing.algorithmHelp('qgis:extractbylocation'))
print(help(processing.algorithmHelp('qgis:mergevectorlayers'))

Also, to populate the dictionaries I used to run these three tools, I first ran the widget. Then I looked in the log panel for the results and directly copied the python code from that into the dictionaries.

import processing


buffer_parameters = {
'INPUT' : '/Users/ep9k/Desktop/Example.gpkg|layername=Example',
'DISTANCE' : 0.01,      #this is in decimal degrees, yours will probably be different
'SEGMENTS' : 5,
'END_CAP_STYLE' : 0,
'MITER_LIMIT' : 2,
'DISSOLVE' : False,
'OUTPUT' : 'memory:'}

buffer = processing.run('qgis:buffer', buffer_parameters)

extraction_parameters = {
'INPUT': 'Polygon?crs=EPSG:4326&field=fid:long&uid={d7feac26-7116-4f01-b1ba-866501ab700b}',         #this is a memory layer, yours could be different
'PREDICATE': [0],
'INTERSECT': 'Polygon?crs=EPSG:4326&field=fid:long&uid={d7feac26-7116-4f01-b1ba-866501ab700b}',     #this is also a memory layer
'OUTPUT' : 'memory:'}

extract_by_location = processing.run('qgis:extractbylocation', extraction_parameters)

merge_parameters = {
'LAYERS': ['/Users/ep9k/Desktop/Example2.shp','Polygon?crs=EPSG:4326&field=fid:long&uid={f2afdb7d-4ff4-4850-99c0-43d5989c54fd}'],       #this is just a list of layers
'CRS': QgsCoordinateReferenceSystem('EPSG:102003'),
'OUTPUT': 'memory:'}

merge_vector_layers = processing.runAndLoadResults('qgis:mergevectorlayers', merge_parameters)     #notice mergeAndLoadResults here, I want to see this output

Let me know if you have further questions.

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.