Contents
How to read spatial files into are using rgdal?
The rgdal package has been around for more than a decade and provides bindings to the incredible Geospatial Data Abstraction Library (GDAL) for reading, writing and converting between spatial formats. You need to install the rgdal package before you can run any of the code in this post.
Do you need rgdal to run geojsonio?
You need to install the rgdal package before you can run any of the code in this post. Keep in mind that there are several specialty packages for reading or writing various formats (e.g., geojsonio, plotKML) that you might consider using and I use occasinoally.
Is it possible to read GeoJSON files into R?
GeoJSON is an increasingly common format. For testing purposes, it’s fun to create and save a layer using the geojson.io site. But reading GeoJSON into R can be challenging if you’re not careful.
Which is the best way to analyze raster data in R?
For raster data I use the raster package rather than readGDAL from rgdal and I find that these functions ( raster, brick and stack) are more straightforward and work smoothly. An example of using the raster function can be found in our post on analyzing raster data in R.
Are there two feature datasets in gdb?
The .gdb contains two Feature Datasets with multiple Feature Classes within each. The problem is only one of the two Feature Datasets is being read. Specifically, I am using the NHD dataset for all states ftp://nhdftp.usgs.gov/DataSets/Staged/States/FileGDB/HighResolution/ In each state .gdb are two feature Datasets, ‘WBD’ and ‘Hydrography’.
How to read OGR file with multiple feature datasets?
You are probably reading the file with the ESRI File Geodatabase (OpenFileGDB) driver. OGR does not preserve or use feature datasets, so all the feature classes are mixed in the same flat namespace. Looking at (e.g.) NHDH_VI.gdb in ArcCatalog: Then reading the same file from a command-line prompt with ogrinfo -ro NHDH_VI.gdb
How can I read a shapefile in R?
One of these files is a .shp file! (TM_WORLD_BORDERS_SIMPL-0.3.shp) The rgdal package offers the readOGR () function that allows to read shapefile using the following syntax. As a result you get a geospatial object ( my_spdf here) that contains all the information we need for further mapping.