CSIRO-Precision-Agriculture / PAT_QGIS_Plugin

PAT is a QGIS plugin containing a collection of tools for processing precision agriculture data.
Other
25 stars 8 forks source link

Break on Create Block Grid with XYZ #55

Closed PitchPoler closed 3 years ago

PitchPoler commented 3 years ago

Please forgive my inexperience with PAT, git and everything here. I just hope to contribute a tiny fix I made in what I was trying to do.

I just started using PAT (version 1.0.3 on QGIS ver 3.16.2-Hannover on Windows10). I struggled with an error in Create Block Grid:

image

I figured out that the problem was that I had an XYZ layer with Google Satellite baselayer in this project. That does not have a 'path' key. When no 'path' key in the variable named 'result' then this error is thrown by the get_layer_source(layer) function. So I edited line 251 of util\qgis_common.py:

 if len(result) == 0 or (not 'path' in result) or result['path'] == '':
        return layer.source()
    else:
        return result['path']

That is the first thing I ever wrote in python, so you can make it better I'm sure. But with that change I finally got 'Block grid completed successfully!'

Thank you for this tool.

cratcliff commented 3 years ago

@PitchPoler Thanks for the error report and suggestion

I have released a new version PAT v1.0.3 which contains a similar fix, whereby I look for the path key in the results dictionary.

 if not 'path' in result.keys():
        return ''
PitchPoler commented 3 years ago

Yes, your code is better, but I don't see it in the latest version here. I am a git novice, so maybe I'm not looking at the right thing but here is the code block I am talking about from version 1.0.3 util\qgis_common.py: image

Thank you again