[R-sig-Geo] Issue with st_read sf with Encoding for MapInfo file (Frisian municipality name)

Egge-Jan Pollé e.j.h.polle at gmail.com
Tue Jan 23 21:49:03 CET 2018


Hello,

Would someone know a solution for this issue:

When I load a MapInfo file with st_read (sf) I have an issue with the
Frisian municipality name 'Súdwest-Fryslân'; it shows as
'S<fa>dwest-Frysl<e2>n' :-( Some issue with the encoding...

Below you will find a reproducible example, which will also download the
data set used.

If I load the same data with readOGR, everything is fine.

And if I load a comparable data set in ESRI SHP file format with st_read
(sf) there is no issue either.

So it really has something to do with the MapInfo driver. I did not find a
solution yet, so any help would be appreciated.

Cheers,

Egge-Jan Pollé


REPRODUCIBLE EXAMPLE:
# Download and read the data
#
# Make sure you have your Working Directory properly set, e.g.:
# setwd("C:/RMOOC")
#
# Download
URL <- "http://www.twiav.nl/files/NL_Municipalities2017.zip"
datafile <- file.path(basename(URL))
dir.create("./Data", showWarnings = FALSE)
workingdirectory <- getwd()
setwd("./Data")
download.file(URL, destfile = datafile, mode = "wb")
unzip(datafile)
unlink(datafile)
rm(URL, datafile)
setwd(workingdirectory)
rm(workingdirectory)

# Read
# Make sure the package "sf" is properly installed:
# install.packages("sf")
library(sf)
NL_Municipalities2017 <-
st_read("Data/NL_Municipalities2017/NL_Municipalities2017.TAB")
View(NL_Municipalities2017)
plot(st_geometry(NL_Municipalities2017),col = "darkgreen", border =
"lightgray")
View(NL_Municipalities2017) # issue with 'Súdwest-Fryslân'; it shows as
'S<fa>dwest-Frysl<e2>n'

# Using rgdal everything is fine...
library(rgdal)
nl2 <- readOGR(dsn = "Data/NL_Municipalities2017", layer =
"NL_Municipalities2017")
View(as.data.frame(nl2))
library(mapview)
mapview(nl2)

	[[alternative HTML version deleted]]



More information about the R-sig-Geo mailing list