12

I have downloaded several imagery Zip files (content of each is jp2, jpg, jpw, xml, htm, and .dbf, .prj, .sbn, .sbx, .shp, .shx) and would like to quickly add this imagery to my working project in QGIS 2.6.1. I am trying to avoid having to navigate to and add each file separately. Because each file is in a different folder, I have not been able to find a way to add multiple files at once.

  • So you have zip files in you folders or you have already extracted the zip files' content? I'm elaborating an answer for the latter case. I'm afraid the former case would require a bit of (Python) scripting. – Germán Carrillo Mar 19 '15 at 23:46
  • I have already extracted content. – reevesii Mar 19 '15 at 23:51
22

What you need is the QGIS plugin Load Them All. Apart from loading files from several directories at once, you can:

  • Reflect the directory structure in the QGIS Table of Contents (by means of nested layer groups).
  • Apply alphanumeric filters so that you just load layers that match your filter (think of regular expressions).
  • Load only certain geometry or raster type (e.g., only polygon vectors or Multiband rasters).
  • Load only certain file extensions (e.g., only .shp files).
  • Load only layers that lie inside or that intersect a given bounding box.

and more. Have a look at https://github.com/gacarrillor/loadthemall for more details.

enter image description here

  • @Germán Carrillo It seems like the perfect plugin for my needs, yet when I try to load the files I get the error: "There are no KML files to load fromt he base directory with this filter. Change those parameters and try again". I'm using QGIS 2.14.2, all filters are turned off and the map I selected contains two maps with one kml file each (just to test, I have a larger dataset to import). – Hannes Ledegen Jan 3 '17 at 13:48
  • @HannesLedegen Did you try with the 'Interesects' filter instead of 'Contains'? If that doesn't work, please open a new issue in the GitHub page of the project, describing everything in detail. – Germán Carrillo Jan 3 '17 at 14:14
2

As an alternative to using a plugin, you can give the Add Layer command a semicolon-delimited list of files. You can create such a list in the following manner:

cd /d <Path_to_the_directory_where_your_files_are>
dir *.shp /s /b >All.txt

This gives you a file named All.txt, which contains the paths to all the files with a specific extension (you can use a different mask depending on the files you have), where each file is on a new line.

D:\Data\01\data01_1.shp
D:\Data\01\data01_2.shp
D:\Data\02\data02_1.shp
D:\Data\02\data02_2.shp

Then simply replace all newlines with ; using a text editor (like Notepad++) and paste the result in the Add Vector Layer... dialog.

For Notepad++ you need to change the replace mode to Extended and replace \r\n with ;. You would get a file that looks like this:

D:\Data\01\data01_1.shp;D:\Data\01\data01_2.shp;D:\Data\02\data02_1.shp;D:\Data\02\data02_2.shp
0

On Linux, you can extract a list of .shp files and feed it directly into the "Import Vector" dialog:

#on the command line
ls /home/yourpath/*/*shp|tr "\n" '@'|sed 's/@/" "/g'|sed 's/^/"/g'

enter image description here

I found this useful under QGIS Docker, beacuse for some reason the "Load Them All" plugin was not showing its dialog.

Your Answer

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

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