geoarrow / geoarrow-r

Extension types for geospatial data for use with 'Arrow'
http://geoarrow.org/geoarrow-r/
Apache License 2.0
155 stars 6 forks source link

Better sf conversion for Arrow table-like things #20

Closed paleolimbot closed 2 years ago

paleolimbot commented 2 years ago
library(geoarrow)
library(sf)
#> Linking to GEOS 3.9.1, GDAL 3.2.3, PROJ 7.2.1

vctr <- geoarrow(wk::wkt("POINT (0 1)", crs = "OGC:CRS84"))
table <- arrow::arrow_table(geom = vctr)
batch <- arrow::record_batch(geom = vctr)
dataset <- arrow::InMemoryDataset$create(table)
query <- dplyr::filter(table, arrow::Expression$scalar(TRUE))

st_crs(query)
#> Coordinate Reference System:
#>   User input: OGC:CRS84 
#>   wkt:
#> GEOGCRS["WGS 84",
#>     DATUM["World Geodetic System 1984",
#>         ELLIPSOID["WGS 84",6378137,298.257223563,
#>             LENGTHUNIT["metre",1]],
#>         ID["EPSG",6326]],
#>     PRIMEM["Greenwich",0,
#>         ANGLEUNIT["degree",0.0174532925199433],
#>         ID["EPSG",8901]],
#>     CS[ellipsoidal,2],
#>         AXIS["longitude",east,
#>             ORDER[1],
#>             ANGLEUNIT["degree",0.0174532925199433,
#>                 ID["EPSG",9122]]],
#>         AXIS["latitude",north,
#>             ORDER[2],
#>             ANGLEUNIT["degree",0.0174532925199433,
#>                 ID["EPSG",9122]]]]
st_bbox(query)
#> xmin ymin xmax ymax 
#>    0    1    0    1
st_geometry(query)
#> Geometry set for 1 feature 
#> Geometry type: POINT
#> Dimension:     XY
#> Bounding box:  xmin: 0 ymin: 1 xmax: 0 ymax: 1
#> Geodetic CRS:  WGS 84
#> POINT (0 1)
st_as_sf(query)
#> Simple feature collection with 1 feature and 0 fields
#> Geometry type: POINT
#> Dimension:     XY
#> Bounding box:  xmin: 0 ymin: 1 xmax: 0 ymax: 1
#> Geodetic CRS:  WGS 84
#>          geom
#> 1 POINT (0 1)

Created on 2022-05-20 by the reprex package (v2.0.1)