[R-sig-Geo] How can I read a path containing multibyte characters using the read_sf () function?

Ista Zahn istazahn at gmail.com
Thu Aug 17 22:10:56 CEST 2017


Hi Ogawa,

I can reproduce the error on Windows, though the error message isn't
very useful. The useful part is the part that comes after that, the
part you didn't include in your question:

In addition: Warning message:
In normalizePath(path.expand(path), winslash, mustWork) :
  path[1]="<U+30C7><U+30FC><U+30BF>/test.shp": The filename, directory
name, or volume label syntax is incorrect

Taking the extrodanary step of googling for the problem I find a bug
report as the first result in
https://www.google.com/search?q=R+normalizePath(path.expand(path)%2C+winslash%2C+mustWork)+utf-8+windows

The upshot from that bug report is that you can either
a) stop using windows (it works on Mac and Linux),
b) use the development version of R where this issue is now fixed on
Windows, or
c) wait for R 3.5 to be released.

With tongue only partially in cheek I suggest that a) is your best option.

Best,
Ista

On Thu, Aug 17, 2017 at 7:32 AM, 小川福嗣 <fukutugu at yahoo.co.jp> wrote:
> Dears,
>
> How can I read data containing multibyte characters in windows
> using the read_sf () function?
>
> library(sf)
> nc <- st_read(system.file("shape/nc.shp", package="sf"))
> write_sf(nc, dsn=enc2utf8("データ"), layer="test", driver="ESRI Shapefile")
> dsn = enc2utf8("データ/test.shp")
> read_sf(dsn)
>
> ERROR:
> Cannot open data source C:\Users*****\nc\データ
> Error in CPL_read_ogr(dsn, layer, as.character(options), quiet, type, :
> Open failed.
>
> best,
> Ogawa
>
> _______________________________________________
> 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