Programming


Using Python to Analyze Bald Eagles’ Nesting Habitat in Pennsylvania

PROBLEM

I have undertaken a research project to describe the characteristics of Bald Eagle’s nesting habitat to better understand the expansion of the population into urban areas in Pennsylvania (e.g., Pittsburgh) and to locate areas of suitable habitat for nesting. Because of the large number of nests across the state, I need a way to automate the process to output HTML of a table describing the habitat in each pair’s territory. I also created a script tool to allow a user to perform a fuzzy overlay analysis to find potentially suitable habitat for nesting.

ANALYSIS             

Python is a programming language that integrates easily with ArcMap through the arcpy package. The workflow for this analysis was designed to automate the process as much as possible while still being applicable to different situations. To achieve this end, I wrote code to create functions for creating shapefiles and finding land-cover and I defined a class to represent the nesting territory. The code takes a tabular file of point locations and creates a shapefile so the land-cover in a buffer distance around the point can be calculated. Land-cover data are reclassified to the Anderson system. A script tool was written to be used in a graphical user interface (GUI) that will perform a fuzzy overlay analysis to locate potentially suitable habitat and write HTML to create a webpage showing the tabular data for the land-cover in the specified nesting territory when user enters a number to represent a nest in the dialog box (Fig. 1).

Fig. 1. Graphical user interface incorporating the script tool that will output the results of a fuzzy overlay analysis and write a table to a web page.

RESULTS

There were several reusable functions that I created, including a function that reads and writes a tabular file containing coordinates and returns a shapefile of point locations, and a function that buffers these point locations by a user-input distance and calculates the area of each type of land-cover within each buffer. Another function locates areas of potential habitat and a final function sets the symbology to export a map image. The GUI outputs a map document and a map image that show the potential for Bald Eagles to occupy an area for nesting based on the results of a fuzzy overlay analysis (Fig. 2) and a table that describes the habitat around a specified nest (Fig. 3).

Fig. 2. Results of a fuzzy overlay analysis identifies areas with potential for Bald Eagles to use for nesting.
Fig. 3. Image of a table that was written to a web page showing the land-cover surrounding a Bald Eagle’s nest.

REFLECTION

With this project I learned how to write code with the Python language, and this skill can be applied to automate and document the workflow of any project using ArcMap. I learned how to define functions and create classes and to write a script tool so another user can easily leverage the power of the code without needing to understand the underlying code. This skill has several implications. I now have an easier time understanding error messages and determining the corrective action to take. Understanding how to write code that can process large amounts of data, be re-used or applied to different datasets, and used to create GUIs that allow others to easily use these tools can be applied to many future projects. Possibly more important though, is understanding how to write code with Python opened up other doors by making it easier for me to learn how to understand and write other computer languages like HTML, SQL, and JavaScript, all skills which also can be applied to future projects. While my focus is to use these coding skills to enhance my work with GIS, having a basic understanding of coding, when computer technology is a rapidly-evolving field, potentially has implications I have yet to understand.


Using an Application Program Interface for JavaScript, Hyper Text Markup Language, and Cascading Style Sheets to Develop a Custom Web-mapping Application

PROBLEM

The National Park Service needs a custom web-mapping application for George Washington Birthplace National Monument. The application needs to include operational layers and basic functionality.

ANALYSIS

I used an ArcGIS Application Program Interface (API) for JavaScript to build the web-mapping application. This involves coding with Hyper Text Markup Language (HTML) and Cascading Style Sheets (CSS). Beginning with a main HTML script, I added a reference to the desired CSS and API, and then created a map and view for the map. A require statement and a function call was used to add a basemap gallery widget to the application. Using previously published map layers, I added feature layers to the map focusing on the park. I also added a home button, layer list and legend.

RESULTS

The web-mapping application includes the basic functionality of a home button to return the user to the initial extent, a layer list with embedded legend, and a basemap gallery. The pop-ups provide additional information about a feature when clicked (Fig. 1).

Fig. 1. Interface for web-mapping application built using API for JavaScript showing legend, configured pop-up, basemap gallery, and home button.

REFLECTION

Understanding how to build web-mapping applications using code is a valuable skill. This allows customization of the application without an interface, but more importantly, understanding how to code provides additional benefits. Not only does it provide a greater understanding of the ‘inner workings’ of the application, it allows an understanding of errors and how to correct them. Understanding how one coding language works makes understanding additional languages easier.

Top