Download Rgdal

0 views
Skip to first unread message

Keiko Middlekauff

unread,
Jul 22, 2024, 10:01:50 AM7/22/24
to matttisipost

Summary: Packages rgdal, rgeos and maptools will retire by theend of 2023 . We describe where their functionality will go, whatpackage maintainers can or should do, and which steps we will take tominimize the impact on dependent packages and on reproducibility ingeneral.

download rgdal


Download File ✏ ✏ ✏ https://byltly.com/2zDVyg



More modern packages like sf (since 2016), stars (2018) and terra(2020) also link to GDAL, GEOS and PROJ and should be able to take overthe role that rgdal and rgeos now have in the future. In this blogwe describe how we envision this to happen.

Package raster has rgdal in Suggests:, but uses it intensively toread and write common raster formats. A lot of functions in rgdal wereadded there specifically with usage by raster in mind. The risk thatraster will stop working when rgdal retires is however limited,because (i) package terra is being developed and is meant to entirelyreplace raster, (ii) raster currently imports terra, and (iii) asterra directly links to GDAL, GEOS and PROJ, functions currently inrgdal but needed (only) by raster could relatively easily be movedto terra.

Package sp currently suggests both rgeos and rgdal. It usesrgdal for the validation of CRS objects (proj4string or WKTdescriptions of coordinate reference systems), and it uses rgeos tosort out which rings are holes when a SpatialPolygons object does nothave a flag indicating this. This only happens for saved objects thatare at least 10 years old. Both functionalities (CRS validation, holedetection) can however easily be substituted by functions in packagesf.

I'm not entirely sure what you mean, but it sounds like you will probably have to ask whoever administers the server to fix this for you. Most R packages do not have complex non-R system requirements, but for the ones that do (like rgdal), you usually need to look at the package's CRAN page under "System requirements" to see what the package requires, and then figure out how to install those non-R tools on your system. Sometimes this is as easy as using the Linux system's built-in package manager (e.g., apt or yum), but not always. Sometimes the R package maintainer will have a website with more detailed installation instructions (if so, it will also be linked from the CRAN page).

Also note that if you are following a tutorial that uses a rgdal call it is likely to be an oldish one (considering the breakneck dynamics of open source development) and liable to contain dated code. This can be in form of practices no longer considered "best" and / or using superseded tools & techniques - such as ggplot2::fortify() instead of ggplot2::geom_sf() to draw a map.

A few months ago, I upgraded to R 4.2.0 and had to reinstall all or most of the installed packages. I started immediately having problems with geospatial packages, and I ended up having two versions of GDAL, PROJ and GEOS installed. I eventually had to manually delete all GDAL files and install them again from scratch. Now I've managed to make sf spdep and tmap work, but I have not been able to install other packages such as getSpatialData or OpenStreetMap, i.e. the ones that still depend on rgdal. The message I get is the following when I try installing them.

The super-powerful grandfather of functions for reading vector-based spatial data is readOGR from the package rgdal. You can use this function to read in dozens of different formats but the syntax can be odd and, importantly, is different for different input types. As an example, you might surprised to learn that one of these lines of code for reading a shapefile will work fine and one will fail can you guess which is which?

Note that this post is limited to reading and writing vector data. 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.

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. 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. But, if possible, I prefer to use one function, one package for reading spatial files and so this post focuses on readOGR.

Working with rgdal is not pretty but it's a powerful and important tool for reading vector data. Knowing the quirks and creating a cheat sheet for yourself will save a lot of hand wringing and allow you to start having fun with spatial analysis in R.

Provides bindings to the 'Geospatial' Data Abstraction Library ('GDAL') (>= 1.11.4) and access to projection/transformation operations from the 'PROJ' library. Use is made of classes defined in the 'sp' package. Raster and vector map data can be imported into R, and raster and vector 'sp' objects exported. The 'GDAL' and 'PROJ' libraries are external to the package, and, when installing the package from source, must be correctly installed first; it is important that 'GDAL' < 3 be matched with 'PROJ' < 6. From 'rgdal' 1.5-8, installed with to 'GDAL' >=3, 'PROJ' >=6 and 'sp' >= 1.4, coordinate reference systems use 'WKT2_2019' strings, not 'PROJ' strings.

760c119bf3
Reply all
Reply to author
Forward
0 new messages