swinkler149 / 901K-Sandbox

901K Sandbox Project
4 stars 1 forks source link

Obtain Agriculture Statistics data via API from USDA #36

Open SMIOP opened 9 years ago

eahollin commented 9 years ago

Had anyone already located a source for this? I am definitely having difficulty finding a direct API into USDA for chickens; I found some promising stuff for cattle, but no chickens! I did, however, find a source of relevant data from the Food and Agriculture Organization of the United Nations (FAO), and it does provide livestock counts at the state level for the US. Unfortunately, it just provides csv files that you customize and only provides one type of livestock at a time. I pulled stats for pigs, cattle, sheep and chickens, and assuming I can convert this into JSON, am wondering if this works? The specificity of the task, however (i.e. use an API), made we wonder if anyone had already found a better source?

bmcelhaney commented 9 years ago

I know you can get the data from USDA/NASS online QuickStats here. I assumed the API would provide the same data as the online QuickStats data finder, but I haven't actually used the API.

eahollin commented 9 years ago

Roger that; my bad. I was too focused on the mapping aspect, so I was hunting for a geospatial API that would deliver some sort of map/feature layer for the chickens. I wasn't thinking you just meant raw data - sorry! :) I snagged an API key for QuickStats and believe I am able to get what you are looking for.

eahollin commented 9 years ago

Action Item for Bill: Please determine a suitable "Data Item" from the Chickens commodity that will still allow us to choose a State-level aggregation.

bmcelhaney commented 9 years ago

Instead of using "Census" data, I get better results using "Survey" data. So, on QuickStats, try:

eahollin commented 9 years ago

Thanks, Bill; will thy this out!

ferrx commented 9 years ago

Ed- I see you have the livestock api in place. What properties are returned in json response that I can place in the update pane? Also: I take it we don't need a picker for this item? Clicking the correlate button just implied you want to see chicken data?

ferrx commented 9 years ago

Getting these errors when trying to use grunt: server\api\livestock\livestock.controller.js line 8 col 19 'escape' is not defined. line 13 col 3 '$http' is not defined.

eahollin commented 9 years ago

OK, I've got revised api calls that pull the data you are looking for, just need to figure out this jquery stuff to execute the call on the back-end.

eahollin commented 9 years ago

sorry, I may not have had latest committed when you checked. I fixed the $http error you're seeing, but still haven't figured out the jquery call, though I think I'm close (had to npm install jquery to get it into the server config, as it was only available in the client before). I'm currently hardcoding the value of the .distinct call to return just "CHICKENS, (EXCL BROILERS) - INVENTORY", but think it would be nice to expand this for other animal types at some point, so I'd suggest leaving the picker in place. I already updated it in my version; sorry for the latent commits. :(

ferrx commented 9 years ago

Check this out for using jQuery to perform the get method: https://api.jquery.com/jquery.get/

Can you add the jQuery install command to the dependencies list on the wiki? I'll need to install that on my server as well.

eahollin commented 9 years ago

OK; finally got this working. I don't "think" it's using jquery, so I'll try yanking that out later and see what happens. Please update to latest committed revision. the client doesn't "do" anything with the chicken data yet, but it's available now.

ferrx commented 9 years ago

My laptop appears to have fallen asleep- going to wake it tonight and pull the latest build so we can see your changes.