Maps of solar radiation

(This article was first published on Omnia sunt Communia! » R-english, and kindly contributed to R-bloggers)

The Atmospheric Science Data Center (ASDC) at NASA Langley Research Center offers several data sources. For example, it is possible to download a text file with the 22-year (July 1983 – June 2005) monthly and annual average of global horizontal irradiation.

nasafile <- ''
nasa <- read.table(file=nasafile, skip=13, header=TRUE)

With this data, R and the solaR package we can calculate (for example) the global effective irradiation incident on several surfaces: a fixed PV generator, a two-axis tracker and a N-S horizontal tracker. First, let’s plot the original data using some spatial packages:


proj <- CRS('+proj=latlon +ellps=WGS84')
nasaSP <- SpatialPixelsDataFrame(points=coords, data=datos, proj4string=proj)

world <- map("world", plot=FALSE)

llCRS <- CRS("+proj=latlong +ellps=WGS84")
world_sp <- map2SpatialLines(world, proj4string=llCRS)

paleta=colorRampPalette(rev(brewer.pal('YlOrRd', n=9)))
paleta2=colorRampPalette((brewer.pal('RdBu', n=11)))
paleta3=heat.ob ##From hexbin

mapa <- list('sp.lines', world_sp)
spplot(nasaSP["Ann"], col.regions=paleta3, sp.layout=mapa)

Now we can calculate the global effective irradiation with solaR (NOTE: this loop spends some time to finish. The results are available here.)

gefNasa <- matrix(nrow=N, ncol=3)

for (i in 1:N){
 gefFixed <- calcGef(lat=lat, prom=prom)
 gef2x <- calcGef(lat=lat, modeRad='prev', prev=gefFixed, modeTrk='two')
 gefHoriz <- calcGef(lat=lat, modeRad='prev', prev=gefFixed, modeTrk='horiz')
 gefNasa[i, ] <- sapply(list(gefFixed, gef2x, gefHoriz), function(x)$Gefd)

gefNasaDF <-
names(gefNasaDF) <- c('Fixed', 'Two', 'Horiz')

Ok, we got it. Let’s build an Spatial object with it:

gefNasaSP <- SpatialPixelsDataFrame(points=coords, data=gefNasaDF, proj4string=proj)

And now we can plot the results. First, the two-axis tracker:

ncuts <- 7
colContour <- paleta3(ncuts)[2]

spplot(gefNasaSP['Two'], sp.layout=mapa,
 col.regions=paleta3, colorkey=list(space='bottom'),
 contour=TRUE, cuts=ncuts, col=colContour, lwd=0.5,

then, the N-S horizontal tracker:

spplot(gefNasaSP['Horiz'], sp.layout=mapa,
col.regions=paleta3, colorkey=list(space='bottom'),
contour=TRUE, cuts=ncuts, col=colContour, lwd=0.5,

and now the fixed generator:

spplot(gefNasaSP['Fixed'], sp.layout=mapa,
col.regions=paleta3, colorkey=list(space='bottom'),
 contour=TRUE, cuts=ncuts, col=colContour, lwd=0.5,

Finally, let’s plot the irradiation incident on a NS horizontal tracker versus the irradiation incident on a fixed surface for the latitudes between -60º and 60º. I use the violin and box plots as described here.

gefNasaSP$HorizFixed <- gefNasaSP$Horiz/gefNasaSP$Fixed

bwplot(HorizFixed~cut(Lat, pretty(Lat, 40)),
 xlab='Latitude', ylab=expression(G[ef]^{horiz}/G[ef]^{fixed}),,
 panel = function(..., box.ratio) {
 panel.violin(..., col = "lightblue",
 varwidth = FALSE, box.ratio = box.ratio)
 panel.bwplot(..., col='black',
 cex=0.8, pch='|', fill='gray', box.ratio = .1)
 par.settings = list(box.rectangle=list(col='black'),
 plot.symbol = list(pch='.', cex = 0.1)),
 scales=list(x=list(rot=45, cex=0.6)),

To leave a comment for the author, please follow the link and comment on their blog: Omnia sunt Communia! » R-english. offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...

If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Tags: , , , , ,

Comments are closed.

Search R-bloggers


Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)