Skip to content

Commit

Permalink
started USGS-VIZLAB#6, no style and wrong export
Browse files Browse the repository at this point in the history
  • Loading branch information
Jordan S Read committed Mar 10, 2017
1 parent 800c437 commit ff9d435
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
22 changes: 22 additions & 0 deletions scripts/visualize/visualize-map.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,28 @@ size_map_svg <- function(sp){
apply(sp::bbox(sp), 1, diff)/500000
}

visualize.map_thumbnail <- function(viz){
library(xml2)
data <- readDepends(viz)
states <- data[['state-map']]
sites <- data[['site-map']]
bars <- data[['bar-data']]
png(filename = viz[['location']], width = 250, height = 250, units = 'px')
par(mai=c(0,0,0,0), omi=c(0,0,0,0))
sp::plot(states, expandBB = c(0.7,0,0,0))
sp::plot(sites, add=TRUE, pch = 20, cex=0.1)
bars.xml <- xml2::read_xml(bars)
rects <- xml_children(bars.xml)
xleft <- xml_attr(rects, 'x') %>% as.numeric()
ys <- xml_attr(rects, 'y') %>% as.numeric()
ytop <- max(ys) - ys
ybottom <- 0
xright <- xml_attr(rects, 'width') %>% as.numeric %>% + xleft
par(new=TRUE, mar=c(0,0,10,0))
plot(0,NA, xlim = c(0,tail(xright,1)), ylim = c(0, max(ys)), axes=FALSE , ylab="", xlab="")
rect(xleft, ybottom, xright, ytop, col='dodgerblue', border = NA)
dev.off()
}
visualize.states_svg <- function(viz){
data <- readDepends(viz)
states <- data[['state-map']]
Expand Down
7 changes: 7 additions & 0 deletions viz.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,13 @@ visualize:
scripts: ["scripts/process/doy.R","scripts/visualize/visualize-map.R"]
title: "NM through the ages"
alttext: "NM gage"
-
id: thumbnail-map
location: figures/thumb-gages-ages.png
visualizer: map_thumbnail
scripts: ["scripts/visualize/visualize-map.R"]
depends: ["state-map", "site-map", "watermark", "bar-data"]
export: true
publish:
-
id: vizCSS
Expand Down

0 comments on commit ff9d435

Please sign in to comment.