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

fix: Fix schema inference for default method #33

Merged
merged 1 commit into from
Jan 31, 2024

Conversation

paleolimbot
Copy link
Collaborator

Closes #32.

Good catch!

library(geoarrow)
library(sf)
#> Linking to GEOS 3.11.0, GDAL 3.5.3, PROJ 9.1.0; sf_use_s2() is TRUE

sf_obj <- data.frame(x = 1:5, y = 6:10) |> 
  sf::st_as_sf(coords = c("x", "y"), crs = "EPSG:3857")

# Now works
as_geoarrow_array(sf_obj)
#> <nanoarrow_array geoarrow.point{struct}[5]>
#>  $ length    : int 5
#>  $ null_count: int 0
#>  $ offset    : int 0
#>  $ buffers   :List of 1
#>   ..$ :<nanoarrow_buffer validity<bool>[0][0 b]> ``
#>  $ children  :List of 2
#>   ..$ x:<nanoarrow_array double[5]>
#>   .. ..$ length    : int 5
#>   .. ..$ null_count: int 0
#>   .. ..$ offset    : int 0
#>   .. ..$ buffers   :List of 2
#>   .. .. ..$ :<nanoarrow_buffer validity<bool>[0][0 b]> ``
#>   .. .. ..$ :<nanoarrow_buffer data<double>[5][40 b]> `1 2 3 4 5`
#>   .. ..$ dictionary: NULL
#>   .. ..$ children  : list()
#>   ..$ y:<nanoarrow_array double[5]>
#>   .. ..$ length    : int 5
#>   .. ..$ null_count: int 0
#>   .. ..$ offset    : int 0
#>   .. ..$ buffers   :List of 2
#>   .. .. ..$ :<nanoarrow_buffer validity<bool>[0][0 b]> ``
#>   .. .. ..$ :<nanoarrow_buffer data<double>[5][40 b]> `6 7 8 9 10`
#>   .. ..$ dictionary: NULL
#>   .. ..$ children  : list()
#>  $ dictionary: NULL

# Also works...slightly differently (also gives attributes)
nanoarrow::as_nanoarrow_array(sf_obj)
#> <nanoarrow_array struct[5]>
#>  $ length    : int 5
#>  $ null_count: int 0
#>  $ offset    : int 0
#>  $ buffers   :List of 1
#>   ..$ :<nanoarrow_buffer validity<bool>[0][0 b]> ``
#>  $ children  :List of 1
#>   ..$ geometry:<nanoarrow_array geoarrow.point{struct}[5]>
#>   .. ..$ length    : int 5
#>   .. ..$ null_count: int 0
#>   .. ..$ offset    : int 0
#>   .. ..$ buffers   :List of 1
#>   .. .. ..$ :<nanoarrow_buffer validity<bool>[0][0 b]> ``
#>   .. ..$ children  :List of 2
#>   .. .. ..$ x:<nanoarrow_array double[5]>
#>   .. .. .. ..$ length    : int 5
#>   .. .. .. ..$ null_count: int 0
#>   .. .. .. ..$ offset    : int 0
#>   .. .. .. ..$ buffers   :List of 2
#>   .. .. .. .. ..$ :<nanoarrow_buffer validity<bool>[0][0 b]> ``
#>   .. .. .. .. ..$ :<nanoarrow_buffer data<double>[5][40 b]> `1 2 3 4 5`
#>   .. .. .. ..$ dictionary: NULL
#>   .. .. .. ..$ children  : list()
#>   .. .. ..$ y:<nanoarrow_array double[5]>
#>   .. .. .. ..$ length    : int 5
#>   .. .. .. ..$ null_count: int 0
#>   .. .. .. ..$ offset    : int 0
#>   .. .. .. ..$ buffers   :List of 2
#>   .. .. .. .. ..$ :<nanoarrow_buffer validity<bool>[0][0 b]> ``
#>   .. .. .. .. ..$ :<nanoarrow_buffer data<double>[5][40 b]> `6 7 8 9 10`
#>   .. .. .. ..$ dictionary: NULL
#>   .. .. .. ..$ children  : list()
#>   .. ..$ dictionary: NULL
#>  $ dictionary: NULL

Created on 2024-01-29 with reprex v2.0.2

@paleolimbot paleolimbot merged commit 3b04518 into geoarrow:main Jan 31, 2024
11 checks passed
@paleolimbot paleolimbot deleted the sf-to-geoarrow branch January 31, 2024 01:17
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 this pull request may close these issues.

as_geoarrow_array() method for sf objects
1 participant