I am having a trouble of encoding at writing shapefile by maptools
(0.8-34) of R by MacOSX and reading that by ArcMap 10.2.1 in Windows 8.1 through parallels desktop. Using an original shapefile, I wrote an edited file by writeLinesShape
as follows:
library(maptools)
original <- readShapeLines("original.shp")
writeLinesShape(original, "edit.shp")
After this, I try to read "edit.shp" with ArcMap but cannot read Japanese strings properly in "dbf" file, which I could read in the original file. (Of course I did some edit before writing "edit.shp" but I have the trouble even in this simplest code.)
The original shapefile seems utf-8 because
iconv(original$japanese,from='utf-8',to='shift_jis')
worked in R. Also, I tried the following suspecting that ArcGIS can read shift_jis or cp932,
iconv(original$japanese,from='utf-8',to='shift_jis')
and
iconv(original$japanese,from='utf-8',to='cp932')
before writing the file, but Japanese strings were not shown properly in ArcMAP again.
Is there any way to solve this problem? I suspect that maptools
is not writing utf-8 file because ArcMap is able to read utf-8.
writeOGR
in thergdal
library. Instructions: inside-r.org/packages/cran/rgdal/docs/writeOGRmaptools
.