Does anyone know of a method to get (raster) data out of an ESRI v10 File Geodatabase in R?
ESRI offers a C++ API (for Linux and Windows), so I guess in principle it should be possible for an R package to retrieve (and write) data to a Geodatabase. I could not find any packages capable of doing this though.
Apparently rgdal now supports file geodatabase read access:
library(rgdal)
subset(ogrDrivers(), grepl("GDB", name))
ogrListLayers("/path/to/folder.gdb")
Worked for me on Windows, R v3.2.0, rgdal v0.9-3.
A quick google led me to the following page:
http://www.gdal.org/ogr/drv_filegdb.html
Which suggest gdal supports file geodatabase. Probably, R then also supports the format through a properly built rgdalpackage. In essence, if the standalone gdal has support, the rgdal package built against that should also read the file geodatabase.
GDAL does not have the ability to read a raster from a File GeoDatabase.
http://erouault.blogspot.fi/2014/01/ogr-openfilegdb-driver.html
https://gis.stackexchange.com/questions/62030/use-gdal-python-to-add-rasters-tiff-to-an-esri-file-geodatabase
Working with rasters in file geodatabase (.gdb) with GDAL
It can read vector feature classes, however. This makes me confident that rgdal also does not support reading raster layers. In fact, ESRI's own FileGDB API does not have raster support.
Unfortunately, this means that you will need to use ESRI tools to export your raster layers to a format that you can use in R. Hopefully there will soon be an open source solution for accessing ESRI GDBs.
Related
I was just updating R and some libraries and came across a problem. The latest raster package 3.5-15 would no longer recognize a geotiff file that I have been using for a few years (see example here). Working backwards it appears that an older version of rgdal (or one of its dependencies) will still recognize it.
Not sure what the issue is here but this type of geotiff is regularly retrieved from a REST client service from landfire.gov (https://landfire.gov/data_access.php).
I am on MacOSX 11.4 Big Sur.
I have just installed on my computer https://postgresapp.com, which bundles PostgreSQL together with the needed libraries for PostGIS (proj, geos, and gdal).
I am able to use command line functions like ogr2ogr, gdalinfo etc. from my terminal, indicating that gdal is successfully installed.
I now want to install the "sf" package for R version 4.1.0. I am able to successfully install "sf", but the PostgreSQL driver is missing when I use the native installation
install.packages("sf")
According to the sf documentation and things I have read elsewhere on stack, this is a known issue for MacOSx, and the recommended workaround for this problem is to separately install gdal using homebrew or the kyngchaos binaries. However, I would like to use the gdal installation used by the postgresapp binary mentioned earlier so that there is only one installation on my computer..
According to the postgresapp installation documentation (https://postgresapp.com/documentation/install.html), the relevant paths are:
Binaries: /Applications/Postgres.app/Contents/Versions/latest/bin
Headers: /Applications/Postgres.app/Contents/Versions/latest/include
Libraries: /Applications/Postgres.app/Contents/Versions/latest/lib
Therefore, when combined with the "sf" documentation my assumption is that the following should work.
install.packages("sf", configure.args = "--with-gdal-lib=/Applications/Postgres.app/Contents/Versions/latest/lib/"
Although I receive no errors or warnings, this does not fix the problem for me as sf::st_drivers() still does not list the PostgreSQL driver as an option. Can someone please help me figure out what additional configuration arguments, if any, are needed to get sf to recognise the Postgres driver?
In my shinyapp I try to transform a sf feature (with EPSG:4326) sf::st_transform(sf_feature, crs = sf::st_crs(4839)), but when deploying on shinyapps.io an error occurs:
GDAL Error 1: No PROJ.4 translation for source SRS, coordinate transformation initialization has failed.
On the shinyapps.io server the geolibraries are as follows:
GEOS 3.5.1, GDAL 2.2.2, PROJ 4.9.2
With a free account shinyapps.io blocks connections to other servers. As far as I know the sf package depends on GEOS, GDAS and other services to provide support for certain features (see the web site). That is most likely the reason, why it does not work on a free shinyapps.io account.
Solutions are obvious:
use other packages
get a paid account
Aside from that I do not think there is much you can do.
I am trying to use the rgdal package to open multiple Sentinel-2 data of JPEG2000 format.
The issue I am running into is:
Error in .local(.Object, ...) :
d:/data/T35SMD_20161227T091402_B01.jp2' not recognised as a supported file format.
Although, I have updated my installation of the rgdal package and use updated gdal binaries that support JPEG2000, which had support introduced in v1.9.0.
rgdal: version: 1.2-5, (SVN revision 648)
Loaded GDAL runtime: GDAL 2.0.1, released 2015/09/15
When I perform gdalDrivers() command, the entry for JPG2000 is not listed there among other drivers.
Can anyone please tell me how could I solve this problem? I have plenty of S-2 data and converting them to tiff in QGIS or any similar program is no option for me.
I have also found few similar questions on this theme (c.f. open jpeg2000 sentinel 2 in r), however it seems there is no straight answer yet.
Use the command-line utility gdal_translate, as documented here: http://www.gdal.org/frmt_sentinel2.html. You will have a lot more flexibility, and likely better speed and memory handling. Example that is given there is:
gdal_translate SENTINEL2_L1C:S2A_OPER_MTD_SAFL1C_PDMC_20150818T101440_R022_V20150813T102406_20150813T102406.xml:10m:EPSG_32632 10m.tif -co TILED=YES --config GDAL_CACHEMAX 1000 --config GDAL_NUM_THREADS 2
There's not really a solid argument for doing that much heavy lifting in R, especially through something that is essentially a wrapper.
I am trying to import geodatabase GSE files into R and I do not know how to get them in a format that can be analyzed by bioconductor software can you tell me how to do so?
Have you tried the GEOquery package? Be sure to read the vignette