R-ArcGIS / r-bridge

Bridge library to connect ArcGIS and R, including arcgisbinding R library.
Apache License 2.0
119 stars 26 forks source link

Please add the support for convert the arc.raster object to SpatRaster object in terra package and stars object in stars package directly #84

Open SpatLyu opened 1 year ago

SpatLyu commented 1 year ago

Describe the bug Now, the advanced R package fro processing raster data is terra and stars package, please add the support for convert the arc.raster object to SpatRaster object in terra package and stars object in stars package directly.I can achieve this now by use :

library(arcgisbinding)
arc.check_product()
library(terra)

arc.open("path/to/raster data") |> 
  arc.raster() |> 
  as.raster() |> 
  rast()

and

library(arcgisbinding)
arc.check_product()
library(stars)

arc.open("path/to/raster data") |> 
  arc.raster() |> 
  as.raster() |> 
  st_as_stars()

but it‘s inelegant, may be the team can add support to convet the arc.raster object to SpatRaster object in terra package and stars object in stars package directly?

JosiahParry commented 1 year ago

Thank you @spatlyu! This a great suggestion.

I think the cleanest approach would be to add generics for stars::st_as_stars() and terra::rast(). Is there a use case where you prefer stars over terra? I unfortunately am not too familiar with raster-based workflows.

SpatLyu commented 1 year ago

Thanks, @JosiahParry! I use terra to deal with raster-data in most cases, which also has the SpatVector object to deal with vector-data .But I usually deal with vector-data in R use sf package ,when i use both raster and vector data, for me , the stars can work better with sf as sf and stars have a same author and these two packages have more unified function design style! In a word, sf for vector-data and terra for raster-data in most cases for me,but the stars is necessary needed. And the reason why I request for adding support to direct convert from arc-raster object to SpatVect object and stars object is that my friends like to use gdb to store raster layer and I usually use R 😂

SpatLyu commented 1 year ago

Maybe two functions as.rast() and as.stars() can be added to convert them directly?