3

West African Population count GPW v4 data

I have a netCDF file with one variable 'gpwcount' and its lat/lot coordinates also available. The dimension of this 'gpwcount' variable is 1050 rows x 1050 columns. This file consists of population count data for the year 2015 from three west African countries that had a major Ebola outbreak. The file is attached here

I am trying to model an epidemic and run a simulation. Is there a way to add the following variables to the existing netCDF file using R (or any other tool).

The variables I would like to add are labelled,

 Exposed (1050 x 1050 grid all filled with 0);
 Infected (1050 x 1050 grid all filled with 0);
 Hospitalised (1050 x 1050 grid all filled with 0);
 Recovered (1050 x 1050 grid all filled with 0);
 Dead (1050 x 1050 grid all filled with 0);
 Prevalence (1050 x 1050 grid all filled with 0);
 Inhabitable (1050 x 1050 grid all filled with either 0 if the gpwcount in that cell is 0 or a 1 if gpwcount in that cell is greater than 0);
2

You can use the function addLayer() from package raster.

Example:

## read your file
ras_netcdf <- raster(".../episim_Africacount_0000.nc")

## let's create a similar raster, fill it with zero
ras_empty <- ras_netcdf
ras_empty[1:ncell(ras_empty)] <- 0
names(ras_empty) <- "Exposed"

# add the layer
ras_netcdf2 <- addLayer(ras_netcdf, ras_empty)

NOTE: you could also use the function ncvar_add from package ncdf4

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.