[R-pkg-devel] Problem with package containing spatial data
Adam H. Sparks
@d@mh@p@rk@ @end|ng |rom gm@||@com
Thu Feb 9 00:46:50 CET 2023
Hi Igor,
I’ve a couple packages that have spatial data in them that I maintain. I’ve opted to package up the data as a geopackage file and import it as an {sf} object. Edzer Pebesma suggests this to circumvent changes in the {sf} package from affecting native {sf} objects that are distributed as part of a package. Maybe this is an option for you?
In https://github.com/adamhsparks/extractOz, see /inst/extdata for the geopackage file and https://github.com/adamhsparks/extractOz/blob/main/R/data.R for handling the data importing and making available in the R session on package load.
Best,
Adam
> On 8 Feb 2023, at 10:32 pm, Igor L <igorlaltuf using gmail.com> wrote:
>
> Hello all,
>
> I'm developing a package that contains spatial data about public safety in
> Rio de Janeiro.
>
> The problem is that when I use the usethis::use_data function which
> transforms the shapefile data into a file with the .rda extension, I cannot
> use the geometry attribute to create a map.
>
> E.g.:
>
> # Raw-data script:
>
> spatial_aisp <- sf::st_read('data-raw/shp_aisp/lm_aisp_2019.shp')
>
> plot(spatial_aisp) # works
>
> # Same data from .rda file after use usethis::use_data(spatial_aisp,
> overwrite = TRUE)
>
> x <- ispdata::spatial_aisp
>
> plot(x) # do not work
>
> Error message:
> Error in data.matrix(x) :
> 'list' object cannot be coerced to type 'double'
>
>
> This is happening with all spatial data in the package. I'm using lazydata:
> true and have already disabled file compression options, but the problem
> persists.
>
> Any ideas?
>
> Scripts can be accessed at https://github.com/igorlaltuf/ispdata
>
> Thanks!
> --
> *Igor Laltuf Marques*
> Economist (UFF)
> Master in Urban and Regional Planning (IPPUR-UFRJ)
> Researcher at ETTERN and CiDMob Laboratories
> https://igorlaltuf.github.io/
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-package-devel using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-package-devel
[[alternative HTML version deleted]]
More information about the R-package-devel
mailing list