1

I would like to select records 0-10 in INPUT. Algorithm works in QGIS Python console, but in cmd I'm getting error:

"Could not load source layer for INPUT: 
  C:/Users/ja/Inne/Desktop/budynki/budynkishp.shp|subset=\"fid\" >=0 and \"fid\" <= 10 not found."

What is the problem?

processing.run("native:joinattributesbylocation", {'INPUT':r'C:/Users/ja/Inne/Desktop/budynki/budynkishp.shp|subset=\"fid\" >=0 and \"fid\" <= 10',
                                                   'JOIN':r'C:/Users/ja/Inne/Desktop/adresy/adresyzukladem.shp',
                                                   'PREDICATE':[1,5],
                                                   'JOIN_FIELDS':['PNA','SIMC_id','SIMC_nazwa','ULIC_nazwa','Numer'],
                                                   'METHOD':0,
                                                   'DISCARD_NONMATCHING':True,
                                                   'PREFIX':'',
                                                   'OUTPUT':r'C:/Users/ja/Inne/Desktop/caloscpython.shp'})
  • What if you define your subset before inputting it into the processing algorithm? Like layer = QgsVectorLayer("C:/Users/ja/Inne/Desktop/budynki/budynkishp.shp|subset=\"fid\" >=0 and \"fid\" <= 10'" , "testlayer_shp", "ogr") and the try print(layer) or layer.isValid(), and if everything is fine run the processing.run("native:joinattributesbylocation", {'INPUT':layer, ... }). – Taras Nov 5 '20 at 12:52
  • I have got empty layer so it didn't work. – datasciencebegginer Nov 5 '20 at 13:01
  • So, maybe check this layer "C:/Users/ja/Inne/Desktop/budynki/budynkishp.shp|subset=\"fid\" >=0 and \"fid\" – Taras Nov 5 '20 at 13:02
  • I tried and got (JOINED_COUNT': 0, 'OUTPUT': 'C:/Users/ja/Inne/Desktop/caloscpython.shp'}). I should got JOINED_COUNT': 2. I think "subset=\"fid\" >=0 and \"fid\" <= 10" didn't work. – datasciencebegginer Nov 5 '20 at 13:23

Your Answer

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

Browse other questions tagged or ask your own question.