-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add parameter to skip layername in gdal:convertformat #45955
Add parameter to skip layername in gdal:convertformat #45955
Conversation
Sounds like a useful feature! I'm wondering, instead of "ignore layer name" if it would be more understandable to go with "convert all layers" or "convert entire dataset"? In either case it needs some documentation in the short help string and also a unit test of the new parameter. |
@benoitblanc A documentation ticket will be opened at https://github.com/qgis/QGIS-Documentation when this PR is merged. Please update the description (not the comments) with helpful description and screenshot to help the work from documentors. Thank you! |
Will this work with formats other than GPKG and how loading of the output layer will be handled in a such case? |
Yes this works with other formats than GPKG. I have added tests to convert one layer or all layers from a GPKG file to GML files. When all layers are converted, you can open the file in QGIS and chose layers you want to add in your project. I think there might be other formats that supports FeatureCollection which can be used here such as KML or GeoJSON. Edit: It doesn't work with GeoJSON because driver can not create layer.
|
python/plugins/processing/tests/testdata/gdal_algorithm_vector_tests.yaml
Show resolved
Hide resolved
Then this should be mentioned in the docs (probably with the list of the supported formats) and maybe it is worth at least evaluate a possibility to check at runtime whether output format can be used and if this is possible then raise error. |
553d2c4
to
d1ec369
Compare
@nyalldawson looks ok for me. While I think it would be good to have run-time check whether output format allows saving multiple layers or no, we can merge it now and add that check later if needed. |
Looks OK to me. Thanks. |
@benoitblanc |
Fixes #43701 |
In fact, there is a issue here: when a multi layer GeoPackage (or other multilayer format, like GML, KML, Spatialite, SQLite) file is created by the algorithm and the "Open output file after running algorithm" is checked (as default), then only 1 layer is automatically added to the map instead of all the layer contained in the output multi layer GeoPackage file. This could give the user the false impression that the conversion process has not happened correctly for all the layers contained in the source multi layer GeoPackage file. |
Description
In some use cases, user needs to export a whole source to an other format, using
gdal:convertformat
(ogr2ogr.py
) but the processing only converts one layer at the moment.For example, I want to export a whole schema from a database to a file :
GDAL command is :
ogr2ogr -f "GPKG" /tmp/OUTPUT.gpkg "PG:service='test' sslmode=disable" public.batiment
. Onlybatiment
table has been converted.If I add a
IGNORE_LAYERNAME
parameter toTrue
:GDAL command is :
ogr2ogr -f "GPKG" /tmp/OUTPUT.gpkg "PG:service='test' sslmode=disable"
. Whole schema is converted.IGNORE_LAYERNAME
is a boolean parameter which default value isFalse
so the default behavior of importing only one layer is kept.This pull request superseds #39580