Feature request #11616
Ability to filter input layers by provider
|Pull Request or Patch supplied:||No||Resolution:|
|Easy fix?:||No||Copied to github as #:||19870|
It would be nice to be able to filter input layers not only by geometry, but also by provider type. This will be useful for algorithms that works only with specific provider (e.g. PostGIS, pgRouting etc).
#1 Updated by Giovanni Manghi over 5 years ago
- File ogr2ogrdistance.py added
This, together with other (small?) improvements would allow to do very neat things.
Take the (working) example I attached to this ticket:
it is a gdal/ogr tool, that using ogr2ogr runs a spatial query inside a PostGIS database (local or remote), using as input two PostGIS layers and where the output is added directly to the very same DB where the inputs come from.
this opens a very interesting opportunity: create a bunch of tools for postgis layers, each one doing a certain spatial operation, and have the results directly in PostGIS.
The attached example works, but it would be needed to implement a few things in processing:
- filter input layers by provider, as asked by Alex in this ticket, because does not make sense to show no PostGIS layers (in this example)
- allow multiple column selection (for each input layer), and return them as a comma separated list, to allow the user add attributes from input layers in the output (when applicable)
- right now the output (a postgis layer) is not added directly in the qgis project, because there is no option (as there is no output as a file)
- as there is not output as file then if something goes wrong no message is shown and in the "log" tab does not shows anything that allow the user to understand if ogr2ogr run ok or not (eventually just looking into processing history/log, but that is not intuitive).
Please notice that the very same spatial queries (well most of them) can be run using ogr2ogr and the "-dialect sqlite" option, in order to use "any" (see below) kind of layers as input and process them with the Spatialite functions, and return a shapefile as output.
In fact this really works and I already implemented a few example: buffer, single side buffer, dissolve, and they all outperform native QGIS tools, especially for large input vectors.
But also using this approach the ability to filter layers by provider would make things better this because inside queries the geometry column name of input layers must be added ("geometry" for shapefiles, at least using ogr) and maybe there are formats (gpx, csv, kml) where this is not possible.
Another thing that would be necessary for the Spatialite approach is the ability to create temporary .vrt files where to put the input layers (if more than one), this because ogr2ogr accepts only 1 input layer, but this can be a .vrt file that can contain >1.