[R-sig-Geo] Issue with st_read sf with Encoding for MapInfo file (Frisian municipality name)
Peter van Horssen
peter.vanhorssen at wxs.nl
Tue Jan 23 22:20:10 CET 2018
try here:
https://github.com/r-spatial/sf/issues/5
a similar issue with a solution ...
greetings , Peter
Op 23-1-2018 om 21:49 schreef Egge-Jan Pollé:
> 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]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
More information about the R-sig-Geo
mailing list