Community Data Science Workshops (Spring 2015)/Day 2 Projects/Socrata: Difference between revisions

From CommunityData
(Created page with "right|250px __NOTOC__ == Building a Dataset using the Socrata API and data.seattle.gov == In this project, we will explore a few ways to gat...")
 
(update links)
 
(18 intermediate revisions by 3 users not shown)
Line 1: Line 1:
[[File:Socrata-square-color.png|right|250px]]
[[File:Socrata-square-color.png|right|250px]]
[[File:SeattleGovLogoHome.png|right|250px]]
__NOTOC__
__NOTOC__
== Building a Dataset using the Socrata API and data.seattle.gov ==
== Building a Dataset using the Socrata API and data.seattle.gov ==
Line 7: Line 8:
=== Goals ===
=== Goals ===


* Get set up to build datasets with the Socrata API
* Get set up to build datasets with the [http://dev.socrata.com/consumers/getting-started.html Socrata API]
* Have fun collecting different types of data from data.seattle.gov
* Have fun collecting different types of data from data.seattle.gov
* Practice reading and extending other people's code
* Practice reading and extending other people's code
* Create a few collections of different types of data from Socrata that you can do research with in the final section
* Create a few collections of different types of data from Socrata that you can do research with in the final workshop session


=== Download and test the Socrata project ===
=== Download the Socrata project ===
<font size="+1">[http://jtmorgan.net/cdsw/april25scripts.zip Click here to download the Socrata scripts]</font>


If you are confused by these steps, go back and refresh your memory with the [[Community Data Science Workshops (Spring 2015)/Day 0 setup and tutorial|Day 0 setup and tutorial]] and [[Community Data Science Workshops (Spring 2015)/Day 0 tutorial|Day 0 tutorial]]
If you are confused by these steps, go back and refresh your memory with the [[Community Data Science Workshops (Fall 2015)/Day 0 setup and tutorial|Day 0 setup and tutorial]] and [[Community Data Science Workshops (Fall 2015)/Day 0 tutorial|Day 0 tutorial]]


(Estimated time: 10 minutes)
(Estimated time: 10 minutes)


* [[Community Data Science Workshops (Spring 2015)/Socrata project Windows setup|Windows]]
=== Topics to cover ===
* [[Community Data Science Workshops (Spring 2015)/Socrata project OS X setup|OS X]]
* [[Community Data Science Workshops (Spring 2015)/Socrata project Linux setup|Linux]]
 
=== Example topics to cover in Lecture ===


* explain Socrata open data platform, exists on other government websites
* explain Socrata open data platform, exists on other government websites
* navigate to [http://en.wikipedia.org/w/api.php api page] and show the documentation, point out examples
* navigate to [http://en.wikipedia.org/w/api.php api page] and show the documentation, point out examples
* introduce the [https://en.wikipedia.org/wiki/Special:ApiSandbox API sandbox] as a tool for building queries
* introduce the [https://www.hurl.it API sandbox] as a tool for building queries
* looking at the images within a page http://en.wikipedia.org/w/api.php?action=query&titles=Seattle&prop=images&imlimit=20&format=jsonfm
 
* change the city with a custom URL
=== Example questions ===
* edit count http://en.wikipedia.org/w/api.php?action=query&list=users&ususers=Benjamin_Mako_Hill|Jtmorgan|Sj|Mindspillage&usprop=editcount&format=jsonfm
* What Seattle neighborhood has the most art galleries? - [http://jtmorgan.net/cdsw/neighborhood_culture1.py neighborhood_culture1.py]
* get the content of the main page http://en.wikipedia.org/w/api.php?format=json&action=query&titles=Main%20Page&prop=revisions&rvprop=content
* What Seattle neighborhood has the most square feet devoted to arts & culture?  - [http://jtmorgan.net/cdsw/neighborhood_culture2.py neighborhood_culture2.py]
* example programs: [http://mako.cc/teaching/2014/cdsw-autumn/wikipedia-raw1-unicode-problems-example.py wikipedia-raw1-unicode-problems-example.py] (note: this is an example of Unicode problems when running this on Windows), [http://mako.cc/teaching/2014/cdsw-autumn/wikipedia-raw2-mudslide-edit.py wikipedia-raw2-mudslide-edit.py]
* Which trail gets more bike traffic per month--the [[w:Burke-Gilman_Trail|Burke Gilman]] or the [[w:Mountains_to_Sound_Greenway|Mountain to Sound Trail]]?  - [http://jtmorgan.net/cdsw/traffic_counter1.py traffic_counter1.py], [http://jtmorgan.net/cdsw/traffic_counter2.py traffic_counter2.py]
* Do people use the trails less when it's cold? [http://jtmorgan.net/cdsw/monthly_weather.py monthly_weather.py]
* Does the Burke-Gilman get more bike or pedestrian traffic? [http://jtmorgan.net/cdsw/bike_and_peds1.py bike_and_peds1.py]
* What is the primary commute direction on the Burke Gilman? [http://jtmorgan.net/cdsw/bike_and_peds1.py bike_and_peds2.py]
 
;Other example questions
* What day of the week does the Burke Gilman have the most total traffic?
* What day has the most pedestrian traffic?
* What ''time of day'' has the most southbound traffic, on average?
* How many shoplifting calls has SPD responded to this month so far?


=== Resources ===
=== Resources ===
* [https://en.wikipedia.org/w/api.php?action=help&modules=query API documentation for the query module]
* [https://www.hurl.it API Sandbox]
* [https://en.wikipedia.org/wiki/Special:ApiSandbox API Sandbox]
* [http://web6.seattle.gov/mnm/ API-powered app]
* [[Sample API queries]]
[http://dev.socrata.com/consumers/getting-started.html API resources]
* Example that saves command-line output into a text file: <code>python wikipedia-raw2-mudslide-edit.py > OsoRevisionData.txt</code>
*[http://dev.socrata.com/docs/filtering.html filtering results]
*[http://dev.socrata.com/docs/datatypes/timestamp.html dealing with timestamps]
*[http://dev.socrata.com/docs/queries.html writing API queries]
 
;Datasets
*[https://data.seattle.gov/Community/Seattle-Cultural-Space-Inventory/vsxr-aydq Seattle Cultural Space Inventory]
*[https://data.seattle.gov/Transportation/MTS-Trail-west-of-I-90-Bridge/u38e-ybnc MTS trail bike/ped traffic]
*[https://data.seattle.gov/Transportation/Burke-Gilman-Trail-north-of-NE-70th-St-Bike-and-Pe/2z5v-ecg8 Burke Gilman trail bike/ped traffic]
*[https://data.seattle.gov/Transportation/Road-Weather-Information-Stations/egc4-d24i Road temps in Seattle]
*[https://data.seattle.gov/Public-Safety/Seattle-Police-Department-911-Incident-Response/3k2p-39jp SPD 911 incident respose]
 
;Videos
* https://data.seattle.gov/videos
* https://www.youtube.com/watch?v=YlKzXTrTLOQ
* https://www.youtube.com/watch?v=Whfp8ojMf0U
* https://www.youtube.com/watch?v=Vd6bwz3ivVA
 
;Other Socrata sites
* https://data.austintexas.gov/
* https://data.cityofchicago.org/
* https://data.cityofnewyork.us/
 
[[Category:Spring_2015_series]]

Latest revision as of 01:21, 19 October 2015

Socrata-square-color.png
SeattleGovLogoHome.png

Building a Dataset using the Socrata API and data.seattle.gov[edit]

In this project, we will explore a few ways to gather data from data.seattle.gov using the Socrata API. Once we've done that, we will extend this to code to create our own datasets of civic data that we might be able to use to ask and answer questions in the final session.

Goals[edit]

  • Get set up to build datasets with the Socrata API
  • Have fun collecting different types of data from data.seattle.gov
  • Practice reading and extending other people's code
  • Create a few collections of different types of data from Socrata that you can do research with in the final workshop session

Download the Socrata project[edit]

Click here to download the Socrata scripts

If you are confused by these steps, go back and refresh your memory with the Day 0 setup and tutorial and Day 0 tutorial

(Estimated time: 10 minutes)

Topics to cover[edit]

  • explain Socrata open data platform, exists on other government websites
  • navigate to api page and show the documentation, point out examples
  • introduce the API sandbox as a tool for building queries

Example questions[edit]

Other example questions
  • What day of the week does the Burke Gilman have the most total traffic?
  • What day has the most pedestrian traffic?
  • What time of day has the most southbound traffic, on average?
  • How many shoplifting calls has SPD responded to this month so far?

Resources[edit]

API resources

Datasets
Videos
Other Socrata sites