Skip to content

Commit

Permalink
version 3.6-30
Browse files Browse the repository at this point in the history
  • Loading branch information
rhijmans authored and cran-robot committed Oct 2, 2024
1 parent ea7b2e2 commit a86d47a
Show file tree
Hide file tree
Showing 14 changed files with 58 additions and 124 deletions.
8 changes: 4 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: raster
Type: Package
Title: Geographic Data Analysis and Modeling
Version: 3.6-26
Date: 2023-10-12
Version: 3.6-30
Date: 2024-10-02
Imports: Rcpp, methods, terra (>= 1.7-29)
LinkingTo: Rcpp
Depends: sp (>= 1.4-5), R (>= 3.5.0)
Expand Down Expand Up @@ -48,7 +48,7 @@ Authors@R: c(
person("Rafael", "Wueest", role = "ctb")
)
NeedsCompilation: yes
Packaged: 2023-10-12 15:29:22 UTC; rhijm
Packaged: 2024-10-02 16:19:18 UTC; rhijm
Author: Robert J. Hijmans [cre, aut] (<https://orcid.org/0000-0001-5872-2872>),
Jacob van Etten [ctb],
Michael Sumner [ctb],
Expand Down Expand Up @@ -82,4 +82,4 @@ Author: Robert J. Hijmans [cre, aut] (<https://orcid.org/0000-0001-5872-2872>),
Rafael Wueest [ctb]
Maintainer: Robert J. Hijmans <[email protected]>
Repository: CRAN
Date/Publication: 2023-10-14 13:40:12 UTC
Date/Publication: 2024-10-02 18:10:02 UTC
26 changes: 13 additions & 13 deletions MD5
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
c76d096eed243669e391c2a9b2898214 *DESCRIPTION
616a8626b5e2d29494b6911fe3901887 *DESCRIPTION
315d9d3afd561fc33ff5c841443463cd *NAMESPACE
8e63a09f55c46c99cf9a490c8003992f *NEWS
8cc868c6b5aefe4c2d43d28df06ede95 *R/AAAClasses.R
Expand Down Expand Up @@ -51,7 +51,7 @@ a923bbded975e2e9310c9347341e5935 *R/clamp.R
aa25fdab6a595011f6fce25d025a44fd *R/click.R
9795a18891818eb4f1a1ba68dfe26c7e *R/clump.R
42f4ce4c4c63b11e53075a31b0c13ceb *R/clusterR.R
f363fcfbe6390201db7ce17d88dcae73 *R/coerce.R
211d03d38c6df560db7394443e6b663f *R/coerce.R
64718da05b72235575db2b4a9c5c23a7 *R/col2RGB.R
bf4d69cac9d779c34c8ea0c35fcefec6 *R/colortable.R
a11cba46329452f8813d48eebceefb32 *R/commonDataType.R
Expand Down Expand Up @@ -114,7 +114,7 @@ d9e423f2f087717358a143b3e3783182 *R/focalFun.R
df748c28cef50ea3cbb394c0cdf37c7a *R/gdal.R
e287001bfef2ccf762ba8bc699a472ce *R/gdalFormats.R
1ae7377892ef1ed123d059a662685317 *R/geom.R
ab7e6ed8eacdc7a8f394c566a904e76d *R/getData.R
318989174d8d8f761e1b5ec13031fab9 *R/getData.R
c5b10dfa091157a1e06cf895770d1855 *R/getValues.R
19e6b95c32096e06597017822aa0196b *R/getValuesBlock.R
56e8aa51ba1f14da020d9b7ca2bf3b74 *R/getValuesFocal.R
Expand Down Expand Up @@ -186,7 +186,7 @@ bb31c0c2988b37ade71a1dfb4ead82a4 *R/multiCore.R
6689657ec2f6ee8f452d8518c85048f5 *R/netCDFtoRasterGMT.R
e3d175453f106a173c6468aac9d8b221 *R/netCDFtoStack.R
9d390903127668d44bd0e8d8a28f58fd *R/netCDFutil.R
5ddb53419ced9c8a751cb97b5cc210e7 *R/netCDFwriteCD.R
e47ad4d2dbf446eba4ece542c54fd519 *R/netCDFwriteCD.R
37522b26afb24d01cfa59da00bff77be *R/newPLot.R
a237e75cc8df7a7dd461de127c7edd3e *R/nlayers.R
41009ec66bcfc072b8b48b2a1024b4e8 *R/notused.R
Expand Down Expand Up @@ -214,12 +214,12 @@ c126b01a725630014b349313fb3a8bde *R/quad.R
95b29f77d650c98773a298f50be12238 *R/quantile.R
e33733f012e4c0301210c3507da2b1b9 *R/randomize.R
556aaf7db457486cb7df6897f1c8ad4e *R/range.R
b87b7f9fa1408cdbc9710cc34956f1d3 *R/raster.R
aa4f50e0ff7535d01d4b54208d052799 *R/raster.R
a2055ed091243612e7808add0efca0bc *R/rasterFromASCII.R
cc61a03d30a2ea21038f583739ef2824 *R/rasterFromBIL.R
3d507ee8905b1d9a6ecbc693c1b00230 *R/rasterFromCells.R
d8f4dab32e4a6c4d5e2afe0a57484155 *R/rasterFromFile.R
0f1d508a09b3883be64f6d95504531b6 *R/rasterFromGDAL.R
fa7b12069744eb66d8683a4f6cc362ae *R/rasterFromGDAL.R
2185c54b649441070057362c1e74405f *R/rasterFromIDRISI.R
0697310be1e94ae77f795174f4aa55ce *R/rasterFromRasterFile.R
f4187c536c35a1d94c20a147ea3f522b *R/rasterFromSAGA.R
Expand Down Expand Up @@ -303,7 +303,7 @@ d491f4a320eca9c0492159e1af236894 *R/whiches.max.R
420475b13f5f379840dbccd46027a130 *R/writeAllGDAL.R
a321dcb2a3233d4f4a0c2f28164b81f7 *R/writeAllRaster.R
63056e8f9aa5e12e1756129db1622360 *R/writeRaster.R
141ac47f36501d5fcc84e224536bbfec *R/writeStartStop.R
6b8f3699942545055604fb07840ea82c *R/writeStartStop.R
42ac06c70c37349c13a2f373fe3cd305 *R/writeStartStopAscii.R
2b8cc77c4a7661ee5c2f5efd6e05494f *R/writeStartStopGDAL.R
911c3ded9e17fddf71166fdef1de3787 *R/writeStartStopRaster.R
Expand All @@ -316,7 +316,7 @@ d9397fdb238463ae0c9929aad0347658 *R/zApply.R
b9cc0e22fcbdd704f6199fecaf8a4382 *R/zonal.R
227cc9e91a64d5685fc5f6eeac885ee2 *R/zoom.R
cae0440f702e35b1a156006c63c84a0b *R/zzz.R
2836b2c5db38c9819380bd093383d89d *build/partial.rdb
b54db8794555342c4feee5fe0b1b8f5b *build/partial.rdb
836fc2bffa338d9f9a721e00d9cd6078 *inst/external/countries.rds
c85d689dcf4c7101db48cbab30338201 *inst/external/lux.dbf
e729936bf5360b37a15365fc295a1901 *inst/external/lux.prj
Expand Down Expand Up @@ -401,7 +401,7 @@ a2211ba5968a68c6332a20c252057b6f *man/draw.Rd
6925d6bc7957b6b87db4f1358a9a1587 *man/extend.Rd
3e1812cd7ab432f6c489d0a379b71e6f *man/extension.Rd
a62d75d75a5463b705c677bef1f9f8c6 *man/extent.Rd
3d704c2c3008b1c2c961c0d0ddb260d4 *man/extract.Rd
8f98c76fea3fb9a5123f93dab458c476 *man/extract.Rd
2fb4b5d1bbd2b58d86eb07b85bd5fea0 *man/extractIndex.Rd
4992ec4f3c4cf67fc729cfdfd14c235e *man/extremeValues.Rd
476d2a9a163fabd07529ee6e3517d845 *man/factor.Rd
Expand All @@ -414,14 +414,14 @@ a377c61fd6a34877273a510ab4666112 *man/focal.Rd
bf4e4b4fed61e6736bc2431c3170d7cb *man/freq.Rd
6c9ea2d96231490cbcb98073aa0c6ab0 *man/gainoffset.Rd
949934a51c6e89070e1fee9294f3d83f *man/geom.Rd
6f3db4ce27959a4672feae4b0e0aad1f *man/getData.Rd
f783eb3bd185383708e9c489cc6d3b55 *man/getData.Rd
513b858bb6a9ab24eedd6eb2b5f75eb6 *man/getValues.Rd
772a6d5a8788870e3d080d30b8215e65 *man/getValuesBlock.Rd
1d2d02b7b6d01609620e99c9e4698324 *man/getValuesFocal.Rd
1e4b75fab3932c064d4ea45eeafb28a1 *man/gridDistance.Rd
99f6d8e81767134d112ed6cad5def120 *man/hdrFiles.Rd
67c344771513764f6a310712cd7d8964 *man/headtail.Rd
3d455a90e7d04c15bef11694148d8125 *man/hillShade.Rd
a9654f73a56bd8639af3931e94d5c3ae *man/hillShade.Rd
122e387fd0d4562d493b3c31bd1072d4 *man/hist.Rd
163dde188853a5fb7d982077926457c6 *man/image.Rd
79abf72046372d5e62cbdb3b1afc27bb *man/iniFile.Rd
Expand Down Expand Up @@ -455,7 +455,7 @@ bc10b6371999e39d3849bd647641ab57 *man/projectRaster.Rd
1caf0fe099e717237998bc76b0197b40 *man/projection.Rd
9cfab780186321ff86fc11a25c7ebd2c *man/properties.Rd
11c6a58182a86dceea216a0b5043ec22 *man/quantile.Rd
5120f5f7db664a3310dc5539a6e0af07 *man/raster-package.Rd
10dd019a488d8f66c74af961032dea51 *man/raster-package.Rd
dcdc942173d4152eeb736c6379f2cb55 *man/raster.Rd
ab6c9c74ebd8d520d9e2e30d91c3cacb *man/rasterFromCells.Rd
618d1612c39114a43c92ca22582ebec7 *man/rasterFromXYZ.Rd
Expand Down Expand Up @@ -501,7 +501,7 @@ f4d47f1611ebac1c4652289dd57550bb *man/stack.Rd
e1dc88aaa384c5d14b4bbc1b393fe923 *man/subset.Rd
03e63787f46fc69ee03cc5e3ffb5cae8 *man/summary.Rd
7cebc3ff0f84b9b08725f6173fbf6bf9 *man/symdif.Rd
5e711d241175aa4a10ba08aab62f7953 *man/terrain.Rd
a14ff126872a6adced3ad700f1877769 *man/terrain.Rd
82a3a8e9c93e600e7e377e845cae05b5 *man/text.Rd
7a547a4dd038782eb213a0de1e7db06d *man/transpose.Rd
29f1f18187e8d9579a43f84a8f8cbf26 *man/trim.Rd
Expand Down
3 changes: 3 additions & 0 deletions R/coerce.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ setAs("SpatRaster", "Raster",
if ((length(usid) == 1) & (b$source[1] != "")) {
if ((nl == nrow(b)) && (b$bands[1] == 1) && (all(diff(b$bands) == 1))) {
r <- raster::brick(b$source[1])
if (nlayers(r) != nl) {
r <- r[[b$bands]]
}
} else {
r <- raster::stack(b$source[1], bands=b$bands)
}
Expand Down
18 changes: 12 additions & 6 deletions R/getData.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,20 @@
# Version 0.9
# October 2008

getData <- function(...) {

stop("getData has been removed. Please use the geodata package instead.")

}

getData <- function(name='GADM', download=TRUE, path='', ...) {

# w <- getOption('rasterGetDataWarningGiven')
# if (is.null(w)) {
warning("getData will be removed in a future version of raster\n. Please use the geodata package instead")
# options(rasterGetDataWarningGiven=TRUE)
# }
.getData <- function(name='GADM', download=TRUE, path='', ...) {

message("getData will stop working soon!\n.
Please use the geodata package instead.\n
Going to sleep for 15 seconds...")

Sys.sleep(15)

path <- .getDataPath(path)

Expand Down
8 changes: 7 additions & 1 deletion R/netCDFwriteCD.R
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,18 @@
}


.stopWriteCDF <- function(x) {
.writeRangeCDF <- function(x) {

nc <- ncdf4::nc_open(x@file@name, write=TRUE)
on.exit( ncdf4::nc_close(nc) )
ncdf4::ncatt_put(nc, x@title, 'min', as.numeric(x@data@min))
ncdf4::ncatt_put(nc, x@title, 'max', as.numeric(x@data@max))
}


.stopWriteCDF <- function(x) {

.writeRangeCDF(x)
if (inherits(x, 'RasterBrick')) {
r <- brick(x@file@name)
} else {
Expand Down
10 changes: 4 additions & 6 deletions R/raster.R
Original file line number Diff line number Diff line change
Expand Up @@ -221,12 +221,12 @@ setMethod('raster', signature(x='RasterBrick'),
r <- raster(extent(x), nrows=nrow(x), ncols=ncol(x), crs=.getCRS(x))
r@file <- x@file

r@file@blockrows <- x@file@blockrows
r@file@blockcols <- x@file@blockcols
r@file@blockrows <- x@file@blockrows[dindex]
r@file@blockcols <- x@file@blockcols[dindex]
r@file@nbands <- nlayers(x)

r@data@offset <- x@data@offset
r@data@gain <- x@data@gain
r@data@offset <- x@data@offset[dindex]
r@data@gain <- x@data@gain[dindex]
r@data@inmemory <- FALSE
r@data@fromdisk <- TRUE
r@data@haveminmax <- x@data@haveminmax
Expand All @@ -253,8 +253,6 @@ setMethod('raster', signature(x='RasterBrick'),
attr(r@data, "level") <- x@data@level
}

r@data@offset <- x@data@offset
r@data@gain <- x@data@gain
r@file@nodatavalue <- x@file@nodatavalue

} else {
Expand Down
8 changes: 8 additions & 0 deletions R/rasterFromGDAL.R
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@
r@data@min <- minv[band]
r@data@max <- maxv[band]

sc <- scoff(x)
r@data@gain <- sc[band,1]
r@data@offset <- sc[band,2]


if (is.factor(x)[1]) {
cts <- cats(x)[[1]]
if (!is.null(cts)) {
Expand All @@ -83,6 +88,9 @@
} else {
r@data@min <- minv
r@data@max <- maxv
sc <- scoff(x)
r@data@gain <- sc[,1]
r@data@offset <- sc[,2]
}

return(r)
Expand Down
6 changes: 3 additions & 3 deletions R/writeStartStop.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ function(x, filename, options=NULL, format, prj=FALSE, ...) {
}

if (prj) {
crs <-.getCRS(x)
if (crs != "") {
writeLines(wkt(x), extension(filename, "prj") )
wk <- wkt(x)
if (wk != "") {
writeLines(wk, extension(filename, "prj") )
}
}
return(x)
Expand Down
Binary file modified build/partial.rdb
Binary file not shown.
2 changes: 1 addition & 1 deletion man/extract.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ It is also possible to extract values for point locations from SpatialPolygons.
\arguments{
\item{x}{Raster* object}

\item{y}{points represented by a two-column matrix or data.frame, or \code{\link{SpatialPoints}*}; \code{\link{SpatialPolygons}*}; \code{\link[sp]{SpatialLines}}; \code{sf} spatial vector objects; \code{\link{Extent}}; or a numeric vector representing cell numbers}
\item{y}{points represented by a two-column matrix or data.frame, or \code{\link[sp]{SpatialPoints}*}; \code{\link[sp]{SpatialPolygons}*}; \code{\link[sp]{SpatialLines}}; \code{sf} spatial vector objects; \code{\link{Extent}}; or a numeric vector representing cell numbers}

\item{method}{character. \code{'simple'} or \code{'bilinear'}. If \code{'simple'} values for the cell a point falls in are returned. If \code{'bilinear'} the returned values are interpolated from the values of the four nearest raster cells.}

Expand Down
63 changes: 3 additions & 60 deletions man/getData.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -5,72 +5,15 @@
\title{Get geographic data }

\description{
Get geographic data for anywhere in the world. Data are read from files that are first downloaded if necessary. Function \code{ccodes} returns country names and the ISO codes

See the geodata package for access to more recent versions of the data available through this function, and for many other datasets.
This function has been deprecated and does not work anymore.
}

\usage{
getData(name, download=TRUE, path="", ...)
getData(...)
ccodes()
}

\arguments{
\item{name}{Data set name, currently supported are 'GADM', 'countries', 'SRTM', 'alt', and 'worldclim'. See Details for more info}
\item{download}{Logical. If \code{TRUE} data will be downloaded if not locally available}
\item{path}{Character. Path name indicating where to store the data. Default is the current working directory }
\item{...}{ Additional required (!) parameters. These are data set specific. See Details}
\item{...}{arguments}
}

\value{
A spatial object (Raster* or Spatial*)
}

\details{
'alt' stands for altitude (elevation); the data were aggregated from SRTM 90 m resolution data between -60 and 60 latitude. 'GADM' is a database of global administrative boundaries. 'worldclim' is a database of global interpolated climate data. 'SRTM' refers to the hole-filled CGIAR-SRTM (90 m resolution). 'countries' has polygons for all countries at a higher resolution than the 'wrld_simpl' data in the maptools package .

If \code{name} is 'alt' or 'GADM' you must provide a 'country=' argument. Countries are specified by their 3 letter ISO codes. Use getData('ISO3') to see these codes. In the case of GADM you must also provide the level of administrative subdivision (0=country, 1=first level subdivision). In the case of alt you can set 'mask' to FALSE. If it is TRUE values for neighbouring countries are set to NA. For example:

\code{getData('GADM', country='FRA', level=1)}

\code{getData('alt', country='FRA', mask=TRUE)}


If \code{name} is 'SRTM' you must provide 'lon' and 'lat' arguments (longitude and latitude). These should be single numbers somewhere within the SRTM tile that you want.

\code{getData('SRTM', lon=5, lat=45)}

If \code{name='worldclim'} you must also provide arguments \code{var}, and a resolution \code{res}. Valid variables names are 'tmin', 'tmax', 'prec' and 'bio'. Valid resolutions are 0.5, 2.5, 5, and 10 (minutes of a degree). In the case of \code{res=0.5}, you must also provide a \code{lon} and \code{lat} argument for a tile; for the lower resolutions global data will be downloaded. In all cases there are 12 (monthly) files for each variable except for 'bio' which contains 19 files.

\code{getData('worldclim', var='tmin', res=0.5, lon=5, lat=45)}

\code{getData('worldclim', var='bio', res=10)}


To get (projected) future climate data (CMIP5), you must provide arguments \code{var} and \code{res} as above. Only resolutions 2.5, 5, and 10 are currently available. In addition, you need to provide \code{model}, \code{rcp} and \code{year}. For example,

\code{getData('CMIP5', var='tmin', res=10, rcp=85, model='AC', year=70)}

function (var, model, rcp, year, res, lon, lat, path, download = TRUE)

'model' should be one of "AC", "BC", "CC", "CE", "CN", "GF", "GD", "GS", "HD", "HG", "HE", "IN", "IP", "MI", "MR", "MC", "MP", "MG", or "NO".

'rcp' should be one of 26, 45, 60, or 85.

'year' should be 50 or 70

Not all combinations are available. See www.worldclim.org for details.
}

\references{
\url{https://www.worldclim.org}

\url{https://gadm.org}

https://srtm.csi.cgiar.org/

\url{https://diva-gis.org/gdata}
}


\keyword{ spatial }
11 changes: 0 additions & 11 deletions man/hillShade.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,5 @@ Horn, B.K.P., 1981. Hill shading and the reflectance map. Proceedings of the IEE
}


\examples{
\dontrun{
alt <- getData('alt', country='CHE')
slope <- terrain(alt, opt='slope')
aspect <- terrain(alt, opt='aspect')
hill <- hillShade(slope, aspect, 40, 270)
plot(hill, col=grey(0:100/100), legend=FALSE, main='Switzerland')
plot(alt, col=rainbow(25, alpha=0.35), add=TRUE)
}
}

\keyword{spatial}

1 change: 0 additions & 1 deletion man/raster-package.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,6 @@ Some of these functions are in the \code{sp} package. The name in \bold{bold} is
\tabular{ll}{
\code{\link{rasterOptions}} \tab Show, set, save or get session options \cr
\code{\link{getData}} \tab Download and geographic data\cr
\code{\link{pointDistance}} \tab Distance between points \cr
\code{\link{readIniFile}} \tab Read a (windows) 'ini' file \cr
\code{\link{hdr}} \tab Write header file for a number of raster formats \cr
Expand Down
18 changes: 0 additions & 18 deletions man/terrain.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -72,22 +72,4 @@ Wilson, M.F.J., O'Connell, B., Brown, C., Guinan, J.C., Grehan, A.J., 2007. Mult
}
\examples{
\dontrun{
elevation <- getData('alt', country='CHE')
x <- terrain(elevation, opt=c('slope', 'aspect'), unit='degrees')
plot(x)
# TPI for different neighborhood size:
tpiw <- function(x, w=5) {
m <- matrix(1/(w^2-1), nc=w, nr=w)
m[ceiling(0.5 * length(m))] <- 0
f <- focal(x, m)
x - f
}
tpi5 <- tpiw(elevation, w=5)
}
}
\keyword{spatial}

0 comments on commit a86d47a

Please sign in to comment.