banner-nll

Importing Topographic Maps - Part 2

 

gis5

Notice the NED and Land Cover have pull-down settings on data format.  These are to be .BIL format.  Notice that the files are going to be zipped, also.  After changing the formats, scroll down to the bottom of the page and click change and save.  You will return to the request summary page and the formats should reflect the .BIL file format. See the figure below

gis6

.  We are interested in the NED at the present.  Click download and the page will extract and queue up the request.

gis7

The download file is given a number and it is a winzip file in this case.  The user clicks “save”. You are given the opportunity to change the name to something more recognizable to you.

gis702

Once the file is named and saved, download tools to manipulate and view the maps.  First, the map data is in a zip file, so we need a utility like Winzip to extract the data.  Examination copies are free downloads.  We also use the tool called LandSerf. Landserf further relies on the latest form of Java. Go to the website http://www.java.com/ for a free download. Landserf is a no-cost program downloadable from http://www.soi.city.ac.uk/~jwo/landserf/.  Download and install LandSerf. .  It is a good idea to complete the tutorial to acquaint yourself with the capabilities of the program. This is a good step-by-step tutorial that shows how to handle the files you downloaded.

 Open Winzip and select the downloaded file being used.  Extract all files in the map file.  One of these files will have the extension “ .bil”.  Select this file to open in the Landserf software.  The raster will appear in the thumbnail on the left and as the main display. Click “display relief” and it will appear in the relief form. 

The problem with this map is that it is arranged in latitude and longitude and the longitude columns vary in their length.  This would create error messages in NetLogo if we tried to read this file.  To rectify this, transform the file using project “lat long raster as a UTM”. This is a mercator projection that makes the columns all the same size and projects the map as square units of the same size.

gis8

The project is also an important time to set the size of the interface screen.  The “set raster dimensions” shows the boundaries and the E-W resolution and the N-S resolution as well as the number of columns and rows.  Remember the size of the file is determined by multiplying the columns times the rows.  Change the boundaries or change the resolution to reduce the number of columns and rows. Changing the boundaries will create a better map with greater resolution. Experiment with changing the digits in the west boundary and the east boundary until there are approximately 100 columns. The final number should be odd due to the fact that the interface screen in NetLogo is an odd number of columns wide.  Experiment with the N-S boundaries to reduce the number of rows to near 100.

Click OK and a UTM appears as the primary map.  If this map meets your expectation and shows what is desired then Click File > Save. Landserf opens a window showing where it will save the file and the type file it will save. Name this file something like “xyzmountain” and pull-down the files of type menu to find Raster as generic pointfile (.txt) and click it. Save this file.

gis9

The file is now an XYZ file with the elevations beginning in the upper left corner and continuing row by row from upper left to lower right.  This is the way NetLogo assigns values to the patches during set-up.  We now need to remove the X and Y data so that the file is only the Z or elevation data.  To do this, open Excel and click> file >open. Locate the file “xyzmountain” and double click it. The text import wizard comes up. Choose delimited.  Click Next. Step 2 asks if the delimiters are tabs. Click Next. The last window asks about column data format. It defaults to General. Click Finish.  The file comes into Excel looking like this:

 

gis10

Check the file to be sure of the length of a row.  To do this, note the value in the middle column top.  Scroll down until that value changes and note the number of columns (which is the number of the row of the change). Often, the first few rows are not full width.  That is the number of columns in the first rows does not equal the size the UTM said it would be. This is critical as the values are read in without carriage returns to indicate next row and the image will be distorted in NetLogo if the first few rows are short of the correct number of columns. This will need to be the width of the interface screen in the NetLogo program. The number of rows must be less than the number of rows in the UTM map.

Highlight the first two columns and delete them. This produces a single column file of tab delimited elevations.

Save this file as a “zmountain” file.  This file needs to be put in a folder that will also hold the NetLogo program file that will read the data into the patch setup.

In the setup of the NetLogo program, the text file must be opened and read into the variable “elevation”.  The code you will need looks like the following:

patches-own 
[elevation]

to setup
   setup-patches

end

to setup-patches
   ask patches
       [
         file-open "zmoutain.txt"
         set elevation file-read
         file-close
       ]
 end

 

To see the result, a “go” routine that scales the color according to elevation will enable the viewing of the elevation we just imported.  The following would work to do that.

to go

  ask patches with [elevation >= the midpoint elevation on  the map]    [
     set pcolor scale-color lime elevation ; Range of elevation
                                           ; might be half of
                                           ; total elevation
                                           ; change in the map.)    ]

  ask patches with [elevation < the midpoint elevation on the map]

     [
     set pcolor scale-color green elevation x y 

                                   ;(Range of elevation might be                                        ; the lower half of the total
                                   ; elevation change in the map
                                   ; x  = min value
                                   ; y = max value
 
  ]

end

Now that your topography is in the program, you should be able to  export the world file and use it again on subsequent runs.  The set-up can be run at each session as an alternate way of loading the program to run again. 


With Support from:

The NetLogo Learning Lab is part of modelingcomplexity.org, the home of the Mesa State College Center for Agent-Based Modeling.

This website is copyright by Mesa State College, 2004. All rights are reserved.

Some materials are adapted from the NetLogo User manual, and are copyright Wilensky, U. (1999). NetLogo.  Center for Connected Learning and Computer-Based Modeling. Northwestern University, Evanston, IL.