Hunter College OpenData Showcase:
Getting Started





Warm-up: Turtles & GIS Locations

In this section, we will use Trinkets, an on-line version of Python,

Turtles

We'll start by drawing shapes with the turtle library of Python. A library is an extra chunk of code, on top of what Python already has in it. Some libraries are built-in to Python, and some are designed by users which you can download separately.

Click the right-facing triangle (Run) button to see the program:

The program has several parts:

Challenges:

Try the following:

Harder: write a program that makes a 5-pointed star.

World Maps

We are going to use Python to make maps. Let's start by mapping cities of the world. Locations in the world are usually indicated by their longitude and latitude.

We will use those ranges to be our coordinates: (-180, -90) to (180,90). Let's map New York City (longitude: -74, latitude: 41):

Challenges:

In the trinket above, stamp the following cities (GIS coordinates are rounded to the nearest whole number):

NYC Maps

The same idea works for mapping at a local scale. Here's a map with Hunter College (longitude: -73.964, latitude: 40.768):

Since we are working with very small differences in numbers, we wrote a separate function to convert the longitude and latitude into numbers large enough for the turtle package to use. To plot a point with our map, we use

	teddy.goto(scalePoints(lon,lat))
where lon and lat are the GIS coordinates of our points.

Challenges:

In the trinket above, stamp the following locations in different colors:

Mapping NYC Library Locations

NYC Open Data stores the GIS coordinates for many datasets. For example, the location of New York City libraries is stored in a format easily read by spreadsheet programs. The "Comma Separated Values" (CSV) files have each column separated by columns. Here's some of the library CSV file from NYC Open Data:

The first column has the longitude and latitude of the library. The next contains the name of the library. Additional columns have more details about the address and location.

Let's use the GIS coordinates from this OpenData file to map the 115th Street Library. It's at (-73.95353074430393, 40.80297988196676). Our trinket maps do not have that precision, so, we can round to: (-73.954, 40.803) and write:

	teddy.goto(scalePoints(-73.954, 40.803))

Challenges

Stamp the locations of

onto a map of New York City. The GIS coordinates are in the above image of the CSV file.

What's Next?

Next, we'll explore ways to have Python work through the OpenData files with a fabulous package called Pandas (see Using Structured Data).

Sponsored by the Hunter College Department of Computer Science.