sábado, 2 de febrero de 2013

File conversion with SEXTANTE

All providers included in SEXTANTE can use and produce all data types supported by QGIS, even if the actual application doing the work does not support all those formats. SEXTANTE takes care of all the needed conversions, so the user doesn't have to worry about it.

This full support of many different formats can be used automate the conversion of a set of files into a given format. We will see in this post how to do it.

There are several modules specifically designed to convert/translate between formats. The GDAL and OGR providers contain modules for converting vector (ogr2ogr) and raster layer (translate) respectively. In the case of vector layers, there is also a quick trick that we can use, which does not require use any external application and does all the work directly within QGIS. The Create new layer with selected features algorithm outputs a new layer with just those features that are selected. However, if no feature is selected, it will take all of them (this is the default behaviour of SEXTANTE in case there is no selection, and it works like that for all providers), so saving a layer with no selection will create that same layer. We just have to use a different file extension, and we will get the same layer, but saved in a different file format.

The algorithm dialog is rather easy to understand, as it doesn't have much more that an input field and an output field.


Just select the layer to export and the destination file. The extension of that file will define the output file format.

This way of exporting a layer through SEXTANTE instead of using the "normal" QGIS elements (in this case the Save Selection as Vector File menu) does not make a great difference for a single layer, but in the case of having a large number of them, it will ease out work considerably. To profit from the productivity tools that are part SEXTANTE, we should run the algorithm not like we usually do, double clicking on its name, but using the batch processing interface. Right-click on the name of the algorithm and then select Execute as batch process. You will see the following dialog.


Each row represents an execution of the algorithm, so we have to add as many rows as layers we want to convert and then fill the table. It is even easier than that, because we can select  a table cell in the Input layer column, click on the edit button to bring up the file selection dialog and select a bunch of files, and SEXTANTE will take care of creating the needed rows to accomodate all the selected files.


The next thing to do is to fill the output names. Click on the upper cell in the Output layer... column and browse to the folder where you want your resulting files to be stored. We are going to convert all our files into GML files, so enter ".gml" as the destination filename (notice that the first character is a dot). Don't worry about that name, because we are going to let SEXTANTE fill the names for us. The only important thing is the extension. Click on OK and you will see a dialog like this.



Now select the values as they are shown in the above figure. This tells SEXTANTE to  fill not only the cell you have selected, but all the ones underneath, and adding in each case the filename in the Input layer field as suffix. Since the we entered en empty filename (only a file extension), the resulting names will be the same names as the input layer, but with a different extension.

The final table is ready to be executed.


Now click on OK and SEXTANTE will convert all your files.

Files generated by the batch processing interface are not loaded into QGIS, but you can go to the folder you entered to check that they have been correctly exported.



No hay comentarios:

Publicar un comentario en la entrada