Colorado State University Logo | Summer 21: CS 150 - Culture and Coding (AUCC 3B/GT-AH3) Colorado State University Logo | Summer 21: CS 150 - Culture and Coding (AUCC 3B/GT-AH3)
Summer 21: CS 150 - Culture and Coding (AUCC 3B/GT-AH3)
Computer Science

Practical Project > Glacial Data

"The World Glacier Inventory (WGI) contains information for over 130,000 glaciers. The WGI is based primarily on aerial photographs and maps with most glaciers having one data entry only. Hence, the data set can be viewed as a snapshot of the glacier distribution in the second half of the 20th century. It is based on the original WGI (WGMS 1989) from the World Glacier Monitoring Service (WGMS)." - National Snow and Ice Data Center

The provided comma-separated-value file has been modified and contains only select rows and columns to provide a file that is easier to parse. Visit this link and click on the User Guide tab to find more information about the data in the file.

Details

The glacier dataset is as described above and includes the following columns.

  • WGI_GLACIER_ID
    A 12-character unique glacier identifier

  • POLITICAL_UNIT
    2-character abbreviation for the name of the country or territory in which the glacier is located.

  • CONTINENT_CODE
    1-digit code for the continent in which the glacier is located

  • GLACIER_NAME
    Name of the glacier

  • LATITUDE
    The latitude of the glacier in decimal degrees North or South

  • LONGITUDE
    The longitude of the glacier in decimal degrees East or West

  • MEAN_ELEV
    The mean elevation is the altitude of the contour line, in meters above sea level, that halves the area of the glacier

  • FORM
    A 1-digit code that describes the form of the glacier

  • SOURCE_NOURISH
    1-digit code that describes the source of nourishment for the glacier

  • TOTAL_AREA
    The total area of the glacier in a horizontal projection in square kilometers

Required Methods To Implement (graded)

We will grade the following methods. Please note, that while there may be different ways to implement them, and you are free to even write helper methods (which we did ourselves) - we need the method names to match the following specification.

CSVReader

This file specifically is used to read the Comma Separated Value files using a Scanner Object. We also used it to help store the indices of the columns in constant variables for easy use in GenderStats.java.

public void initialize(String file)

This method will initialize a class level scanner object based on a File (new File(…)). The name of the file will be passed in. You can assume it is a correct name, but you should also try and catch the IOException that is required by calling new file. The following code can help you get started. You may also want to look at the Digital Humanities lab for an example.

Here is some example code that will help you.

try {
     fileScanner = new Scanner(new File(file));
 }catch (IOException io) {
     io.printStackTrace();
}

public boolean hasNext()

Returns if the scanner has more lines to read if the scanner has been initialized. If the scanner hasn’t been initialized, it will return false. Looking at how scanner checks to see if more lines need to be read will help with this method.

public String[] getNext()

If the scanner has more lines to read, it reads the line and returns a String array of all the values in the line - broken up by the comma (‘,’) delimiter! This is essentially how CSV files are stored.

Stats.java

This file is the main driver file of your program. It will help figure out what things you want to calculate.

Output

The other test all look at the output to standard out, so you are free to name the methods whatever you want, as long as they print out in a similar manner. I strip all whitespace in the tests and ignore case, so that isn’t as big of a deal.

The output should be in the format of

Area Average: 2.034
Highest Latitude Name: VOSTOK2
Longest Glacier Name: Shinchula Glacier
Most Common Glacier Form: 5

This also shows the four pieces of information you should look for: average area, highest latitude, longest glacier name, and the most common form among the glaciers. These outputs only represent the format and do not reflect any cases.

Suggestions / Insights

When working through this dataset, we found helper methods were essential to break up the work. Arrays are essential to get this done without a bunch of typing. Our actual solution didn’t have that many lines of code. It also helped to put static final variables in the CSVReader file that matches up with the column names. This way, my other code would know which index was which column. For example:

public final static int LATITUDE = 4;

Think about what of the given information will be useful in finding this information out.

References

  • WGMS, and National Snow and Ice Data Center (comps.). 1999, updated 2012. World Glacier Inventory, Version 1. Boulder, Colorado USA. NSIDC: National Snow and Ice Data Center. doi: https://doi.org/10.7265/N5/NSIDC-WGI-2012-02. Fall 2018.

Computer Science Department

279 Computer Science Building
1100 Centre Avenue
Fort Collins, CO 80523
Phone: (970) 491-5792
Fax: (970) 491-2466

Summer 21: CS 150 - Culture and Coding (AUCC 3B/GT-AH3)

Survey of computer science, formal logic, and computational thinking. Explores the historical, gender, and cultural perspectives on the role of technology in society. Includes learning a basic programming language. Students will be expected to write small programs, and construct written arguments on ways in which technology influences our modern culture. Previous computer science experience not necessary.