Skip to content
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

ogr2ogr transfer relationships defined in geopackages #11397

Closed
ea-eriksson opened this issue Nov 30, 2024 · 3 comments · Fixed by #11411
Closed

ogr2ogr transfer relationships defined in geopackages #11397

ea-eriksson opened this issue Nov 30, 2024 · 3 comments · Fixed by #11411
Assignees

Comments

@ea-eriksson
Copy link

Feature description

When converting between gpkgs with ogr2ogr, support transferring relationships defined by related tables or foreign keys to the output.

If ogr2ogr is for example used to reproject a gpkg, defined relationships appears to be lost and must be recreated again.

Recreating relationships defined with the related tables extension is not necessarily problematic, but lost foreign keys are more difficult to fix as the tables must be dropped and recreated. It would therefore be great if these relationships were transferred directly by ogr2ogr.

Most desirable would be if ogr2ogr could also transfer relations when converting formats, e.g. from File Geodatabase to gpkg.

Additional context

No response

@rouault
Copy link
Member

rouault commented Nov 30, 2024

GDALRelationship could probably be transferred with moderate effort and risk by ogr2ogr
Foreign keys are much more tricky because tables must be created and filled in the right order depending on the dependency graph formed by foreign keys

@ea-eriksson
Copy link
Author

Yes, I would suggest to only consider transferring GDAL relationships with ogr2ogr. I guess foreign key relationships in gpkgs are not often used anyway because they are limited in how they can be defined

@jratike80
Copy link
Collaborator

Transferring relations makes sense only when the data from the both sides of the relations are also transferrer, so it could be possible with a command like
ogr2ogr -f gpkg output.gpkg input.gpkg [options that can be used for all layers] (-spat, -t_srs, -a_srs, -clip*, ...)
May get complicated is user selects a subset of GPKG layers, including the ones used in relations into a VRT file and transfers then the whole VRT.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants