How can I read a path containing multibyte characters using the read_sf () function?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

How can I read a path containing multibyte characters using the read_sf () function?

小川福嗣
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
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Reply | Threaded
Open this post in threaded view
|

Re: How can I read a path containing multibyte characters using the read_sf () function?

Ista Zahn-2
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, 小川福嗣 <[hidden email]> 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
> [hidden email]
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo