-
Notifications
You must be signed in to change notification settings - Fork 1
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
Feature request: helper function for working with GeoPackage schema extension #4
Comments
I think it also may be possible to read the schema information from a GeoPackage file by using the |
Thanks for this interesting idea! It will first need exploring the different possible options how to best approach this, as you refer. I've no experience with the schema extension and won't be able to look at it soon, but will be glad to do so. It's added in my todo list, but of course you're welcome to take this further already or add a pull request. |
I don't have a GeoPackage file that is using the Schema or Metadata extensions to test this with but I've got a working prototype for reading the relevant tables using the RSQLite package: Update: I developed this a little more fully and stuck the code in this gist. Writing the data may be easier than I expected although it will take some work to incorporate validation for the schema and metadata specifications. I'm assuming there is some way to do this with
|
For really no good reason, I spent a bunch more time on my fork this tonight both expanding on the examples I shared in my comment this afternoon and refactoring the original functions. If you're OK with expanding the Imports to include rlang, glue, and cli and moving RSQLite from Suggests to Imports, I'd be glad to open a pull request (or open a separate more general issue for this proposed refactoring). I'd also love to see the I haven't fully figured out how to use parameterized SQL queries but, once I do, I think implementing both the registered extensions (which includes the metadata and schema extensions) and broader list of community extensions is totally doable. |
Ah – I did just spot the note on the README that |
Thanks!
This essentially means that it is not necessarily built on top of one specific framework; hence some heterogeneity between functions is to be expected. No problem there for flexibility! I will look further into your ideas and come back! Regarding adding dependencies (Imports), I think it depends on how frequently functions of these packages are used inside and across the new functions.
Good point; feel free to change in a PR! |
@elipousson I've read your gist. Such awesome contributions; this rocks!! They would make the currently modest, tiny package (just toying with timestamps, which I needed once) more reflect its name, i.e. providing various useful functions to interact with GeoPackages. Also I've been learning a bit further about GPKG extensions, thanks for the links 👍. As a historical note, rgeopackage was created after discussion in rkrug/rGeoPackage#9. (At the time of writing, its Readme refers to an older repo location of current rgeopackage; have made a pull request for that) I didn't yet study your new code in your fork, so still lagging behind 🙈. But I've taken a quick peek; it looks impressive and it's clear to me you take this very serious ❤️. I must add I'm very busy these days (months actually) with non-coding work, which makes it challenging to keep pace with all exciting developments. Also, at the moment rgeopackage isn't my first priority when it comes to maintenance or adding new features. Given this, and your obvious and most welcome ambition to take the package to 'the next level' and perhaps add more ideas in the future, I'd be glad to pass maintainership to you if you'd be willing to, and go to 'assistance mode' where I can. Which doesn't mean I won't look in detail to your upcoming pull requests, on the contrary 😄. Just please don't expect I can handle them very quickly, I hope I can get to it (or to further inspecting your fork, if not yet a PR) in the course of next week. Looking forward to your ideas on this! |
Did you take a further look at those? It appears that GDAL supports the Schema and Metadata extensions, see https://gdal.org/drivers/vector/gpkg.html#level-of-support-of-geopackage-extensions. It is best to check what can be done with sf or not in this area, and document overlapping functionality, so that users are aware (similar to the case of |
Thanks for the kind words about my code, @florisvdh, and the invitation to share in the development and stewardship of your package. I'm going to try to get some additional read and write functionality working on my fork and add more tests before I open a pull request so it may be a week or two more before I have something to review. I mainly want to make sure I don't run into any issues that require significant restructuring (e.g. switching to use GDAL via sf rather than using RSQLite) and I think adding the tests per #5 should make code review easier. I've been doing package development for about two years but mostly working with APIs and sf objects so it is fun and different to learn how to access a GeoPackage file like a database! |
OK, I'll see it when you get there. Feel free to add a branch and work here, but indeed the fork is still easier to experiment with GH Action workflows that depend on the |
@florisvdh Renaming the branch sounds good to me! I haven't done this before but I'm assuming there is a way to make a pull request to bring my changes back into a development branch? Then bring them back into main one piece at a time so that I can add tests as I go? |
Hi @elipousson
|
Regarding the pull request strategy: since all work (different features) sits in one branch there are indeed two options:
The first approach will be the easiest one, but I'm open to both, depending on your preference. |
The first option definitely sounds easier to me as well. I'll see about pulling in the tests through a separate branch from |
I've been a little slow to dig back into development on this because I've thinking it may be better to use GDAL directly via |
Ah – on reflection, it may not need to be an either-or proposition. I set up a new development branch and pulled some of the refactoring from my earlier fork/development branch (which uses I'm going to focus on read and write functions for the schema and the metadata extensions and will share an update when I have working examples. It probably won't be a quick project but I think I'm starting to get my head around the options. |
Interesting @elipousson! It's indeed best to use GDAL as backend in R where it already can cover what you want, to avoid duplication of effort and because it will be maintained to support future GPKG versions. Actually I wasn't yet aware of this being a change of approach, postponing reflection to the PR reviewing process 🙈. GDAL support for aspatial tables in a GeoPackage has been implemented in sf, both reading and writing (r-spatial/sf#1396). You may want to make use of it in programming the features that you want to add here. Also, SQL queries can be passed to GDAL with |
I'm note sure if this is already possible using the layer_options and dataset_options for
sf::st_write()
but I'm curious if you've explored the possibility of adding support for the GeoPackage schema extension, ideally allowing column labels or a dataframe with definitions/aliases to match column names, to serve as the data to use for the schema. Happy to spend some time figuring this out if you have any pointers on how to approach it!The text was updated successfully, but these errors were encountered: