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]]