Broccoli: A State Comparison
Created: 2011-09-21 07:09:43
Last updated: 2011-09-21 07:09:41
Imports data from NY and NJ to compare broccoli harvest vs. planting rates across the two states. The workflow is currently set to evaluate data from 1960 to 1965.
Source: Compiled by ERS from data of USDA, National Agricultural Statistics Service, Vegetables Final Estimates.
Preview
Run
Run this Workflow in the Taverna Workbench...
Workflow Components
Authors (1)
Titles (1)
Broccoli: A State Comparison |
Descriptions (1)
Imports data from NY and NJ to compare broccoli harvest vs. planting rates across the two states. The workflow is currently set to evaluate data from 1960 to 1965.
Source: Compiled by ERS from data of USDA, National Agricultural Statistics Service, Vegetables Final Estimates. |
Dependencies (0)
Processors (7)
Name |
Type |
Description |
SpreadsheetImport |
spreadsheet |
Importer for the NY spreadsheet. |
GenerateGraphURL |
beanshell |
Generates a URL in Google Charts format. ScriptStringBuilder sb = new StringBuilder();
sb.append("http://chart.apis.google.com/chart?");
sb.append("cht=bvg");
sb.append("&chs=650x300");
sb.append("&ch=");
sb.append("&chxt=x,y,y");
sb.append("&chbh=5,1,5");
sb.append("&chxr=0,");
sb.append(Float.parseFloat(years.get(0)).intValue());
sb.append(",");
sb.append(Float.parseFloat(years.get(years.size() - 1)).intValue());
sb.append(",2|20000,4000,1000");
sb.append("&chds=0,3000");
sb.append("&chxl=2:|Area%20used");
sb.append("&chxp=2,50");
sb.append("&chco=336666,339999,CC66FF,CC33CC");
sb.append("&chdl=Area%20Planted%20NY|Area%20Harvested%20NY|Area%20Planted%20NJ|Area%20Harvested%20NJ");
sb.append("&chtt=Crop%20Output%20in%20New%20York%20and%20New%20Jersey");
if (title != void) {
sb.append("&chtt=");
sb.append(type);
}
if (data != void) {
sb.append("&chd=t:");
for (int i = 0; i < data.size(); i++) {
List data1 = (List) data.get(i);
for (int j = 0; j < data1.size(); j++) {
Float value = Float.parseFloat(data1.get(j));
sb.append(value.intValue());
if (j+1 < data1.size()) {
sb.append(",");
}
}
if (i+1 < data.size()) {
sb.append("|");
}
}
}
graphURL = sb.toString(); |
Get_Image_From_URL |
localworker |
Retrieves the Google Chart image from Google and passes it to Taverna's results panel. ScriptURL inputURL = null;
if (base != void) {
inputURL = new URL(new URL(base), url);
} else {
inputURL = new URL(url);
}
byte[] contents;
if (inputURL.openConnection().getContentLength() == -1) {
// Content size unknown, must read first...
byte[] buffer = new byte[1024];
int bytesRead = 0;
int totalBytesRead = 0;
InputStream is = inputURL.openStream();
while (bytesRead != -1) {
totalBytesRead += bytesRead;
bytesRead = is.read(buffer, 0, 1024);
}
contents = new byte[totalBytesRead];
} else {
contents = new byte[inputURL.openConnection().getContentLength()];
}
int bytesRead = 0;
int totalBytesRead = 0;
InputStream is = inputURL.openStream();
while (bytesRead != -1) {
bytesRead = is.read(contents, totalBytesRead, contents.length - totalBytesRead);
totalBytesRead += bytesRead;
if (contents.length==totalBytesRead) break;
}
image = contents;
|
Beanshell |
beanshell |
Takes spreadsheet information and prepares it for the Google Chart URL generator. Scriptdata = new ArrayList();
headers = new ArrayList();
headers.add(areaplantedNY.remove(0));
headers.add(areaharvestedNY.remove(0));
headers.add(areaplantedNJ.remove(0));
headers.add(areaharvestedNJ.remove(0));
data.add(areaplantedNY);
data.add(areaharvestedNY);
data.add(areaplantedNJ);
data.add(areaharvestedNJ);
year.remove(0);
years = year; |
NY_value |
stringconstant |
New York broccoli harvest spreadsheet source. Valuehttp://dl.dropbox.com/u/11440153/PS3-NY-Broccoli.xls |
NJ_value |
stringconstant |
New Jersey broccoli harvest spreadsheet source. Valuehttp://dl.dropbox.com/u/11440153/PS3-NJ-Broccoli.xls |
SpreadsheetImport_2 |
spreadsheet |
Importer for the NJ spreadsheet. |
Beanshells (2)
Name |
Description |
Inputs |
Outputs |
GenerateGraphURL |
Generates a URL in Google Charts format. |
title
data
headers
years
|
graphURL
|
Beanshell |
Takes spreadsheet information and prepares it for the Google Chart URL generator. |
year
areaplantedNY
areaharvestedNY
areaplantedNJ
areaharvestedNJ
|
data
headers
years
|
Datalinks (12)
Source |
Sink |
NY_value:value |
SpreadsheetImport:fileurl |
Beanshell:data |
GenerateGraphURL:data |
Beanshell:headers |
GenerateGraphURL:headers |
Beanshell:years |
GenerateGraphURL:years |
GenerateGraphURL:graphURL |
Get_Image_From_URL:url |
SpreadsheetImport:Year |
Beanshell:year |
SpreadsheetImport:area_planted |
Beanshell:areaplantedNY |
SpreadsheetImport_2:area_planted |
Beanshell:areaplantedNJ |
SpreadsheetImport:area_harvested |
Beanshell:areaharvestedNY |
SpreadsheetImport_2:area_harvested |
Beanshell:areaharvestedNJ |
NJ_value:value |
SpreadsheetImport_2:fileurl |
Get_Image_From_URL:image |
graph |
Uploader
License
All versions of this Workflow are
licensed under:
Version 1
(of 1)
Credits (1)
(People/Groups)
Attributions (3)
(Workflows/Files)
Shared with Groups (1)
Featured In Packs (0)
None
Log in to add to one of your Packs
Attributed By (1)
(Workflows/Files)
Favourited By (0)
No one
Statistics
Other workflows that use similar services
(0)
There are no workflows in myExperiment that use similar services to this Workflow.
Comments (0)
No comments yet
Log in to make a comment