as.MAPraster: Convert Raster objects into MAPraster objects

View source: R/as.MAPraster.R

as.MAPrasterR Documentation

Convert Raster objects into MAPraster objects

Description

as.MAPraster converts a RasterLayer or RasterStack object into a 'MAPraster' object (data.frame) for easy plotting with ggplot.

Usage

as.MAPraster(raster_object)

Arguments

raster_object

RasterLayer or Rasterstack object to convert into a MAPraster.

Value

as.MAPraster returns a MAPraster object (data.frame) containing the below columns.

  1. x - x coordinates of raster pixels

  2. y - y coordinates of raster pixels

  3. z - value of raster pixels

  4. raster_name - name of raster for which values are stored in z

See Also

getRaster:

to download rasters directly from MAP.

as.MAPraster:

to convert RasterLayer/RasterStack objects into a 'MAPraster' object (data.frame) for easy plotting with ggplot.

autoplot.MAPraster:

to quickly visualise MAPraster objects created using as.MAPraster.

Examples

# Download PfPR2-10 Raster for Madagascar in 2015 and visualise this on a map.
## Not run: 
MDG_shp <- getShp(ISO = "MDG", admin_level = "admin0")
MDG_PfPR2_10 <- getRaster(surface = "Plasmodium falciparum PR2-10", shp = MDG_shp, year = 2015)
MDG_PfPR2_10 <- as.MAPraster(MDG_PfPR2_10)
autoplot(MDG_PfPR2_10)
## End(Not run)

#Download global raster of G6PD deficiency from Howes et al 2012 and visualise this on a map.
## Not run: 
G6PDd_global <- getRaster(surface = "G6PD Deficiency Allele Frequency")
G6PDd_global <- as.MAPraster(G6PDd_global)
autoplot(G6PDd_global)
## End(Not run)


malaria-atlas-project/malariaAtlas documentation built on Nov. 5, 2023, 2:03 p.m.