You are here:GeoTux»Geo-Blogs»Desktop GIS»Load Them All, a QGIS plugin

Statistics

Invitados: 39
Usuarios registrados: 3132
Usuarios en línea:
-
Registrados hoy:
-

Register

RSS

Blogs and News:
Recibe las actualizaciones en Geo-Noticias y Geo-Blogs

Get them by e-mail
Recibir Geo-Noticias y Geo-Blogs por e-mail

¿What is this about?

Latest Geo-Tweets

Monday, 18 October 2010 16:43

Load Them All, a QGIS plugin Featured

Written by  German Carrillo
Rate this item
(2 votes)

The Load Them All plugin allows you to load at the same time a number of layers stored in a directory structure, based on a variety of filters you may customize.

(The Spanish version can be found here)

 

A few days ago my girlfriend asked me something related to QGIS. She wanted to know whether it was possible to load several Shapefiles at the same time, even being stored in a directory structure. I didn't know how to do it with the QGIS tools but I thought it would not be so hard to write a little script using the python console with PyQGIS. So I wrote it and she said it was great, but it was not exactly what she wanted. She needed something more specific: to load several files based on a kind of alphanumeric filter, so I modified the script slightly and it worked like a charm.

 

So what?

Well, now it is a QGIS plugin and it has some additional filters.

 

It is called 'Load Them All' because it allows you to load all the files you have in a directory structure. The plugin is able to load file-based layers (GML, SHP, TIF, IMG, among others), whereas database layers are not supported due to the appropriate way in which QGIS deals with them.

 

Loading all layers from a directory (recursively)

Imagine you have a directory structure like this:

 

A directory structure

 

To get all your layers (shapefiles) loaded in QGIS you have to set a base directory from which the plugin will search and you have to choose the format you want to load, i.e. for vectors: Shapefile, Mapinfo, CSV, GML, GPX, KML, GeoJSON, GMT, e00, DXF or GeoRSS, whereas for rasters: TIF, IMG, ASC or DEM.

 

Loading all

 

And click on OK.

 

Loading layers based on an alphanumeric filter

For the previous example, imagine you need to load only those layers who start with the word 'zona', so you should set an alphanumeric filter:

 

Alphanumeric filter

 

You do not need to write the usual characters to set filters, such as * or %, just use one of the 3 types of match: Starts with, In any position and Ends with.

 

NOTE: If you leave the filter string empty, the alphanumeric filter will not be applied.

 

Now click on OK.

 

Loading vector layers based on their geometry type

Let's forget for a while the alphanumeric filter.

 

Now imagine you need to load all the point layers, so you have to set a geometry type filter:

 

Geometry type filter

 

You may choose more than one geometry type to set your filter but if you choose all the possible options (Point, Line and Polygon) the geometry type filter will not be applied.

 

Now click on OK.

 

Loading raster layers based on their type

If you need to load rasters based on their type you have to set a raster type filter:

 

Raster type filter

 

You may choose more than one raster type to set your filter but if you choose all the possible options (Gray or Undefined, Palette and Multiband) the raster type filter will not be applied.

 

Now click on OK.

 

Mixing filters

You may be wondering if it is possible to set an alphanumeric filter and a geometry (or raster) type filter at the same time. The answer is yes.

 

Just set each filter and click on OK.

 

Mixed filter

 

It works either for vectors or rasters.

 

Configuring the plugin

You might customize a number of aspects of the Load Them All plugin:

 

Configuration tab

 

Create groups:

Check this option to get the loaded layers organized into groups taking directories' names as a base.

 

Create groups

 

Turn off the layers by default:

Check this option to get the loaded layers turned off.

 

Turn off loaded layers

 

Show a dialog to let you know the process is done:

Check this option to know when the loading is done by means of a dialog.

 

A dialog to inform you the loading is done

 

Number of layers to show a confirmation dialog before the loading:

A confirmation dialog will be shown when the number of layers to load is greater than or equal to this number. Set this to 1 if you want the dialog is always shown.

 

Confirmation dialog

 

Technical issues

The Load Them All plugin was written having in mind the strategy pattern for encapsulating the range of filters that can be applied. Have a look at the design:

 

Class diagram

 

Ok, so, how do I install it?

You might download it from here (loadthemall.zip) and copy the extracted folder into the QGIS plugins directory:

 

In GNU/Linux it should be in /home/user/.qgis/python/plugins/

In Windows most likely it is in: c:/Documents and Settings/user/.qgis/python/plugins/

 

Restart QGIS and go to the Plugin Manager to activate it.

 

Contact

Feel free to report bugs, suggest improvements or say hello at geotux_tuxman [at] linuxmail [dot] org

 

=================================================

Update (11.03.2011): Version 1.4

These changes have been implemented:

  • New option: Do not load empty vector layers.
  • New vector and raster formats added.
  • Now it is possible to select the option "All listed formats (*.*)" from the format filter.

=================================================

Update (29.03.2012): Version 1.5

These changes have been implemented:

  • GPX format correctly handled by considering track, route and waypoints (problem reported by Arnaud LE BRETON, thanks!).

=================================================

Update (18.01.2015): Version 2.3

Thanks to Sören Gebbert, v.2.3 of Load Them All includes:

  • Support for boolean operators in the alphanumeric filter. Operators like || (for boolean OR) and && (for boolean and) can be used to combine regular expressions in one string.
    • Examples 1: This alpha numeric filter expression with boolean OR operator "Ae || Ar || As || B[ers]" will load all files that have at least one of the sub-strings "Ae", "Ar", "As", "Be", "Br" and "Bs" in their file names.
    • Example 2: This alpha numeric filter expression with boolean AND operator: "W[ie] && city" will load all files that have the sub-strings of "Wi" or "We" and "city" in their file names. The names Wittenberg_city.shp and Wesenberg_city.shp for example will fit this criteria.
  • Bounding-box filter: The bounding-box filter allows the selection of raster or vector layers that are located within or intersect a user defined spatial extent. The user defined spatial extent can be loaded from the current spatial extent of the map view or can be edited by the user directly. Two radio buttons allow the user to select the spatial topological relations intersection or contains that must be fulfilled. The implementation of this filter makes sure that it is applied after the alphanumeric and geometry filter (when enabled) for performance reasons, since the spatial extent check requires to open the pre-selected raster or vector layers and to determine their spatial extent.
  • Source code structure: A new and easier way of dealing with multiple filters. In older versions it was only possible to handle up to 2 filters at once. By using a list of filters it is now possible to mix 2+ different filters.

Additionally, the following options and bug fixes have been included:

  • Case insensitive option for the alphanumeric filter (Configuration tab).
  • Accent insensitive option for the alphanumeric filter. This option requires the Python lib 'unidecode' and can be activated in the Configuration tab.
  • Performance improvement in alphanumeric filter. RE patterns are compiled and reused.
  • Bug fix: Similar to the bug fixed in v.2.2 related to trailing slashes, the same bug was occurring on Windows (e.g., "c:\folder\").
  • The source code of the plugin was migrated to GitHub: https://github.com/gacarrillor/loadthemall Feel free to improve the plugin, suggest features, etc.

Last modified on Monday, 19 January 2015 17:17

comments  

 
0 # link rotogbh 2012-04-10 15:19
Hola Germán, el siguiente link de la versión en español está roto: http://geotux.tuxfamily.org/index.php/en/component/myblog/?task=view&id=264

Sds.

Adolfo
Reply | Reply with quote | Quote
 
 
0 # Re:tuxman 2012-04-10 20:33
Gracias Adolfo por reportarlo! Corregido.
Reply | Reply with quote | Quote
 
 
0 # Versión para qgis 2.0?Alejo 2013-10-29 14:21
Estimado German, primero gracias por tan útil plugin. Es posible tener disponible loadthemall para qgis 2.0? Muchas Gracias
Saludos
Reply | Reply with quote | Quote
 
 
0 # Re:tuxman 2013-10-29 15:00
Hola Alejo,

seguro!, voy a hacer un campo para actualizarlo a QGIS 2.0. Te aviso por este medio cuando esté listo.

Saludos,

Tuxman
Reply | Reply with quote | Quote
 
 
0 # Re:tuxman 2013-12-21 00:42
Alejo, LoadThemAll ya está disponible para QGIS 2.0:

plugins.qgis.org/plugins/loadthemall/

Saludos!
Reply | Reply with quote | Quote
 
 
0 # Re:Alejo 2013-12-21 13:06
Excelente! Muchas gracias por el plugin y el esfuerzo de actualizarlo.

Un cordial saludo


Alejo
Reply | Reply with quote | Quote
 
 
0 # Load unicode pathismailsunni 2014-08-11 16:05
Hi, thanks for the useful plugin.

I want to ask, how do you manage to be able to load layer that has unicode path?

I tried the same code in QGIS python console, it doesnot work. I looked at your code, but I couldn't find the magic. Can you help me....

Thanks
Reply | Reply with quote | Quote
 
 
0 # Re:tuxman 2014-08-12 17:18
Hi ismailsunni, you're welcome.

What exactly have you tried out? Take a look at LoadThemAllDialog.py, perhaps that could give you a hint.

Regards
Reply | Reply with quote | Quote
 
 
0 # jp2 support?sim 2017-01-18 09:21
Good plugin. Is There way to add filetype support?
Reply | Reply with quote | Quote
 
 
0 # re: jp2 support?tuxman 2017-01-18 15:38
Hi,

please post an issue here and I'll give it a try soon. If you want to contribute with code, you're welcome, just tell me what you need to start.

Regards,

Germán
Reply | Reply with quote | Quote
 
 
0 # Issue with gmlAlex-WD 2017-01-23 11:34
Hi,

This looks very useful and runs very fast, however the plugin is not loading a set of gml files properly. It is only opening the point and table sub-layers, not the poly-lines.
Reply | Reply with quote | Quote
 
 
0 # Re:tuxman 2017-01-25 14:33
Hi Alex,

could you please share the problematic GML or a subset of it? I'll use it just for testing purposes.

Regards,

Germán
Reply | Reply with quote | Quote
 
 
0 # Re:Alex-WD 2017-01-25 15:12
Hi German,

I'm afraid the one I am using is licenced ITN, so I cannot share it. There is a freely available sample here: https://www.ordnancesurvey.co.uk/business-and-government/products/itn-layer.html

Many Thanks,

Alex
Reply | Reply with quote | Quote
 
 
0 # Re:tuxman 2017-01-30 01:36
Hi Alex,

thanks for pointing out that issue and sharing sample data. I've fixed the issue in Load Them All v2.5. You can download it from the QGIS Plugin Manager.

Regards,

Germań
Reply | Reply with quote | Quote
 
 
0 # ExceptionB-C 2017-06-22 19:06
Hi,
I was wondering if it was possible to make the filter an exception. instead of importing all data in the Alphanumerical filter import the rest?
Thanks,
B-C
Reply | Reply with quote | Quote
 
 
0 # Re:tuxman 2017-06-22 21:58
Hi B-C,

let me know what Alphanumeric filter you're using. Perhaps what you want is achievable with RegExp syntax.

Nonetheless, such option (something like 'inverted filter') would be handy. Please create an issue at GitHub. I could implement it when I can make time for it.


Regards,

Germán
Reply | Reply with quote | Quote
 
 
0 # Re:ReB-C 2017-06-22 23:14
Hi Germán,
Thanks for you reply!

Right now I was using 'waypoint|tracks '
This gave me the correct results has I was trying to have everything except track_points.
Inverted would be a great option!
I added issue on GITHub. also with an other request. to filter other things such as 'date modified'
Thanks,
B-C
Reply | Reply with quote | Quote
 
 
+1 # Re:tuxman 2017-06-23 04:11
Ah OK, so that filter does the job for you already. Good!

Keep an eye on the issue, I could implement the "inverted filter" during the weekend.

Thanks for your suggestion, that's how a project can keep growing.

Regards,

Germán
Reply | Reply with quote | Quote
 

Add comment


Security code
Refresh

 

On-line users

Latest Geo-Forums

More Topics »

Latest Comments