Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I have access to about 1000 satellite images that covers my country. Each of them is associated to a smaller image that is used for browsing the real deal. I would like to write a script that will sweep through the folders and opens all the "browsing" images. I can program in python but I am not sure on how to connect a script like this to QGIS. Can anyone help me?

share|improve this question
 
Not quite what you intend, but building a virtual raster index on all those files with GDAL might speed up working with the whole dataset. –  Andre Joost Jan 3 at 9:02
add comment

1 Answer

I suppose that you would want to use the os.walk function found in the os module that comes with Python to go through all the directories. You could then use the QgsRasterLayer function to load the image into your script. Here's an example for QgsRasterLayer from the PyQGIS Documentation:

fileName = "/path/to/raster/file.tif"
fileInfo = QFileInfo(fileName)
baseName = fileInfo.baseName()
rlayer = QgsRasterLayer(fileName, baseName)
if not rlayer.isValid():
  print "Layer failed to load!"

Hope that this helps!

share|improve this answer
1  
Your answer is a link only answer with no helpful context, please update. –  artwork21 Nov 18 '13 at 14:02
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.