Import non-English shapefiles

I am trying to import a form file as follows:

fn <- "Proj1" my_shp <- readShapeSpatial(fn) 

It works fine on a Windows computer (32-bit), but when I do the same from a Ubuntu machine (64-bit, English OS, R2.14.0), I get "Error in make.names (onames, unique = TRUE): invalid multibyte string 9 ".

I suspect that this is because the shapefile is of Spanish origin, i.e. the names of the polygons in it have the same accents as in Mexico City (not Mexico).

As a quick fix, I made an import to Windows, saved as .rda and uploaded to Ubuntu, but then I got, for example, "M \ xfexico" as the name of the polygon.

I am not so experienced in Linux, so I don’t know if the fix is ​​fixed in R or in Ubuntu. Your help is much appreciated.

+4
source share
1 answer

The solution is to run R on an Ubuntu computer by writing "LC_ALL = CR" in the terminal window. Thanks to Oscar Perpignan for the decision.

Update: I use RStudio, where, as far as I know, it is impossible to start R with command line parameters, but it works from within RStudio: Sys.setlocale (category = "LC_ALL", locale = "C")

/ Chris

+3
source

Source: https://habr.com/ru/post/1393743/


All Articles