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 am trying to import some GDAL supported raster files into a binary raster map layer using the r.in.gdal module from QGis Grass tool.

As I have multiple files to import, I would like to batch import them.

Is is possible or should do I have to repeat the same operation for every single file?

I work with QGis 1.8.0 Lisboa.

share|improve this question
1  
We assume Windows OS? –  nickves Nov 16 '12 at 8:31
1  
Yes, sorry, Windows 7. –  Bap Nov 16 '12 at 17:29
add comment

2 Answers 2

up vote 3 down vote accepted

Just for the record, the GRASS graphical user interface offers a convenient bulk import tool: http://grasswiki.osgeo.org/wiki/Importing_data#Bulk_data_import

enter image description here

share|improve this answer
add comment

You can easily do this using QGIS python console. To get Python Console

QGIS 1.8.0 Lisboa -> Plugins -> Python Console

Find the attached screenshot which loads all files(vector - shape) from a specific directory QGIS bactch load layers

Below is the code for loading vectors.

shp_path="C:\\Users\\rashad\\Documents\\kerala"
shps = glob.glob(os.path.join(shp_path,"*.shp"))
for shp in shps:
    (shpdir, shpfile) = os.path.split(shp)
    qgis.utils.iface.addVectorLayer(shp, shpfile, 'ogr' )

For your purpose you need to modify a bit

raster_path="C:\\Users\\rashad\\Documents\\all_raster_maps"

#you can say other extension or *.*
rasts = glob.glob(os.path.join(raster_path,"*.tif")) 
for rast in rasts:
    (rastdir, rastfile) = os.path.split(rast)
    qgis.utils.iface.addRasterLayer(rastfile, "raster")

Hope that helps

share|improve this answer
    
I had a few problems with the Python code (probably because I had never used Python before...), so I used the GRASS interface. It works really well. Thank you! –  Bap Nov 19 '12 at 22:57
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.