[R-sig-Geo] Encoding of attributes in SpatVector (terra package)

Ben Tupper btupper @end|ng |rom b|ge|ow@org
Wed Jun 16 00:32:00 CEST 2021


Hi,

Alas, HTML mail gets mangled - try setting your email client to send plan text.

I don't know what the NOM variable contents are supposed to look like,
but I find they are identical.  Can you post to the list your evidence
that shows how they differ and what makes one right versus the other
wrong?  Also, always add the output of sessionInfo() as shown below.

library(sf)
library(terra)

url <- "https://data.montreal.ca/dataset/00bd85eb-23aa-4669-8f1b-ba9a000e3dd8/resource/e9b0f927-8f75-458c-8fda-b5da65cc8b73/download/limadmin.geojson"

mtl.sf <- read_sf(url)# convert sf object to SpatVector object

mtl.spv <- vect(mtl.sf)

identical(mtl.sf$NOM, mtl.spv$NOM)
# [1] TRUE

sessionInfo()
# R version 4.0.3 (2020-10-10)
# Platform: x86_64-apple-darwin17.0 (64-bit)
# Running under: macOS Big Sur 10.16
#
# Matrix products: default
# LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib
#
# locale:
#   [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
#
# attached base packages:
#   [1] stats     graphics  grDevices utils     datasets  methods   base
#
# other attached packages:
#   [1] terra_1.2-10 sf_0.9-8     dplyr_1.0.5
#
# loaded via a namespace (and not attached):
#   [1] Rcpp_1.0.6         rstudioapi_0.13    raster_3.4-5
magrittr_2.0.1     units_0.7-1        tidyselect_1.1.1
# [7] lattice_0.20-41    R6_2.5.0           rlang_0.4.11
fansi_0.4.2        blob_1.2.1         tools_4.0.3
# [13] grid_4.0.3         KernSmooth_2.23-17 utf8_1.2.1
cli_2.5.0          e1071_1.7-6        DBI_1.1.1
# [19] ellipsis_0.3.2     class_7.3-17       assertthat_0.2.1
tibble_3.1.1       lifecycle_1.0.0    crayon_1.4.1
# [25] purrr_0.3.4        codetools_0.2-16   vctrs_0.3.8
glue_1.4.2         sp_1.4-5           proxy_0.4-25
# [31] compiler_4.0.3     pillar_1.6.0       generics_0.1.0
classInt_0.4-3     pkgconfig_2.0.3

Cheers,
Ben


On Tue, Jun 15, 2021 at 11:57 AM Tim Elrick <abo using elrick.de> wrote:
>
> Hi all,
>
> Does anyone know how to change encoding for attributes in a SpatVector
> (terra package)?
>
> library(sf) library(terra)
> # importing a geojson file as sf object url <-
> "https://data.montreal.ca/dataset/00bd85eb-23aa-4669-8f1b-ba9a000e3dd8/resource/e9b0f927-8f75-458c-8fda-b5da65cc8b73/download/limadmin.geojson"
> mtl.sf <- read_sf(url)# convert sf object to SpatVector object mtl.spv
> <- vect(mtl) # while mtl.sf$NOM # displays French letters correctly,
> mtl.spv$NOM # does not anymore Thanks, Tim
>
>
>         [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo using r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo



-- 
Ben Tupper (he/him)
Bigelow Laboratory for Ocean Science
East Boothbay, Maine
http://www.bigelow.org/
https://eco.bigelow.org



More information about the R-sig-Geo mailing list