Hi Roger,
Am 16.07.2015 um 11:55 schrieb Roger Bivand:
Do you have other versions of GDAL on the system, and was rgdal 1.0-4
installed against GDAL 2.0.0? I believe that the package should check
that the GDAL runtime is the same as the one used to install rgdal, but
the check may not be robust. I am away until mid-August, and cannot help
with FreeBSD anyway. Does setwd() to the dsn of the shapefile help ,
then dsn=":"? Does
Yep. rgdal_1.0-4 is build against GDAL 2.0.0. Version 2.0.0 is the only
one installed, see sessionInfo() at bottom of previous mail.
Other functions like ogrDrivers() work fine:
ogrDrivers()
name
long_name write copy isVector
1 ARCGEN Arc/Info
Generate FALSE FALSE TRUE
2 AVCBin Arc/Info Binary
Coverage FALSE FALSE TRUE
3 AVCE00 Arc/Info E00 (ASCII)
Coverage FALSE FALSE TRUE
4 AeronavFAA
Aeronav FAA FALSE FALSE TRUE
5 BNA
Atlas BNA TRUE FALSE TRUE
[..snip..]
And also, ogrinfo() from package gdalUtils works fine:
gdalUtils::ogrinfo("/home/rhurlin/SpatialData/world",
"TM_WORLD_BORDERS-0.3", so=TRUE)
[1] "INFO: Open of `/home/rhurlin/SpatialData/world'"
[2] " using driver `ESRI Shapefile' successful."
[3] ""
[4] "Layer name: TM_WORLD_BORDERS-0.3"
[5] "Metadata:"
[6] " DBF_DATE_LAST_UPDATE=2008-07-30"
[7] "Geometry: Polygon"
[8] "Feature Count: 246"
[9] "Extent: (-180.000000, -90.000000) - (180.000000, 83.623596)"
[10] "Layer SRS WKT:"
[11] "GEOGCS[\"GCS_WGS_1984\","
[12] " DATUM[\"WGS_1984\","
[13] " SPHEROID[\"WGS_84\",6378137.0,298.257223563]],"
[14] " PRIMEM[\"Greenwich\",0.0],"
[15] " UNIT[\"Degree\",0.0174532925199433]]"
[16] "FIPS: String (2.0)"
[17] "ISO2: String (2.0)"
[18] "ISO3: String (3.0)"
[19] "UN: Integer (3.0)"
[20] "NAME: String (50.0)"
[21] "AREA: Integer (7.0)"
[22] "POP2005: Integer64 (10.0)"
[23] "REGION: Integer (3.0)"
[24] "SUBREGION: Integer (3.0)"
[25] "LON: Real (8.3)"
[26] "LAT: Real (7.3)"
I am afraid, I don't get you with the dsn=":" thing ;(
ogrInfo("/home/rhurlin/SpatialData/world/TM_WORLD_BORDERS-0.3.shp",
"TM_WORLD_BORDERS-0.3")
This works fine:
ogrInfo("/home/rhurlin/SpatialData/world/TM_WORLD_BORDERS-0.3.shp",
"TM_WORLD_BORDERS-0.3")
Source: "/home/rhurlin/SpatialData/world/TM_WORLD_BORDERS-0.3.shp",
layer: "TM_WORLD_BORDERS-0.3"
Driver: ESRI Shapefile; number of rows: 246
Feature type: wkbPolygon with 2 dimensions
Extent: (-180 -90) - (180 83.6236)
CRS: +proj=longlat +datum=WGS84 +no_defs
LDID: 87
Number of fields: 11
name type length typeName
1 FIPS 4 2 String
2 ISO2 4 2 String
3 ISO3 4 3 String
4 UN 0 3 Integer
5 NAME 4 50 String
6 AREA 0 7 Integer
7 POP2005 12 10 Integer64
8 REGION 0 3 Integer
9 SUBREGION 0 3 Integer
10 LON 2 8 Real
11 LAT 2 7 Real
help?
Is the shapefile in that folder? Do other drivers work? Does
example(readOGR) work?
It is the same as with ogrInfo(). With shape integrated in the dsn
string it works, without not:
tm <- readOGR("/home/rhurlin/SpatialData/world", "TM_WORLD_BORDERS-0.3")
Fehler in ogrInfo(dsn = dsn, layer = layer, encoding = encoding,
use_iconv = use_iconv, :
Cannot open data source
tm <-
readOGR("/home/rhurlin/SpatialData/world/TM_WORLD_BORDERS-0.3.shp",
"TM_WORLD_BORDERS-0.3")
OGR data source with driver: ESRI Shapefile
Source: "/home/rhurlin/SpatialData/world/TM_WORLD_BORDERS-0.3.shp",
layer: "TM_WORLD_BORDERS-0.3"
with 246 features
It has 11 fields
Many thanks for your answer and your suggestions. It seems, there is
something odd in the interpretation of the dsn string.
Best wishes,
Rainer
Roger
On Thu, 16 Jul 2015, Rainer Hurling wrote:
I am using GDAL 2.0.0 on FreeBSD and having trouble to get rgdal-1.0-4
work correctly.
(1) The error looks like this:
ogrInfo("/home/rhurlin/SpatialData/world", "TM_WORLD_BORDERS-0.3")
Fehler in ogrInfo("/home/rhurlin/SpatialData/world",
"TM_WORLD_BORDERS-0.3") :
Cannot open data source
Obviously, rgdal does not find the path and/or files, given as
parameters to functions like ogrInfo(). This problem also exists with
similar rgdal tools like for example ogrListLayers:
ogrListLayers("/home/rhurlin/SpatialData/world")
Fehler in ogrListLayers("/home/rhurlin/SpatialData/world") :
Cannot open data source
(2) The library rgdal loads fine so far:
library(rgdal)
Lade nötiges Paket: sp
rgdal: version: 1.0-4, (SVN revision 548)
Geospatial Data Abstraction Library extensions to R successfully loaded
Loaded GDAL runtime: GDAL 2.0.0, released 2015/06/14
Path to GDAL shared files: /usr/local/share/gdal
Loaded PROJ.4 runtime: Rel. 4.9.1, 04 March 2015, [PJ_VERSION: 491]
Path to PROJ.4 shared files: (autodetected)
Linking to sp version: 1.1-1
(3) On the shell, outside of R, gdal 2.0.0 gives the expected output:
ogrinfo -so "/home/rhurlin/SpatialData/world" "TM_WORLD_BORDERS-0.3"
INFO: Open of `/home/rhurlin/SpatialData/world'
using driver `ESRI Shapefile' successful.
Layer name: TM_WORLD_BORDERS-0.3
Metadata:
DBF_DATE_LAST_UPDATE=2008-07-30
Geometry: Polygon
Feature Count: 246
Extent: (-180.000000, -90.000000) - (180.000000, 83.623596)
Layer SRS WKT:
GEOGCS["GCS_WGS_1984",
DATUM["WGS_1984",
SPHEROID["WGS_84",6378137.0,298.257223563]],
PRIMEM["Greenwich",0.0],
UNIT["Degree",0.0174532925199433]]
FIPS: String (2.0)
ISO2: String (2.0)
ISO3: String (3.0)
UN: Integer (3.0)
NAME: String (50.0)
AREA: Integer (7.0)
POP2005: Integer64 (10.0)
REGION: Integer (3.0)
SUBREGION: Integer (3.0)
LON: Real (8.3)
LAT: Real (7.3)
This leads me to the assumption, that the new rgdal-1.0_4 has some
problem with path and/or file strings, at least on FreeBSD and at
least for GDAL 2.0.0.
(4) I tried to get some insight with gdb, but my skills are far to
small to get deeper. What I did:
- Run R with 'R -d gdb791'
- Load library(rgdal) within R
- Set 'bt ogrInfo' in gdb for src/ogrsource.cpp:l46
- Continue R, run the following command:
ogrInfo("/home/rhurlin/SpatialData/world", "TM_WORLD_BORDERS-0.3")
Breakpoint 1, ogrInfo (ogrsourcename=0x4b8cf458, Layer=0x4b8cf428) at
ogrsource.cpp:46
46 int nFIDs, nFields, iField, *nCount, pc=0;
(gdb) n
60 installErrorHandler();
(gdb) n
62 poDS=(GDALDataset*)
GDALOpenEx(CHAR(STRING_ELT(ogrsourcename, 0)), GDAL_OF_VECTOR, NULL,
NULL, NULL);
(gdb) n
63 if(poDS==NULL){
(gdb) bt
#0 ogrInfo (ogrsourcename=0x4b8cf458, Layer=0x4b8cf428) at
ogrsource.cpp:63
#1 0x0000000040adf576 in R_doDotCall (ofun=0x4bc14201 <ogrInfo(SEXP,
SEXP)>, nargs=2,
cargs=0x7fffffffc5e0, call=0x4aae9f78) at dotcode.c:573
#2 0x0000000040aed4a2 in do_dotcall (call=0x4aae9f78, op=0x46ceeb50,
args=0x4ab53468, env=0x4ab400b0)
at dotcode.c:1251
#3 0x0000000040b291c1 in Rf_eval (e=0x4aae9f78, rho=0x4ab400b0) at
eval.c:655
#4 0x0000000040b2dab3 in do_set (call=0x4aae6190, op=0x46cd71c8,
args=0x4aae88b0, rho=0x4ab400b0)
at eval.c:2106
#5 0x0000000040b28f71 in Rf_eval (e=0x4aae6190, rho=0x4ab400b0) at
eval.c:627
#6 0x0000000040b2c9a0 in do_begin (call=0x4aae00b0, op=0x46cd8778,
args=0x4aae61c8, rho=0x4ab400b0)
at eval.c:1716
#7 0x0000000040b28f71 in Rf_eval (e=0x4aae00b0, rho=0x4ab400b0) at
eval.c:627
#8 0x0000000040b2a256 in Rf_applyClosure (call=0x4aadc1c8,
op=0x4aade238, arglist=0x4ab40318,
rho=0x46f0a708, suppliedvars=0x46cd4f78) at eval.c:1039
#9 0x0000000040b29304 in Rf_eval (e=0x4aadc1c8, rho=0x46f0a708) at
eval.c:674
#10 0x0000000040b6ad2c in Rf_ReplIteration (rho=0x46f0a708,
savestack=0, browselevel=0,
state=0x7fffffffd580) at main.c:258
#11 0x0000000040b6aef0 in R_ReplConsole (rho=0x46f0a708, savestack=0,
browselevel=0) at main.c:308
#12 0x0000000040b6c682 in run_Rmainloop () at main.c:1009
#13 0x0000000040b6c697 in Rf_mainloop () at main.c:1016
#14 0x0000000000400a5c in main (ac=1, av=0x7fffffffe658) at Rmain.c:29
(gdb) n
64 uninstallErrorHandlerAndTriggerError();
(gdb)
65 error("Cannot open data source");
(gdb) n
Fehler in ogrInfo("/home/rhurlin/SpatialData/world",
"TM_WORLD_BORDERS-0.3") :
Cannot open data source
run_Rmainloop () at main.c:1008
1008 R_GlobalContext = R_ToplevelContext = R_SessionContext =
&R_Toplevel;
(gdb) n
1009 R_ReplConsole(R_GlobalEnv, 0, 0);
Hope, my analysis it ok so far. From here on, I am lost and could
really need some help. Please ask me, if you need more information or
if I should try something.
Many thanks in advance.
Regards,
Rainer Hurling
sessionInfo()
R Under development (unstable) (2015-07-14 r68652)
Platform: amd64-portbld-freebsd11.0 (64-bit)
Running under: FreeBSD xxx.xxx.xxx 11.0-CURRENT FreeBSD 11.0-CURRENT
#0 r285383: Sat Jul 11 10:39:33 CEST 2015
[email protected]:/usr/obj/usr/src/sys/XXX amd64
locale:
[1] C/de_DE.UTF-8/de_DE.UTF-8/C/de_DE.UTF-8/de_DE.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] rgdal_1.0-4 sp_1.1-1
loaded via a namespace (and not attached):
[1] grid_3.3.0 lattice_0.20-33
_______________________________________________
R-sig-Geo mailing list
[email protected]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo