R Package Maptools

0 views
Skip to first unread message

Faith Lienhard

unread,
Aug 4, 2024, 6:01:43 PM8/4/24
to acsmalaleed
Helloto everyone I would like to know how to install the package called "maptools" in R. I was trying to do it by hand, downloading from " -project.org/src/contrib/Archive/maptools/". But I cant. After attempting the installation, the following error message appears.

If it's some legacy project you are working on, I'd consider setting up a renv environment with specific repos for this to keep those packages in project's package library and to avoid version conflicts:


The suggested course of action is to move to more current, actively developed packages. The actual type depends on your data - but for most vector data this would be sf, for spatio-temporal data stars and for raster data terra.


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.


This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.



If you have a query related to it or one of the replies, start a new topic and refer back with a link.


Set of tools for manipulating and reading geographic data, in particular 'ESRI Shapefiles'; C code used from 'shapelib'. It includes binary access to 'GSHHG' shoreline files. The package also provides interface wrappers for exchanging spatial objects with packages such as 'PBSmapping', 'spatstat', 'maps', 'RArcInfo', 'Stata tmap', 'WinBUGS', 'Mondrian', and others.


I have no problem installing and using this package in R, but I get many error messages when I try to install it in RStudio. Here is what I get after several lines of downloads completed. There are many messages that talk about 'non zero exit status.' Any help in layman's terms would be greatly appreciated.


If you are able to install olsrr through R, the package should already be available to RStudio. If not, I suspect you have multiple libraries of R packages on your computer that are not shared between R and RStudio. I would be interested in seeing what the output of the .libPaths() function is for both R and RStudio.


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.


The reason that these package will retire are primary that theirmaintainer, Roger Bivand, has retired. In principle someone could takeover maintenance, but that would be a large effort better spentdifferently. Maintenance of these two packages is hard because


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.


after that, e.g. a call to CRS("+proj=longlat") calls sf::st_crs()to validate the coordinate reference system and retrieve the WKTrepresentation. All code of the ASDAR hasbeen verified to run under these conditions. Maintainers of packagesdepending on sp can do this too when checking their packages.


I've been moving most of my workflow to using the sf package in R, and I'm trying to find the equivalent to the maptools package SpatialLinesMidPoints function - I've used this function frequently over the years and had modified to get line endpoints as well (here).


Is there an equivalent function using sf package? I've looked at st_cast and st_line_sample, but want to explicitly get midpoints of lines. I'm guessing perhaps I can make use of either st_cast or st_line_sample with slight modification to get just midpoints but struggling a bit with approach.


If the data are polygon data, the function will read GSHHS polygons into SpatialPolygons object for a chosen region, using binary shorelines from Global Self-consistant Hierarchical High-resolution (Shorelines) Geography, release 2.3.0 of February 1, 2014 ( -bin-2.3.0.zip).


If the data are line data, the borders or river lines will be read into a SpatialLines object. The data are provided in integer form as millionths of decimal degrees. Reading of much earlier versions of the GSHHS binary files will fail with an error message. The netCDF GSHHS files distributed with GMT >= 4.2 cannot be read as they are in a very different format.


The package is distributed with the coarse version of the shoreline data, and much more detailed versions may be downloaded from the referenced websites. The data is of high quality, matching the accuracy of SRTM shorelines for the full dataset (but not for inland waterbodies). In general, users will construct study region SpatialPolygons objects, which can then be exported (for example as a shapefile), or used in other R packages (such as PBSmapping). The largest land polygons take considerable time to clip to the study region, certainly many minutes for an extract from the full resolution data file including Eurasia (with Africa) or the Americas. For this reason, do not give up if nothing seems to be happening after the (verbose) message: "Rgshhs: clipping of polygons ..." appears. Clipping the largest polygons in full resolution also needs a good deal of memory.


A number of steps are taken in this implementation that are unexpected, print messages, and so require explanation. Following the extraction of polygons intersecting the required region, a check is made to see if Antarctica is present. If it is, a new southern border is imposed at the southern ylim value or -90 if no ylim value is given. When clipping polygons seeming to intersect the required region boundary, it can happen that no polygon is left within the region (for example when the boundaries are overlaid, but also because the min/max polygon values in the header may not agree with the polygon itself (one case observed for a lake west of Groningen). The function then reports a null polygon. Another problem occurs when closed polygons are cut up during the finding of intersections between polygons and the required region boundary.


Since the publication of the second edition of ASDAR ( -book.org/)ten years ago (R. S. Bivand, Pebesma, and Gomez-Rubio2013), and based on what we had learned about representingspatial data, it became clear that alternatives to spshould be sought, leading to sf, and most recently toSpatial Data Science with Applications in R (Pebesma andBivand 2023b). In parallel, Robert Hijmans started movingmore of raster processing into compiled code, leading tothe development of the terra package no longer usingrgdal or rgeos. So modernisation has beentaking place in infrastructure packages.


However, continuing to maintain both the outdated interfaces toPROJ, GDAL and GEOS as well asdeveloping sf and terra is arguably a waste ofvery limited resources, and assumes that I as maintainer will be able tocontinue to keep the packages working in the future. Since I retired twoyears ago, I have also determined that work on spdep andspatialreg are a more sensible use of my available effort,so we should acknowledge that modernisation has happened and that theretiring packages can be satisfactorily replaced by sf andterra now.


When one installs R itself, base and recommended packages also getinstalled. Among these packages are the functions needed to administerother, contributed, packages. But what are packages as understood byR?


is a directory of files which extend R, a source package (the masterfiles of a package), or a tarball containing the files of a sourcepackage, or an installed package, the result of running R CMD INSTALL ona source package.


On some platforms (notably macOS and Windows) there are also binarypackages, a zip file or tarball containing the files of an installedpackage which can be unpacked rather than installing from sources.


A directory into which packages are installed,e.g. /usr/lib/R/library: in that sense it is sometimes referred to as alibrary directory or library tree (since the library is a directorywhich contains packages as directories, which themselves containdirectories).


The sources of an R package consist of a subdirectory containing thefiles DESCRIPTION and NAMESPACE, and the subdirectories R, data, demo,exec, inst, man, po, src, tests, tools and vignettes (some of which canbe missing, but which should not be empty). The package subdirectory mayalso contain files INDEX, configure, cleanup, LICENSE, LICENCE andNEWS.


Source packages can be built. This involves taking a source directoryand creating a tarball ready for distribution, including cleaning it upand creating PDF/HTML documentation from any vignettes it maycontain.


Source packages (and most often tarballs) can be checked, when a testinstallation is done and tested (including running its examples); also,the contents of the package are tested in various ways for consistencyand portability.

3a8082e126
Reply all
Reply to author
Forward
0 new messages