-
Notifications
You must be signed in to change notification settings - Fork 27
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
Spatial Extension support #55
Comments
I would definitely be excited! I think the general issue is that by default the data comes back in an internal BLOB format (you need to call I'm hoping to get the Arrow output directly as geoarrow extension arrays ( duckdb/duckdb-spatial#153 ) so that the geoarrow package ( https://github.com/geoarrow/geoarrow-c/tree/main/r/geoarrow ) can handle the whole thing automagically! |
I find duckdb works really nicely from R on spatial data already. I have a small wrapper since the syntax is a bit verbose otherwise, that will read in from duckdb as an quick example with lazy read that avoids downloading the data, reads in a few different spatial vector formats and performs a spatial join: remotes::install_github("cboettig/duckdbfs")
library(dplyr)
url <- "https://github.com/cboettig/duckdbfs/raw/main/inst/extdata/world.gpkg"
countries <-
paste0("/vsicurl/", url) |>
duckdbfs::open_dataset()
cities <-
paste0("/vsicurl/https://github.com/cboettig/duckdbfs/raw/",
"main/inst/extdata/metro.fgb") |>
duckdbfs::open_dataset()
countries |>
filter(continent == "Oceania") |>
spatial_join(cities, by = "st_intersects", join="inner") |>
to_sf() One problem that I have had though is for some reason the spatial extension does not seem to be available for Windows users. (It appears that windows extensions have to be built separately for R to be compatible with the rtools chain, and cannot use the Windows extension that all other duckdb platforms use(?) Core extensions are now built for Windows, but as I understand it, the spatial one is not. @krlmlr any insights here? duckdb/duckdb-spatial#158 It would be great for windows users to be able to use duckdb for large spatial operations too...) |
That's correct since DuckDB for Windows other than R uses the MSVC ABI and only R uses the GNU ABI. |
Thanks @eitsupi , that matches my understanding. It's great that all of the "core" extensions are built separately with the GNU ABI for R on windows. It's really sad that windows users can't access the spatial extension though at this time. |
I'm not familiar with how the DuckDB extensions are distributed, but they appear to be entirely defined by GitHub Actions, so why not simply port the following workflow to https://github.com/duckdb/duckdb_spatial? In any case, that's another issue. |
Thanks @eitsupi , that's great! it does look like that recipe could be adjusted to build the spatial extension. It's not clear to me what repository ought to be implementing it -- the workflow you link to appears to depend on a custom action defined in the main repository (https://github.com/duckdb/duckdb/blob/a55f89cd9e956b3e575532e058c230461799ac64/.github/actions/build_extensions/action.yml) which in turn depends on scripts specific to that repository -- I guess that would all need to be duplicated in the spatial extension repo? I'm very sorry if this was the wrong thread to address this issue, though it is specific to R. In any event, other than windows support I don't see what more needs to be done to support the spatial extension for duckdb-r? (Though I was glad to see the Ibis support, it doesn't look like the approach there supports directly passing through geospatial functions the way we dbplyr does, and so they are implementing these bit by bit, while on the R side we seem to be able to use any function available in the geospatial extension immediately (e.g. like the new |
The extensions help page has:
On the other hand, the overview page doesn't mention core extensions. According to the list of official extensions, "spatial" is an official extension. |
I wanted to point out that DuckDB lacks the ability to convert spacial types to the appropriate R types. I don't think there is anything this repository can do about spacial extensions that work on R on Windows. |
Thanks @krlmlr and co! It would be wonderful if @eitsupi thanks for your help. Re mapping to native R types, this is just a matter of using the correct read methods when using those types; e.g. if the desired R type is an But for users of |
We're going to pick this up and build all extensions for windows_amd64_rtools |
Per #100 (comment), this should work now? Can you confirm? Closing in favor of #100. |
My original intent was that this issue is not about Windows but about the proper conversion between Geospatial and R types. |
Reopening, but the discussion got mixed up. I'd appreciate it if we could start a fresh discussion with the most important findings, up-to-date, summarized and linked here. |
Perhaps not a complete summary, but:
|
As far as I know spatial now builds for rtools |
Yes, spatial is good now, confirmed by @carlopi. Opened a new issue to investigate the OP. |
Just wanted to confirm that spatial extension appears to be working nicely for Windows R users now too, at least as per our windows CI. |
I saw this post of ibis.
https://ibis-project.org/posts/ibis-duckdb-geospatial/
It would be great if the R client also had an integration with the Spatial Extension. (For now, it seems to be difficult to handle because it is converted to the raw type of R)
Perhaps integrating with the geoarrow package would make sense?
@paleolimbot Sorry for tagging you, but do you have any perspectives on such integrations?
The text was updated successfully, but these errors were encountered: