1

This simple script retrieving a value of raster pixel size works in Python console, but can't be processed in Script editor: "No script found. Seems there is no valid script in the file." How could it be solved?

from qgis.core import QgsRasterLayer
ras = QgsRasterLayer(r"C:\Users123円123円.tif")
pixelsizeX = ras.rasterUnitsPerPixelX()
pixelsizeY = ras.rasterUnitsPerPixelY()
print (pixelsizeX)
print (pixelsizeY)
asked Oct 3, 2023 at 9:47
3
  • Welcome to Geographic Information Systems! Welcome to GIS SE! We're a little different from other sites; this isn't a discussion forum but a Q&A site. Your questions should as much as possible describe not just what you want to do, but precisely what you have tried and where you are stuck trying that. Please check out our short tour for more about how the site works Commented Oct 3, 2023 at 10:04
  • This is not a valid processing script. Start your learning journey here. And pay attention to the tip here Commented Oct 3, 2023 at 10:32
  • Also check out: qgistutorials.com/en/docs/3/processing_python_scripts.html and: anitagraser.com/… Commented Oct 3, 2023 at 10:39

1 Answer 1

2

That may be a valid pyqgis script, but it's not a valid processing script. You can run it from the console script editor, not the processing script editor.

enter image description here

answered Oct 3, 2023 at 11:53
1
  • To add to this: Scripts in the console editor can be opened in a different editor (which makes it easier to see everything imo) with the "Open in External Editor" button. This editor can be set in "Settings - Options - System - Environment". So far I've only tested it with PyCharm and changes are synched pretty much instantly between them when you save the file. Commented Sep 4 at 14:13

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.