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

GDAL geometries can not be saved to JLD2 files #445

Open
alex-s-gardner opened this issue Nov 13, 2024 · 3 comments · Fixed by #448
Open

GDAL geometries can not be saved to JLD2 files #445

alex-s-gardner opened this issue Nov 13, 2024 · 3 comments · Fixed by #448

Comments

@alex-s-gardner
Copy link
Contributor

When trying to save GDAL geometries to .jld2 files they are saved as NULL Geometry. @asinghvi17 thinks this has to do with the c-pointers to memory that is not handled correctly by JLD2.

Being able to save GDAL geometries to .jld2 files would be super useful for users like me who work with DimensionalData arrays and GDAL geometries in the same table.

@evetion
Copy link
Collaborator

evetion commented Nov 13, 2024

Yeah, while I understand the need, this can't work.

A pointer is just that, it points to a bit of temporary memory (on your machine). Keeping track of that memory is hard enough while in Julia (as you saw in the other issue), and straight up impossible for JLD2, because if you close Julia, you close the GDAL library and poof, that memory/geometry is gone (which is why JLD2 plays it safe and doesn't save the pointers). And you can't be smart about this, copying the memory, because it's a foreign (GDAL) structure. The pointer only points to a beginning, and only GDAL understands it from there on.

What would work is creating native geometries in Julia (like WKB, as ArchGDAL can read/write those), and saving those to JLD2.

@asinghvi17
Copy link
Contributor

JLD2's serialization methods can be overridden. I was not sure how to save geometries efficiently but your WKB tip pointed me in the right direction :D

Now we just need a method to set the CRS of a geometry. Probably needs to be wrapped from GDAL.

@yeesian
Copy link
Owner

yeesian commented Nov 14, 2024

Reopening due to #448 (comment)

@yeesian yeesian reopened this Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants