问题
I would like to read spatial data into R from my Oracle Spatial database.
When I execute ogrDrivers()
I do not see anything for Oracle Spatial.
And the following fails:
> require(rgdal)
> ogrInfo(dsn="OCI:myusr/mypwd@mydb:MYTABLE:")
Error in ogrListLayers(dsn = dsn) : Cannot open data source
It looks like Oracle Spatial driver is not normally built into OGR (Oracle makes it really difficult for everybody to work and interoperate with other eco-systems!).
I am wondering whether there are other ways to access Oracle Spatial data or whether it would be possible/reasonable to build and install rgdal with Oracle Spatial drivers...
Any hints is super welcome!
回答1:
The OCI plugin is one among the many that are not included in default GDAL builds. See http://www.gdal.org/ogr_formats.html for the full list of vector formats. About 1/2 of them are in the default builds. The others are not: Oracle OCI is one of them. ESRI SDE, MySQL, PostGIS are others. The main reason is that they all depend on the presence of 3rd party libraries at build time (and of course also at runtime). For Oracle that means the Oracle runtime library. This is available license free to anyone, but needs to be installed.
So, if you want to access Oracle databases through GDAL, you need to get a build that includes the Oracle OCI driver and let rgdal use that one.
Which platform do you run on ?
You can get a set of GDAL builds that include the OCI driver here for win32 and win64 as well as linux-64. There should also be a macOS build.
来源:https://stackoverflow.com/questions/42783405/how-to-read-oracle-spatial-data-with-rgdal-missing-drive