Re: [R-sig-Geo] readOGR does not read file names with accent
In sf, the same changes should be available in https://github.com/r-spatial/sf/commit/49d1caca4a4cc71398c1b34a9dedc10112247cae (untested) On 02/15/2018 02:07 PM, Roger Bivand wrote: > Thanks, I'll start moving to submit to CRAN. > > Best wishes, > > Roger > > On Thu, 15 Feb 2018, Patrick Giraudoux wrote: > >> Le 15/02/2018 à 13:01, Roger Bivand a écrit : >>> And with a further fix for a downstream encoding issue: >>> >>> http://spatial.nhh.no/R/rgdal/rgdal_1.2-17.zip >>> >>> Roger >> >> >> OK. Works perfect now, even with a worst case scenario "accents + >> white space", e.g. >> >> readOGR("./track génét/gélinotte/2016/Mont Noir","général jour 5") >> >> Really great ! Many thanks for your help and so quick response... >> Awsome ! >> >> Best wishes, >> >> Patrick >> >> > > > > ___ > R-sig-Geo mailing list > R-sig-Geo@r-project.org > https://stat.ethz.ch/mailman/listinfo/r-sig-geo > -- Edzer Pebesma Institute for Geoinformatics Heisenbergstrasse 2, 48151 Muenster, Germany Phone: +49 251 8333081 ___ R-sig-Geo mailing list R-sig-Geo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Re: [R-sig-Geo] readOGR does not read file names with accent
Thanks, I'll start moving to submit to CRAN. Best wishes, Roger On Thu, 15 Feb 2018, Patrick Giraudoux wrote: Le 15/02/2018 à 13:01, Roger Bivand a écrit : And with a further fix for a downstream encoding issue: http://spatial.nhh.no/R/rgdal/rgdal_1.2-17.zip Roger OK. Works perfect now, even with a worst case scenario "accents + white space", e.g. readOGR("./track génét/gélinotte/2016/Mont Noir","général jour 5") Really great ! Many thanks for your help and so quick response... Awsome ! Best wishes, Patrick -- Roger Bivand Department of Economics, Norwegian School of Economics, Helleveien 30, N-5045 Bergen, Norway. voice: +47 55 95 93 55; e-mail: roger.biv...@nhh.no http://orcid.org/-0003-2392-6140 https://scholar.google.no/citations?user=AWeghB0J&hl=en___ R-sig-Geo mailing list R-sig-Geo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Re: [R-sig-Geo] readOGR does not read file names with accent
Le 15/02/2018 à 13:01, Roger Bivand a écrit : And with a further fix for a downstream encoding issue: http://spatial.nhh.no/R/rgdal/rgdal_1.2-17.zip Roger OK. Works perfect now, even with a worst case scenario "accents + white space", e.g. readOGR("./track génét/gélinotte/2016/Mont Noir","général jour 5") Really great ! Many thanks for your help and so quick response... Awsome ! Best wishes, Patrick ___ R-sig-Geo mailing list R-sig-Geo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Re: [R-sig-Geo] readOGR does not read file names with accent
And with a further fix for a downstream encoding issue: http://spatial.nhh.no/R/rgdal/rgdal_1.2-17.zip Roger On Thu, 15 Feb 2018, Roger Bivand wrote: Please try to install a draft version of rgdal at: https://win-builder.r-project.org/vvWJdd1isnsR and report on its performance for your charset: ogrInfo("./track génét/gélinotte/2017/Trémontagne", "tracé_chaux_du_dombief") ogrListLayers("./track génét/gélinotte/2017/Trémontagne") etc. Beware that my email is probably encoded in UTF-8, so enter the diacriticals on your own machine. Roger On Thu, 15 Feb 2018, Patrick Giraudoux wrote: PS: surprisingly, the files with accent are well read from QGIS (however QGIS uses gdal as workhorse...) Le 15/02/2018 à 08:20, Patrick Giraudoux a écrit : Patrick: Is there also a space in the file path? What is the locale, I guess CP1252? My locale is fr;Français (France) Le 15/02/2018 à 07:57, Roger Bivand a écrit : ... and could you try sf::st_read(), as it uses enc2utf8() internally? If that works, the same may be used in rgdal. st_read has the same issue: reads the file with no accent but not with accent: library(sf) st_read("./track génét/gélinotte/2017/Trémontagne","trace_chaux_du_dombief") Reading layer `trace_chaux_du_dombief' from data source `U:\Users\pgiraudo2\Documents\Tetra\Master Tony Vialet\track génét\gélinotte\2017\Trémontagne' using driver `ESRI Shapefile' Simple feature collection with 1 feature and 5 fields geometry type: LINESTRING dimension: XY bbox: xmin: 870249.9 ymin: 2180142 xmax: 871070 ymax: 2180930 epsg (SRID):NA proj4string:NA but st_read("./track génét/gélinotte/2017/Trémontagne","tracé_chaux_du_dombief") Cannot open layer tracé_chaux_du_dombief Error in CPL_read_ogr(dsn, layer, as.character(options), quiet, type, : Opening layer failed. -- Roger Bivand Department of Economics, Norwegian School of Economics, Helleveien 30, N-5045 Bergen, Norway. voice: +47 55 95 93 55; e-mail: roger.biv...@nhh.no http://orcid.org/-0003-2392-6140 https://scholar.google.no/citations?user=AWeghB0J&hl=en___ R-sig-Geo mailing list R-sig-Geo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Re: [R-sig-Geo] readOGR does not read file names with accent
Please try to install a draft version of rgdal at: https://win-builder.r-project.org/vvWJdd1isnsR and report on its performance for your charset: ogrInfo("./track génét/gélinotte/2017/Trémontagne", "tracé_chaux_du_dombief") ogrListLayers("./track génét/gélinotte/2017/Trémontagne") etc. Beware that my email is probably encoded in UTF-8, so enter the diacriticals on your own machine. Roger On Thu, 15 Feb 2018, Patrick Giraudoux wrote: PS: surprisingly, the files with accent are well read from QGIS (however QGIS uses gdal as workhorse...) Le 15/02/2018 à 08:20, Patrick Giraudoux a écrit : Patrick: Is there also a space in the file path? What is the locale, I guess CP1252? My locale is fr;Français (France) Le 15/02/2018 à 07:57, Roger Bivand a écrit : ... and could you try sf::st_read(), as it uses enc2utf8() internally? If that works, the same may be used in rgdal. st_read has the same issue: reads the file with no accent but not with accent: library(sf) st_read("./track génét/gélinotte/2017/Trémontagne","trace_chaux_du_dombief") Reading layer `trace_chaux_du_dombief' from data source `U:\Users\pgiraudo2\Documents\Tetra\Master Tony Vialet\track génét\gélinotte\2017\Trémontagne' using driver `ESRI Shapefile' Simple feature collection with 1 feature and 5 fields geometry type: LINESTRING dimension: XY bbox: xmin: 870249.9 ymin: 2180142 xmax: 871070 ymax: 2180930 epsg (SRID):NA proj4string:NA but st_read("./track génét/gélinotte/2017/Trémontagne","tracé_chaux_du_dombief") Cannot open layer tracé_chaux_du_dombief Error in CPL_read_ogr(dsn, layer, as.character(options), quiet, type, : Opening layer failed. -- Roger Bivand Department of Economics, Norwegian School of Economics, Helleveien 30, N-5045 Bergen, Norway. voice: +47 55 95 93 55; e-mail: roger.biv...@nhh.no http://orcid.org/-0003-2392-6140 https://scholar.google.no/citations?user=AWeghB0J&hl=en___ R-sig-Geo mailing list R-sig-Geo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Re: [R-sig-Geo] readOGR does not read file names with accent
However, we have a downstream difficulty, which is that current GDAL poLayer->GetName() appears to return UTF-8 in both sf::st_layers() and rgdal::ogrListLayers(), instead of native (CP1252 or other). However, this is seen as native or unknown in R, so messes up choosing the first or single layer if only a dsn is given in a non-UTF-8 charset locale. I'm going to assign Encoding(layers) <- "UTF-8" layers <- enc2native(layers) as a work-around. Roger On Thu, 15 Feb 2018, Roger Bivand wrote: On a CP1252 Windows 7 system, R 3.4.3 patched, current CRAN rgdal and sf, the dsn is not affected by diacriticals, but the layer name is. Putting enc2utf8() around the layer name resolves the problem for me, so for Patrick: st_read("./track génét/gélinotte/2017/Trémontagne", enc2utf8("tracé_chaux_du_dombief")) or readOGR("./track génét/gélinotte/2017/Trémontagne", enc2utf8("tracé_chaux_du_dombief")) should work. Roger On Thu, 15 Feb 2018, Edzer Pebesma wrote: On 02/15/2018 08:20 AM, Patrick Giraudoux wrote: Patrick: Is there also a space in the file path? What is the locale, I guess CP1252? My locale is fr;Français (France) Le 15/02/2018 à 07:57, Roger Bivand a écrit : ... and could you try sf::st_read(), as it uses enc2utf8() internally? If that works, the same may be used in rgdal. st_read has the same issue: reads the file with no accent but not with accent: library(sf) st_read("./track génét/gélinotte/2017/Trémontagne","trace_chaux_du_dombief") Reading layer `trace_chaux_du_dombief' from data source `U:\Users\pgiraudo2\Documents\Tetra\Master Tony Vialet\track génét\gélinotte\2017\Trémontagne' using driver `ESRI Shapefile' Simple feature collection with 1 feature and 5 fields geometry type: LINESTRING dimension: XY bbox: xmin: 870249.9 ymin: 2180142 xmax: 871070 ymax: 2180930 epsg (SRID):NA proj4string:NA but st_read("./track génét/gélinotte/2017/Trémontagne","tracé_chaux_du_dombief") Does st_read("./track génét/gélinotte/2017/Trémontagne", enc2utf8("tracé_chaux_du_dombief")) work? Cannot open layer tracé_chaux_du_dombief Error in CPL_read_ogr(dsn, layer, as.character(options), quiet, type, : Opening layer failed. [[alternative HTML version deleted]] ___ R-sig-Geo mailing list R-sig-Geo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo -- Roger Bivand Department of Economics, Norwegian School of Economics, Helleveien 30, N-5045 Bergen, Norway. voice: +47 55 95 93 55; e-mail: roger.biv...@nhh.no http://orcid.org/-0003-2392-6140 https://scholar.google.no/citations?user=AWeghB0J&hl=en___ R-sig-Geo mailing list R-sig-Geo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Re: [R-sig-Geo] readOGR does not read file names with accent
On a CP1252 Windows 7 system, R 3.4.3 patched, current CRAN rgdal and sf, the dsn is not affected by diacriticals, but the layer name is. Putting enc2utf8() around the layer name resolves the problem for me, so for Patrick: st_read("./track génét/gélinotte/2017/Trémontagne", enc2utf8("tracé_chaux_du_dombief")) or readOGR("./track génét/gélinotte/2017/Trémontagne", enc2utf8("tracé_chaux_du_dombief")) should work. Roger On Thu, 15 Feb 2018, Edzer Pebesma wrote: On 02/15/2018 08:20 AM, Patrick Giraudoux wrote: Patrick: Is there also a space in the file path? What is the locale, I guess CP1252? My locale is fr;Français (France) Le 15/02/2018 à 07:57, Roger Bivand a écrit : ... and could you try sf::st_read(), as it uses enc2utf8() internally? If that works, the same may be used in rgdal. st_read has the same issue: reads the file with no accent but not with accent: library(sf) st_read("./track génét/gélinotte/2017/Trémontagne","trace_chaux_du_dombief") Reading layer `trace_chaux_du_dombief' from data source `U:\Users\pgiraudo2\Documents\Tetra\Master Tony Vialet\track génét\gélinotte\2017\Trémontagne' using driver `ESRI Shapefile' Simple feature collection with 1 feature and 5 fields geometry type: LINESTRING dimension: XY bbox: xmin: 870249.9 ymin: 2180142 xmax: 871070 ymax: 2180930 epsg (SRID):NA proj4string:NA but st_read("./track génét/gélinotte/2017/Trémontagne","tracé_chaux_du_dombief") Does st_read("./track génét/gélinotte/2017/Trémontagne", enc2utf8("tracé_chaux_du_dombief")) work? Cannot open layer tracé_chaux_du_dombief Error in CPL_read_ogr(dsn, layer, as.character(options), quiet, type, : Opening layer failed. [[alternative HTML version deleted]] ___ R-sig-Geo mailing list R-sig-Geo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo -- Roger Bivand Department of Economics, Norwegian School of Economics, Helleveien 30, N-5045 Bergen, Norway. voice: +47 55 95 93 55; e-mail: roger.biv...@nhh.no http://orcid.org/-0003-2392-6140 https://scholar.google.no/citations?user=AWeghB0J&hl=en___ R-sig-Geo mailing list R-sig-Geo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Re: [R-sig-Geo] readOGR does not read file names with accent
On 02/15/2018 08:20 AM, Patrick Giraudoux wrote: >> Patrick: >> >> Is there also a space in the file path? What is the locale, I guess >> CP1252? > > My locale is fr;Français (France) > > > Le 15/02/2018 à 07:57, Roger Bivand a écrit : >> ... and could you try sf::st_read(), as it uses enc2utf8() internally? >> If that works, the same may be used in rgdal. >> > > st_read has the same issue: reads the file with no accent but not with > accent: > > library(sf) > st_read("./track génét/gélinotte/2017/Trémontagne","trace_chaux_du_dombief") > > Reading layer `trace_chaux_du_dombief' from data source > `U:\Users\pgiraudo2\Documents\Tetra\Master Tony Vialet\track > génét\gélinotte\2017\Trémontagne' using driver `ESRI Shapefile' > Simple feature collection with 1 feature and 5 fields > geometry type: LINESTRING > dimension: XY > bbox: xmin: 870249.9 ymin: 2180142 xmax: 871070 ymax: 2180930 > epsg (SRID):NA > proj4string:NA > > > but > > st_read("./track génét/gélinotte/2017/Trémontagne","tracé_chaux_du_dombief") > Does st_read("./track génét/gélinotte/2017/Trémontagne", enc2utf8("tracé_chaux_du_dombief")) work? > Cannot open layer tracé_chaux_du_dombief > Error in CPL_read_ogr(dsn, layer, as.character(options), quiet, type, : > Opening layer failed. > > > [[alternative HTML version deleted]] > > ___ > R-sig-Geo mailing list > R-sig-Geo@r-project.org > https://stat.ethz.ch/mailman/listinfo/r-sig-geo > -- Edzer Pebesma Institute for Geoinformatics Heisenbergstrasse 2, 48151 Muenster, Germany Phone: +49 251 8333081 ___ R-sig-Geo mailing list R-sig-Geo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Re: [R-sig-Geo] readOGR does not read file names with accent
PS: surprisingly, the files with accent are well read from QGIS (however QGIS uses gdal as workhorse...) Le 15/02/2018 à 08:20, Patrick Giraudoux a écrit : >> Patrick: >> >> Is there also a space in the file path? What is the locale, I guess >> CP1252? > > My locale is fr;Français (France) > > > Le 15/02/2018 à 07:57, Roger Bivand a écrit : >> ... and could you try sf::st_read(), as it uses enc2utf8() >> internally? If that works, the same may be used in rgdal. >> > > st_read has the same issue: reads the file with no accent but not with > accent: > > library(sf) > st_read("./track > génét/gélinotte/2017/Trémontagne","trace_chaux_du_dombief") > Reading layer `trace_chaux_du_dombief' from data source > `U:\Users\pgiraudo2\Documents\Tetra\Master Tony Vialet\track > génét\gélinotte\2017\Trémontagne' using driver `ESRI Shapefile' > Simple feature collection with 1 feature and 5 fields > geometry type: LINESTRING > dimension: XY > bbox: xmin: 870249.9 ymin: 2180142 xmax: 871070 ymax: 2180930 > epsg (SRID):NA > proj4string:NA > > but > > st_read("./track > génét/gélinotte/2017/Trémontagne","tracé_chaux_du_dombief") > Cannot open layer tracé_chaux_du_dombief > Error in CPL_read_ogr(dsn, layer, as.character(options), quiet, type, > : Opening layer failed. [[alternative HTML version deleted]] ___ R-sig-Geo mailing list R-sig-Geo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Re: [R-sig-Geo] readOGR does not read file names with accent
hi Patrick, I think it is not about the accent but the space in your path. Try to escape this with "\" : st_read("./Desktop/foldername\ with\ spaces/shapefile.shp") Daniel On Thu, 15 Feb 2018 08:20:12 +0100 Patrick Giraudoux wrote: > > Patrick: > > > > Is there also a space in the file path? What is the locale, I guess > > CP1252? > > My locale is fr;Français (France) > > > Le 15/02/2018 à 07:57, Roger Bivand a écrit : > > ... and could you try sf::st_read(), as it uses enc2utf8() internally? > > If that works, the same may be used in rgdal. > > > > st_read has the same issue: reads the file with no accent but not with > accent: > > library(sf) > st_read("./track génét/gélinotte/2017/Trémontagne","trace_chaux_du_dombief") > > Reading layer `trace_chaux_du_dombief' from data source > `U:\Users\pgiraudo2\Documents\Tetra\Master Tony Vialet\track > génét\gélinotte\2017\Trémontagne' using driver `ESRI Shapefile' > Simple feature collection with 1 feature and 5 fields > geometry type: LINESTRING > dimension: XY > bbox: xmin: 870249.9 ymin: 2180142 xmax: 871070 ymax: 2180930 > epsg (SRID):NA > proj4string:NA > > > but > > st_read("./track génét/gélinotte/2017/Trémontagne","tracé_chaux_du_dombief") > > Cannot open layer tracé_chaux_du_dombief > Error in CPL_read_ogr(dsn, layer, as.character(options), quiet, type, : > Opening layer failed. > > > [[alternative HTML version deleted]] > > ___ > R-sig-Geo mailing list > R-sig-Geo@r-project.org > https://stat.ethz.ch/mailman/listinfo/r-sig-geo -- Dr. Daniel Knitter CRC1266 -- Scales of Transformation Project A2 "Integrative Modeling of Socio-Environmental Dynamics" Christian-Albrechts-Universität zu Kiel Department of Geography Physical Geography -- Landscape Ecology and Geoinformation Ludewig-Meyn-Str. 14, room 109 D - 24118 Kiel, Germany Phone: +49 431 880 2941 Email: knit...@geographie.uni-kiel.de pgpuTL5q2yGQA.pgp Description: OpenPGP digital signature ___ R-sig-Geo mailing list R-sig-Geo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Re: [R-sig-Geo] readOGR does not read file names with accent
> Patrick: > > Is there also a space in the file path? What is the locale, I guess > CP1252? My locale is fr;Français (France) Le 15/02/2018 à 07:57, Roger Bivand a écrit : > ... and could you try sf::st_read(), as it uses enc2utf8() internally? > If that works, the same may be used in rgdal. > st_read has the same issue: reads the file with no accent but not with accent: library(sf) st_read("./track génét/gélinotte/2017/Trémontagne","trace_chaux_du_dombief") Reading layer `trace_chaux_du_dombief' from data source `U:\Users\pgiraudo2\Documents\Tetra\Master Tony Vialet\track génét\gélinotte\2017\Trémontagne' using driver `ESRI Shapefile' Simple feature collection with 1 feature and 5 fields geometry type: LINESTRING dimension: XY bbox: xmin: 870249.9 ymin: 2180142 xmax: 871070 ymax: 2180930 epsg (SRID):NA proj4string:NA but st_read("./track génét/gélinotte/2017/Trémontagne","tracé_chaux_du_dombief") Cannot open layer tracé_chaux_du_dombief Error in CPL_read_ogr(dsn, layer, as.character(options), quiet, type, : Opening layer failed. [[alternative HTML version deleted]] ___ R-sig-Geo mailing list R-sig-Geo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Re: [R-sig-Geo] readOGR does not read file names with accent
... and could you try sf::st_read(), as it uses enc2utf8() internally? If that works, the same may be used in rgdal. Roger Roger Bivand Norwegian School of Economics Bergen, Norway Fra: Roger Bivand Sendt: torsdag 15. februar, 07.49 Emne: Re: [R-sig-Geo] readOGR does not read file names with accent Til: r-sig-geo@r-project.org, Patrick Giraudoux Patrick: Is there also a space in the file path? What is the locale, I guess CP1252? Best wishes, Roger Bivand Norwegian School of Economics Bergen, Norway Fra: Patrick Giraudoux Sendt: torsdag 15. februar, 07.45 Emne: readOGR does not read file names with accent Til: r-sig-geo@r-project.org Kopi: Roger Bivand Dear all, My plateform is Windows 7. I am meeting trouble when reading a shapefile with rgdal:readOGR when the file name includes an accent. For instance, readOGR("./track génét/gélinotte/2017/Trémontagne","trace_chaux_du_dombief.shp") is well read BUT readOGR("./track génét/gélinotte/2017/Trémontagne","tracé_chaux_du_dombief.shp") gives Error in ogrInfo(dsn = dsn, layer = layer, encoding = encoding, use_iconv = use_iconv, : Cannot open layer In both cases accents in the path are well accepted. The difference just come from accent in the filename. Any idea about a workaround (except trivial: manually changing accents to non accent ;-): I have tens of files to read)? Best, Patrick [[alternative HTML version deleted]] ___ R-sig-Geo mailing list R-sig-Geo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo [[alternative HTML version deleted]] ___ R-sig-Geo mailing list R-sig-Geo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Re: [R-sig-Geo] readOGR does not read file names with accent
Patrick: Is there also a space in the file path? What is the locale, I guess CP1252? Best wishes, Roger Bivand Norwegian School of Economics Bergen, Norway Fra: Patrick Giraudoux Sendt: torsdag 15. februar, 07.45 Emne: readOGR does not read file names with accent Til: r-sig-geo@r-project.org Kopi: Roger Bivand Dear all, My plateform is Windows 7. I am meeting trouble when reading a shapefile with rgdal:readOGR when the file name includes an accent. For instance, readOGR("./track génét/gélinotte/2017/Trémontagne","trace_chaux_du_dombief.shp") is well read BUT readOGR("./track génét/gélinotte/2017/Trémontagne","tracé_chaux_du_dombief.shp") gives Error in ogrInfo(dsn = dsn, layer = layer, encoding = encoding, use_iconv = use_iconv, : Cannot open layer In both cases accents in the path are well accepted. The difference just come from accent in the filename. Any idea about a workaround (except trivial: manually changing accents to non accent ;-): I have tens of files to read)? Best, Patrick [[alternative HTML version deleted]] ___ R-sig-Geo mailing list R-sig-Geo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo