Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows encoding problem with vect() #258

Closed
AGeographer opened this issue Jun 22, 2021 · 1 comment
Closed

Windows encoding problem with vect() #258

AGeographer opened this issue Jun 22, 2021 · 1 comment

Comments

@AGeographer
Copy link

AGeographer commented Jun 22, 2021

Hi,
I have problems with the encoding of Unicode characters in Windows using the vect() function:

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.sf) 
# while 
mtl.sf$NOM # displays French letters correctly, 
mtl.spv$NOM # does not

Is there any parameter for vect() that would avoid this problem?
Thanks,
Tim

@rhijmans
Copy link
Member

rhijmans commented Jun 22, 2021

Thanks. That had annoyed me for a while, but I needed your push to fix it. The values were fine at the C++ side, they just needed to be declared as UTF-8 on the R side. I believe this is fixed now, as I get:

mtl.spv$NOM[1:15]
# [1] "Outremont"                                "LaSalle"                                 
 #[3] "Mont-Royal"                               "Ville-Marie"                             
 #[5] "Le Plateau-Mont-Royal"                    "Hampstead"                               
 #[7] "Le Sud-Ouest"                             "Rivière-des-Prairies-Pointe-aux-Trembles"
 #[9] "Lachine"                                  "Dorval"                                  
#[11] "Montréal-Nord"                            "L'Île-Bizard-Sainte-Geneviève"           
#[13] "Kirkland"                                 "Dollard-des-Ormeaux"                     
#[15] "Senneville"                              

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants