Learn R Programming

GSIF (version 0.5-5.1)

getID: Derive 1 degree cell IDs

Description

Derives ID's of the 1 degree cells in the default land mask for a given polygon defining the spatial domain of interest.

Usage

# S4 method for SpatialPolygons
getID(obj, pixsize = 3/3600, empty.tif = FALSE, 
      compress = FALSE, zipname = set.file.extension(tempfile(tmpdir = getwd()), "zip"))

Arguments

obj

object of class "SpatialPolygons"; must be in geographical coordinates (WGS84)

pixsize

grid cell size in decimal degrees (set at 0.0008333333 or 100 m around equator)

empty.tif

logical; specify whether a GeoTiff mask file should be created

compress

logical; specify whether to compress GeoTiffs

zipname

(optional); zip archive file name

Value

The output is a vector of grid cell ID names e.g. W79_N83. These can be further used to automate digital soil mapping for large areas.

See Also

landmask

Examples

Run this code
# NOT RUN {
library(sp)
## Bounding box for Malawi:
bbox = expand.grid(lon=c(32.67152, 35.915046), lat=c(-17.12721, -9.363796))
bbox[5,] <- bbox[1,]
crs = CRS("+proj=longlat +datum=WGS84")
x <- SpatialPolygons(list(Polygons(list(Polygon(bbox)), ID="1")), proj4string=crs)
ID.lst <- getID(x)
# }

Run the code above in your browser using DataLab