Skip to content

Commit

Permalink
attemp to remove non-ascii characters from CRS
Browse files Browse the repository at this point in the history
  • Loading branch information
mpdougherty committed Nov 15, 2022
1 parent 9912723 commit c884327
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions R/arc2sp.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@
#' }
#'
#' @importFrom arcgisbinding arc.data2sp arc.select arc.open
#' @importFrom sp CRS
#' @importFrom sp CRS wkt
#' @importFrom stringr str_replace
#' @importFrom methods slot<-
#'
arc2sp <- function(fc_path) {
# Check if fc parent folder exists
Expand All @@ -53,14 +55,19 @@ arc2sp <- function(fc_path) {
# Get CRS
arcobj_crs <- sp::CRS(SRS_string = paste0("EPSG:", arcobj@shapeinfo$WKID))

# Convert WKT unicode to ascii (https://github.com/r-spatial/sf/issues/1341)
arcobj_wkt <- sp::wkt(arcobj_crs)
arcobj_wkt_ascii <- stringr::str_replace(arcobj_wkt, "°|º", "\\\u00b0")
arcobj_crs_ascii <- sp::CRS(SRS_string = arcobj_wkt_ascii)

# Make a selection of the ArcGIS data (all data) returned in arc.data format
arc <- arcgisbinding::arc.select(arcobj)

# Convert the arc.data format to the sp format
sp <- arcgisbinding::arc.data2sp(arc)

# Set CRS
slot(sp, "proj4string") <- arcobj_crs
slot(sp, "proj4string") <- arcobj_crs_ascii

return(sp)
}

0 comments on commit c884327

Please sign in to comment.