gesistsa / rio

🐟 A Swiss-Army Knife for Data I/O
http://gesistsa.github.io/rio/
604 stars 76 forks source link

Shape file extension: update extension guide #458

Open nhward opened 6 days ago

nhward commented 6 days ago

I am keen to extend Rio for shape files (which are technically a sets of four files). Shape files contain data that includes spatial features such as points, lines and polygons. I have read everything I can find on extending Rio but I cannot get the code below to work. Is there a step that is not mentioned?

library(sf)
library(rio)

.import.rio_shp <- function(file, ...) {
  sf::read_sf(dsn = file, quiet = TRUE)
}

file <- system.file("shape/nc.shp", package="sf")
rio::get_info(file)
rio::import(file)

I am running R4.4.2 and the Rio 1.2.3

chainsawriot commented 3 days ago

@nhward Thank you for reporting this.

And you are right that the extension guide is outdated and adding just the S3 method is not enough. get_info() can't detect the file format. And it should also be addressed.

I will update this later.