[R-sig-Geo] issue with readOGR

Roger Bivand Roger@B|v@nd @end|ng |rom nhh@no
Sun Nov 10 14:34:38 CET 2019


On Sat, 9 Nov 2019, Abdoulaye Sarr wrote:

> Platform is osx.
>
> Thanks
>
> On Sat, Nov 9, 2019 at 6:11 PM Abdoulaye Sarr <abdoulayesar using gmail.com>
> wrote:
>
>> output from list.files:
>>
>>      "dhaka_div.shx"        "dhaka_gazipur.cpg"
>>  "dhaka_gazipur.dbf"    "dhaka_gazipur.prj"    "dhaka_gazipur.qpj"
>>  "dhaka_gazipur.shp"
>>  "dhaka_gazipur.shx"    "dhaka.dbf"            "dhaka.prj"
>>  "dhaka.shp"
>> "dhaka.shx"            "indicator.csv"        "r_val.csv"
>>

>From this we see that "indicator.csv" is not (immediately) a file that has 
an appropriate driver (it needs a *.vrt to say which columns are which, 
see https://gdal.org/drivers/vector/csv.html). Valid layers should be 
"dhaka" and "dhaka_gazipur", but not "dhaka_div", for which  only the 
*.shx is shown.

Try ogrListLayers(path.expand("/Volumes/DS2S/R_QGIS_codes//Data")) to try 
to detect valid layers. If you really meant "indicators", use 
paste0("CSV:", file.path(path.expand("/Volumes/DS2S/R_QGIS_codes//Data"), 
"indicators.csv")) as per the GDAL vector driver help page.

Roger

>> On Sat, Nov 9, 2019 at 5:07 PM Roger Bivand <Roger.Bivand using nhh.no> wrote:
>>
>>> On Fri, 8 Nov 2019, Abdoulaye Sarr wrote:
>>>
>>>> I am trying to read a shapefile using readOGR but keep getting error
>>>> messages:
>>>> map =
>>>> readOGR(dsn=path.expand("/Volumes/DS2S/R_QGIS_codes//Data"),"indicator")
>>>> Error in ogrInfo(dsn = dsn, layer = layer, encoding = encoding,
>>> use_iconv =
>>>> use_iconv,  :
>>>>  Cannot open layer
>>>
>>> What is "/Volumes/DS2S/R_QGIS_codes//Data"? If a network drive, some OGR
>>> drivers are known not to work with them (or that used to be the case).
>>> Which OS/Platform is this? Is the repeated "//" correct? Can you see the
>>> file running list.files("/Volumes/DS2S/R_QGIS_codes//Data") ?
>>>
>>> Roger
>>>
>>>>
>>>> What could be causing the problem? sp 1.3-2
>>>>
>>>> Thanks
>>>> as
>>>>
>>>>       [[alternative HTML version deleted]]
>>>>
>>>> _______________________________________________
>>>> R-sig-Geo mailing list
>>>> R-sig-Geo using 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.Bivand using nhh.no
>>> https://orcid.org/0000-0003-2392-6140
>>> https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en
>>>
>>
>
> 	[[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo using 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.Bivand using nhh.no
https://orcid.org/0000-0003-2392-6140
https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en



More information about the R-sig-Geo mailing list