geomarker-io / xx_address

0 stars 0 forks source link

error converting data to a simple features object #2

Closed cole-brokamp closed 1 month ago

cole-brokamp commented 1 month ago

Are the geometries nested in a list? Should we unionize these so they can be read in as a simple features object?

packageVersion("dpkg")
#> [1] '0.4.0'

d <-
  dpkg::stow("https://github.com/geomarker-io/xx_address/releases/download/crime_incidents-v0.1.0/crime_incidents-v0.1.0.parquet") |>
  arrow::read_parquet()

library(geoarrow)

sf::st_as_sf(d)
#> Error in st_sf(x, ..., agr = agr, sf_column_name = sf_column_name): no simple features geometry column present

sf::st_as_sfc(d$geometry)
#> Error in st_as_sfc.list(d$geometry): st_as_sfc.list: don't know what to do with list with elements of class arrow_listst_as_sfc.list: don't know what to do with list with elements of class vctrs_list_ofst_as_sfc.list: don't know what to do with list with elements of class vctrs_vctrst_as_sfc.list: don't know what to do with list with elements of class list

Created on 2024-08-23 with reprex v2.1.0

erikarasnick commented 1 month ago

I think it's just a geometry column, not a nested list. I used st_union and pasted together the tlids...

Screenshot 2024-08-23 at 4 38 43 PM
cole-brokamp commented 1 month ago

Can you read it back in okay? Do you get those same errors that I get above in the reprex?

erikarasnick commented 1 month ago

If I read it in before loading the geoarrow package, I get the same error as you did (and the geometry column is type 'list')

If I load geoarrow then read it in, I still get that error, but the geometry column is type 'grrw_vect'... I wonder if there is some way to convert that back to sf?

Screenshot 2024-08-26 at 9 20 11 AM
cole-brokamp commented 1 month ago

It looks my reprex above works as expected if I load geoarrow first instead of after I load the data.

packageVersion("dpkg")
#> [1] '0.4.0'

library(geoarrow)

d <-
  dpkg::stow("https://github.com/geomarker-io/xx_address/releases/download/crime_incidents-v0.1.0/crime_incidents-v0.1.0.parquet") |>
  arrow::read_parquet()

d$geometry <- sf::st_as_sfc(d$geometry)

d <- sf::st_as_sf(d, crs = 4326)

Created on 2024-08-26 with reprex v2.1.0