Upgrade to Pro — share decks privately, control downloads, hide ads and more …

AAGW3 - Jubal Harpster - Agriculture Open Data API for the Techincal User

CGIAR-CSI
March 25, 2013

AAGW3 - Jubal Harpster - Agriculture Open Data API for the Techincal User

CGIAR-CSI

March 25, 2013
Tweet

More Decks by CGIAR-CSI

Other Decks in Research

Transcript

  1. API – What is It and why should I care

    Application Programming Interface So other people can access our knowledge Opening data is great
  2. The OData Protocol is an application-level protocol for interacting with

    data via RESTful web services. The protocol supports the description of data models and the editing and querying of data according to those models. Pioneered by Microsoft. Adoption by SAP, IBM, NetFlix, eBay and growing Regular SQL over HTTP
  3. CODE! Request (all the harvest choice categories ordered by name

    ): http://208.109.190.171/harvestchoiceapi/0.1/api/categories?$orderby=Name desc Response: [{"Name":"Markets","Subcategories":[{"Name":"Market Access","Aggregates":[{"Name":"travel time","Indicators":[{"Id":385,"ColumnName":"TT_20K","MicroLabel":"Avg. travel time 20K+","Unit":"hours","Year":null,"DecimalPlaces":1,"ClassificationType":"continuous","AggType":"AVG","AggFormula":null},{"Id":386,"ColumnName":"TT_50K","MicroLabel":"Avg. travel time 50K+","Unit":"hours","Year":null,"DecimalPlaces":1,"ClassificationType":"continuous","AggType":"AVG","AggFormula":null},{"Id":387,"ColumnName":"TT_PORT","MicroLabel":"Avg. TT Nearest Port","Unit":"hours","Year":null,"DecimalPlaces":1,"ClassificationType":"continuous","AggType":"AVG","AggFormula":null},{"Id":389,"ColumnName":"TT_100K","MicroLabel":"Avg. travel time 100K+","Unit":"hours","Year":null,"DecimalPlaces":1,"ClassificationType":"continuous","AggType":"AVG","AggFormula":null},{"Id":390,"ColumnName":"TT_250K","MicroLabel":"Avg. travel time 250K+","Unit":"hours","Year":null,"DecimalPlaces":1,"ClassificationType":"continuous","AggType":"AVG","AggFormula":null},{"Id":391,"ColumnName":"TT_500K","MicroLabel":"Avg. travel time 500K+","Unit":"hours","Year":null,"DecimalPlaces":1,"ClassificationType":"continuous","AggType":"AVG","AggFormula":null}]}]}]},{"Name":"Farming System","Subcategories":[{"Name":"Banana/Plantain","Aggregates":[{"Name":"irrigated","Indicators":[{"Id":116,"ColumnName":"BANP_I_Y","MicroLabel":"Irr. banana/plant. yield","Unit":"kg/ha","Year":2000,"DecimalPlaces":0,"ClassificationType":"continuous","AggType":"WGHTD","AggFormula":"SUM(BANP_I_R)/SUM(BANP_I_H)*1000"},{"Id":117,"ColumnName":"BANP_I_R","MicroLabel":"Irr. banana/plant. prod.","Unit":"mt","Year":2000,"DecimalPlaces":0,"ClassificationType":"continuous","AggType":"SUM","AggFormula":null},{"Id":118,"ColumnName":"BANP_I_H","MicroLabel":"Irr. banana/plant. area","Unit":"ha","Year":2000,"DecimalPlaces":0,"ClassificationType":"continuous","AggType":"SUM","AggFormula":null}]},{"Name":"rainfed","Indicators":[{"Id":176,"ColumnName":"BANP_R_Y","MicroLabel":"Rainfed banana/plant. yield","Unit":"kg/ha","Year":2000,"DecimalPlaces":0,"ClassificationType":"continuous","AggType":"WGHTD","AggFormula":"SUM(BANP_R_R)/SUM(BANP_R_H)*1000"},{"Id":177,"ColumnName":"BANP_R_R","MicroLabel":"Rainfed banana/plant.prod.","Unit":"mt","Year":2000,"DecimalPlaces":0,"ClassificationType":"continuous","AggType":"SUM","AggFormula":null},{"Id":178,"ColumnName":"BANP_R_H","MicroLabel":"Rainfed banana/plant.area","Unit":"ha","Year":2000,"DecimalPlaces":0,"ClassificationType":"continuous","AggType":"SUM","AggFormula":null}]},{"Name":"total","Indicators":[{"Id":56,"ColumnName":"BANP_Y","MicroLabel":"Banana/plant. yield","Unit":"kg/ha","Year":2000,"DecimalPlaces":0,"ClassificationType":"continuous","AggType":"WGHTD","AggFormula":"SUM(BANP_R)/SUM(BANP_H)*1000"},{"Id":57,"ColumnName":"BANP_R","MicroLabel":"Banana/plant. prod.","Unit":"mt","Year":2000,"DecimalPlaces":0,"ClassificationType":"continuous","AggType":"SUM","AggFormula":null},{"Id":58,"ColumnName":"BANP_H","MicroLabel":"Banana/plant. area","Unit":"ha","Year":2000,"DecimalPlaces":0,"ClassificationType":"continuous","AggType":"SUM","AggFormula":null}]}]},{"Name":"Barley","Aggregates":[{"Name":"irrigated","Indicators":[{"Id":98,"ColumnName":"BARL_I_Y","MicroLabel":"Irr. barley yield","Unit":"kg/ha","Year":2000,"DecimalPlaces":0,"ClassificationType":"continuous","AggType":"WGHTD","AggFormula":"SUM(BARL_I_R)/SUM(BARL_I_H)*1000"},{"Id":99,"ColumnName":"BARL_I_R","MicroLabel":"Irr. barley prod.","Unit":"mt","Year":2000,"DecimalPlaces":0,"ClassificationType":"continuous","AggType":"SUM","AggFormula":null},{"Id":100,"ColumnName":"BARL_I_H","MicroLabel":"Irr. barley area","Unit":"ha","Year":2000,"DecimalPlaces":0,"ClassificationType":"continuous","AggType":"SUM","AggFormula":null}]},{"Name":"rainfed","Indicators":[{"Id":158,"ColumnName":"BARL_R_Y","MicroLabel":"Rainfed barley yield","Unit":"kg/ha","Year":2000,"DecimalPlaces":0,"ClassificationType":"continuous","AggType":"WGHTD","AggFormula":"SUM(BARL_R_R)/SUM(BARL_R_H)*1000"},{"Id":159,"ColumnName":"BARL_R_R","MicroLabel":"Rainfed barley
  4. CODE! Request (listing of countries that make up COMESA ):

    http://208.109.190.171/harvestchoiceapi/0.1/api/countrycollections?$filter=name eq 'COMESA' Response: [{"name":"COMESA","label":"COMESA Countries","code":"XYA","group":"Economic Regions","ISOs":["AGO","BDI","COM","EGY","DJI","KEN","LBY","MDG","MWI","MUS","ERI","Z WE","RWA","SYC","SDN","SWZ","UGA","ETH","COD","ZMB"]}]
  5. CODE! Request (Just the population categories ): http://208.109.190.171/harvestchoiceapi/0.1/api/categories?$filter=Subcategories/any(s:s/ Name%20eq%20'Population') Response:

    [{"Name":"Demographics","Subcategories":[{"Name":"Income and Poverty","Aggregates":[{"Name":"total","Indicators":[{"Id":266,"ColumnName":"TPOV_PT125","MicroLabel":"Total $1.25 poverty hcr.","Unit":"percent","Year":2005,"DecimalPlaces":1,"ClassificationType":"continuous","AggType":"WGHTD","AggFormula":"SUM(TPOV_PT125*PN05_TOT)/SUM(PN05_TOT)"},{"Id":267,"Colu mnName":"TPOV_PT200","MicroLabel":"Total $2 poverty hcr.","Unit":"percent","Year":2005,"DecimalPlaces":1,"ClassificationType":"continuous","AggType":"WGHTD","AggFormula":"SUM(TPOV_PT200*PN05_TOT)/SUM(PN05_TOT)"}]}]},{"Name":"P opulation","Aggregates":[{"Name":"rural","Indicators":[{"Id":9,"ColumnName":"PN00_RUR","MicroLabel":"Rural population '00","Unit":"persons","Year":2000,"DecimalPlaces":0,"ClassificationType":"continuous","AggType":"SUM","AggFormula":null},{"Id":12,"ColumnName":"PN05_RUR","MicroLabel":"Rural population '05","Unit":"persons","Year":2005,"DecimalPlaces":0,"ClassificationType":"continuous","AggType":"SUM","AggFormula":null},{"Id":380,"ColumnName":"PD_RU00","MicroLabel":"Rural pop. density","Unit":"persons/sq. km","Year":2000,"DecimalPlaces":1,"ClassificationType":"continuous","AggType":"WGHTD","AggFormula":"SUM(PN00_RUR)/SUM(AREA_TOTAL)*100"},{"Id":381,"ColumnName":"PD_RU05"," MicroLabel":"Rural pop. density","Unit":"persons/sq. km","Year":2005,"DecimalPlaces":1,"ClassificationType":"continuous","AggType":"WGHTD","AggFormula":"SUM(PN05_RUR)/SUM(AREA_TOTAL)*100"}]},{"Name":"total","Indicators":[{"Id":8," ColumnName":"PN00_TOT","MicroLabel":"Total population '00","Unit":"persons","Year":2000,"DecimalPlaces":0,"ClassificationType":"continuous","AggType":"SUM","AggFormula":null},{"Id":11,"ColumnName":"PN05_TOT","MicroLabel":"Total population '05","Unit":"persons","Year":2005,"DecimalPlaces":0,"ClassificationType":"continuous","AggType":"SUM","AggFormula":null}]},{"Name":"urban","Indicators":[{"Id":10,"ColumnName":"PN00_URB ","MicroLabel":"Urban population '00","Unit":"persons","Year":2000,"DecimalPlaces":0,"ClassificationType":"continuous","AggType":"SUM","AggFormula":null},{"Id":13,"ColumnName":"PN05_URB","MicroLabel":"Urban population '05","Unit":"persons","Year":2005,"DecimalPlaces":0,"ClassificationType":"continuous","AggType":"SUM","AggFormula":null}]}]}]}]
  6. CODE! To Come: Indicator(s) by geography (points, polygons) Custom aggregations

    Quick start applications Just about anything that can be done with SQL