Thursday, March 15, 2012

Building Python Based Geoprocessing ArcToolbox for Natural Gas and Oil Seeps Risk Assessment



   Natural Gas and Oil Seeps Risk Assessment

Anshu Kishore, James Kang,
Peggy Law, and Rainie Scott

Geography 173:
Geographic Information Systems Programming and Development
UCLA Geography Department



                          Click here to download source code for ArcToolbox

Introduction:
Oil and gas seeps occur like natural springs of hydrocarbons out of the ground.  These seeps are fed by natural underground accumulations of oil and natural gas.  This oil is eventually transformed from a clear fluid to a tar-like substance called asphalt.  The lighter components of the oil evaporate, and the remaining heavier oil becomes sticky and black.
Many of these spills occur inland and may affect surrounding populations as well as the natural environment.  Clearly, there is a need to evaluate and manage the impact of these seeps.  Therefore, we propose a set of tools to study the impact of natural gas and oil seepage in California.
Background:
The importance of petroleum predates written history.  Native Americans of the coastal areas of California incorporated naturally occurring oils into their cultures.  The earliest accounts of oil and gas seepages in California come to us from the European explorers in 17th century.  Native Indians such as the Chumash, Yokuts, Achomawi, and Maidu Indians used oil, tar, bitumen and other natural substances from the seeps for various ceremonial and recreational purposes.  Early California pioneers used the oil from natural seeps to grease their wagon wheels.  Settlers and ranchers in the Santa Barbara, Ventura, Los Angeles, and Orange county areas, used seeped oil for lubricating farm machinery, for tarring roofs, and for illumination.  From the 1860's to the early 1900's, every oil or gas field discovered in California was located on the basis of nearby seeps.  In California, the earliest oil exploration efforts began in areas where numerous seeps, such as Ojai and Santa Paula, occurred.  Some oil seeps, such as the La Brea Tar Pits, located near Los Angeles, killed off entire species because animals trapped in the area could not get out of the sticky tar. 
Oil seeps are environmental hazards that need to be addressed.  They can have tremendous impacts on people as well as the surrounding environment.  Some of these impacts include lower water quality and environmental pollution, in addition to other things.  As part of our project, we propose a method for evaluating and assessing the possible urban and environmental impacts associated with natural gas and oil seepage in California.  We will do this by designing a set of GIS tools that will perform various series of analysis on the seepage areas, including buffer analysis and slope and aspect analysis to determine potential spread of the oil/natural gas.
Purpose:
            The purpose of this project is to build four dynamic tools in ArcGIS to assess the effects of Natural Gas and Oil seepage in California and various California counties.  For our first assessment, we created a tool in Arcmap10 that would help the user(s) perform risk analysis assessment on the nearby population and infrastructure.  For our second assessment, we created a tool that would allow the user to analyze the effects of natural gas and oil seepage on natural features, such as parks and recreation areas.  We made these tools separately because we wanted the user to be able to choose between natural features assessment and infrastructure assessment, as well as for clarity (too many visible outputs and parameters can make the map appear cluttered) and ease of use.  For our third area assessment, we created a topographic analysis tool to analyze the potential for spread within our study region (Los Angeles County).  For our fourth and final tool, we created a code to generate a map book so that users would have the ability to view the affected area as a series of maps in a PDF file.
Map:
The map was created in ArcMap and data were collected from public domain. US Census was used to obtain data about people and demography. Esri data sources were used for infrastructure such as roads and points of interest. USGS was used to obtain data on oil seepage locations and oil well located close to it. These data were used to create a file geodatabase. The map created from the data is shown below.




Toolbox:
Our project has a toolbox with four running scripts for Environmental Impact Assessment (EIA).  The first three tools are meant to assess the impact of oil and natural gas seeps on people, local infrastructure, and natural resources, as well as to determine the potential for spread through the use of hillshade, slope, and aspect models.  Finally, a fourth tool is offered to create a map book of seep locations showing natural features and block groups around it.  The map book is a visual summary of the impact of oil seeps on people and surrounding properties.  All tools are packaged in a toolbox, and can be accessed either from ArcMap or ArcCatalog.  Opening the tool in ArcMap or ArcCatalog brings up a dialog requiring users to supply input and output parameters.  The user then executes the tool to obtain results.  The resulting layers are then added to map.  A screenshot of the toolbox is shown below.






The following tools are included in the toolbox:
Tool 1: Oil Seepage Environmental Impact Assessment on People and Infrastructure
The goal of this tool is to assess the impact of oil seeps on people and infrastructure.  U.S. Census data, made available by the ESRI website, was used to calculate the number of people affected by oil seeps.  The U.S. Census divides the population into block groups.  For our analytical purposes, we assumed a uniform distribution of the population across the census blocks.  The oil seep buffer area is assumed to be the impact area (dynamic parameter), although the user is free to use any polygon of any shape to assess the impact – in which case, the impact will be evaluated for the polygon area, instead of the buffer area considered here.  In this way, our tool is flexible and can accommodate both situations.  To compute the impact on people, we intersected the block group area with the oil seep area of impact.  People and properties located within the intersection area were said to be affected by the oil seep.  We calculated the number of affected people in the intersection area by calculating the population density and multiplying it by the area of intersection.  We identified affected properties by selecting point and line features such as schools, institutions, and roads within the area of intersection.  Finally, the number of people affected was determined by analyzing the population statistics.   For our project, we also identified the race and age of affected populations to help us better pinpoint which populations might be more vulnerable to natural gas and oil seepage spread.  For example, we determined from our analysis that seniors and young children were the two age groups most at risk and that they were the people that would likely need immediate attention.   Information such as this can be used by different agencies to better allocate resources such as firefighters, police, and emergency response vehicles in the case of a natural disaster or other emergency.  A screenshot of the dialog box for this tool is shown below:



The required inputs for this tool are as follows: Oil Seepage location(s), block groups, buffer distance, institutes, and roads.  The required outputs are the buffer areas, the intersection of block groups and buffer area, the summary statistics table name, the impacted institutes, and the impacted roads feature classes.  Upon clicking OK, the tool will execute and create output feature classes, which will also be added to the map.
Tool 2: Oil Seepage Environmental Impact Assessment on Natural Features
For our second assessment, we designed a tool to help users analyze gas and oil seepage damage on natural features.  These natural features include but are not limited to recreational areas, parks, and river regions.  This tool may be used to perform analysis on an entire state (in this case the state of California), whereas Tool #1 is primarily used to perform analysis at the county level.  To use this tool, users must obtain the following shapefiles: gas and oil seepage locations in California, recreational areas, park areas, and river regions.  These shapefiles will be used by the tool to generate output shapefiles showing the user which recreational, park, and river region features would be most affected by these natural gas and oil seeps within a specified distance.  A screenshot of the dialog box is shown below.



The input is oil seep location, and natural features such as recreational areas, parks and rivers. Upon a successful execution, the tool will create output shapefiles showing the impact on natural features.
Tool 3: Oil Seepage Area Digital Elevation Model Analysis
            For our third assessment, we developed a tool that would allow users to study the potential spread of these natural gas and oil seeps within Los Angeles County, based on the assessment of local topography.  In order to run this tool, the user must first obtain a digital elevation model of their region of interest.  This type of information can be easily accessed and downloaded from the USGS Seamless Viewer website (http://seamless.usgs.gov).  The user must also remember to project the original DEM to UTM coordinates before proceeding with the analysis.  This newly projected DEM will be used as the first input for the tool.  Other necessary inputs include the azimuth angle, altitude, and zFactor, which will be at the discretion of the user.  Upon proper completion, the tool will generate three output raster images including a hillshade model, a slope model, and an aspect model of the landscape.  The user can then evaluate these images to determine the potential for natural gas/oil seepage spread (based on the steepness and direction of the slope).  A screenshot of the parameters dialog box is shown below.


Tool 4: Oil Seepage Area Map Book
The goal of this final tool is simply to create a map book that features a page by page guide of the impact and extent of each oil seep location.  The inputs for the tool are the original map document (.mxd file) with a template layout designed for the purpose of creating a map book.  The map book is then generated as a PDF file.  This book serves as a visual reference of the impact of these oil seeps, and includes the local population, properties, infrastructure, and natural features affected.  This PDF file can be emailed to anyone, even those who do not currently have ArcMap installed.  Below is a screenshot of the map book parameters dialog box.



Code Design:
Codes for all tools are written in Python script. Our scripts typically make successive calls to geoprocessing tools such as buffer, intersect, select by location, create table, create field, delete field, slope analysis, aspect analysis, whenever they are needed by the tools. Python script is used to string these geoprocessing tools together to create a more complex tool that automates number of processes that otherwise would not be possible.
Complications:
Natural gas and oil seeps have been affecting the environment for centuries.  A significant amount of seep occurs under the ocean.  Oil escapes from fractures in the ocean floor and rises up to float on top of the water.  Ideally, we should have also included the ocean in our analysis, as oil does seep into the ocean in large volumes (about 4000 gallons per day).  These seeps can also adversely affect ocean flora and fauna. 
We decided not to analyze the oil seep impact on oceans, however, because of lack of readily available data.  We therefore limited our analysis to the land area only.   In addition, while analyzing impact on population, we found that the task was computationally intensive.  Block area polygons are numerous and analyzing all of them for the State of California was not feasible within the given time frame.  As a result, we limited our analysis on block groups to just within the Los Angeles County area.  For the same reason, we also used Los Angeles County for our DEM analysis.  Natural gas and oil seepage impact on natural features was analyzed for the entire State of California, as its computation was feasible.
Conclusion:
Oil and natural gas seeps are an old natural occurrence.  Most of our oil wells have been located by observing oil seeps.  Thus, there are some benefits associated with these seeps.  These seeps have also degraded the environment and put the lives of people and animals in danger.  They have adversely affected major water bodies including lakes and rivers and have posed as a potential hazard to local populations.  Therefore, there is a clear need to manage the impact of oil and natural gas seeps on people, infrastructure, and natural resources.  In this project, we created a toolbox containing four different tools to accomplish these goals.  The accompanying document will help the user to make use of these tools in a beneficial manner.  Using these tools, we can identify the population and properties at risk from these oil seeps, and take preventive steps to mitigate the impact, resulting in safer environment for people.

References:

Source code for Oil Seeps Impact Assessment Tool

import arcpy
import os

# ---------------------------------------------------------------------------
# Project: Environmental Impact Assessment of Oil Seeps
# Anshu Kishore
# Date: March 1, 2012
# Geog 173, GIS Development and Programming
# University of California, Los Angeles
# Description: Find people and properties affected by oil seepage impact area
# ---------------------------------------------------------------------------

# Import arcpy module
import arcpy
import os

# Setup
layersDataset = "Layers"
arcpy.OverwriteOutput = True

# Define inputs and outputs - Script arguments
OilSeeps = arcpy.GetParameterAsText(0)
BlockGroup = arcpy.GetParameterAsText(1)
Out_SeepsBuffer = arcpy.GetParameterAsText(2)
BufferDistance = arcpy.GetParameterAsText(3)
Out_BufferBlocksIntersect = arcpy.GetParameterAsText(4)
Out_PopSummary = arcpy.GetParameterAsText(5)
InstitutesLA = arcpy.GetParameterAsText(6)
ImpactedInstitutesLA = arcpy.GetParameterAsText(7)
MajorRoadsLA = arcpy.GetParameterAsText(8)
ImpactedMajorRoadsLA = arcpy.GetParameterAsText(9)


arcpy.AddMessage("OilSeeps " + OilSeeps)
arcpy.AddMessage("BlockGroup " + BlockGroup)
arcpy.AddMessage("Out_SeepsBuffer " + Out_SeepsBuffer)
arcpy.AddMessage("BufferDistance " + BufferDistance)
arcpy.AddMessage("Out_BufferBlocksIntersect " + Out_BufferBlocksIntersect)
arcpy.AddMessage("Out_PopSummary " + Out_PopSummary)
arcpy.AddMessage("InstitutesLA " + InstitutesLA)
arcpy.AddMessage("ImpactedInstitutesLA " + ImpactedInstitutesLA)
arcpy.AddMessage("MajorRoadsLA " + MajorRoadsLA)
arcpy.AddMessage("ImpactedMajorRoadsLA " + ImpactedMajorRoadsLA)

#--------------------------------------------------------------------------------
# Impact assessment on people
#--------------------------------------------------------------------------------

# Calculate population density for the block polygon.
# Create a field named POP10_SQFT to store values on population density
#Verify if the field exists (from previous run), and add one if it does not
desc = arcpy.Describe(BlockGroup)
ok = False
for field in desc.fields:
    if(field.name=="POP10_SQFT"):
        ok=True
        break
if(ok==False) :
  arcpy.AddField_management(BlockGroup, "POP10_SQFT", "DOUBLE", "", "", "", "", "NULLABLE", "NON_REQUIRED", "")
  arcpy.AddMessage("POP10_SQFT field added to BlockGroup layer")
else:
  arcpy.AddMessage("POP10_SQFT field already exists in BlockGroup layer")
 
# Calculate population density for block polygon. Calculated value is stored in POP10_SQFT
arcpy.CalculateField_management(BlockGroup, "POP10_SQFT", "[POP2010] / [Shape_Area]", "", "")
arcpy.AddMessage("Population density in field POP10_SQFT calculated")

# Calculate the impact area - users can bring their area, here we will use a buffer area
arcpy.Buffer_analysis(OilSeeps, Out_SeepsBuffer, BufferDistance, "FULL", "ROUND", "NONE", "")
arcpy.AddMessage("Impact area calulated by buffering oil seep locations")

# Find blocks impacted by intersecting blocks with oil impact polygon (buffered area)
# An output polygon featrue class named Out_BufferBlocksIntersect will be created

arcpy.Intersect_analysis([BlockGroup, Out_SeepsBuffer], Out_BufferBlocksIntersect, "ALL", "", "INPUT")
arcpy.AddMessage("Block areas layer Out_BufferBlocksIntersect affected by oil seep calculated")

# Delete Fields from the intersected layer. We do not need them.
arcpy.DeleteField_management(Out_BufferBlocksIntersect, "latitude;longitude;modelgrp;POP2000;POP00_SQMI;MED_AGE;MED_AGE_M;MED_AGE_F;HOUSEHOLDS;AVE_HH_SZ;HSEHLD_1_M;HSEHLD_1_F;MARHH_CHD;MARHH_NO_C;MHH_CHILD;FHH_CHILD;FAMILIES;HSE_UNITS;VACANT;OWNER_OCC;RENTER_OCC")
arcpy.AddMessage("Fields not needed for impact assessment deleted from Out_BufferBlocksIntersect layer")

desc = arcpy.Describe(Out_BufferBlocksIntersect)
shapeName = desc.ShapeFieldName

#Get cursor
updateRows = arcpy.UpdateCursor(Out_BufferBlocksIntersect)
for updateRow in updateRows:
  feature = updateRow.getValue(shapeName)
  oid = updateRow.getValue("OBJECTID")
 
  #people affected are calculated by assuming uniform distribution
  try:
      areaIntersected = updateRow.POP10_SQFT * updateRow.Shape_area
      updateRow.WHITE = updateRow.WHITE / areaIntersected
      updateRow.BLACK = updateRow.BLACK / areaIntersected
      updateRow.ASIAN = updateRow.ASIAN / areaIntersected
      updateRow.HISPANIC = updateRow.HISPANIC / areaIntersected
      updateRow.MALES = updateRow.MALES / areaIntersected
      updateRow.FEMALES = updateRow.FEMALES / areaIntersected
      updateRow.AGE_UNDER5 = updateRow.AGE_UNDER5 / areaIntersected
      updateRow.AGE_5_17 = updateRow.AGE_5_17 / areaIntersected
      updateRow.AGE_18_21 = updateRow.AGE_18_21 / areaIntersected
      updateRow.AGE_22_29 = updateRow.AGE_22_29 / areaIntersected
      updateRow.AGE_30_39 = updateRow.AGE_30_39 / areaIntersected
      updateRow.AGE_40_49 = updateRow.AGE_40_49 / areaIntersected
      updateRow.AGE_50_64 = updateRow.AGE_50_64 / areaIntersected
      updateRow.AGE_65_UP = updateRow.AGE_65_UP / areaIntersected
      updateRows.updateRow(updateRow)
  except:
      print "problem with block feature OID: " + str(oid)
      continue
   
del updateRow
del updateRows

arcpy.AddMessage("Population affected calculated for the block")

#Do a statistics and create a summary table
statFields = "WHITE SUM;BLACK SUM;ASIAN SUM;HISPANIC SUM;MALES SUM;FEMALES SUM;AGE_UNDER5 SUM;AGE_18_21 SUM;AGE_UNDER5 SUM;AGE_22_29 SUM;AGE_30_39 SUM;AGE_40_49 SUM;AGE_50_64 SUM;AGE_65_UP SUM"

arcpy.Statistics_analysis(Out_BufferBlocksIntersect, Out_PopSummary, statFields, "")
arcpy.AddMessage("Population statistics completed")

#--------------------------------------------------------------------------------
#Find point features affected - Institutions
#--------------------------------------------------------------------------------

#Find institutions affected by oil seepage
#InstitutesLA = arcpy.GetParameterAsText(6)
#ImpactedInstitutesLA = arcpy.GetParameterAsText(7)

InstitutesLA_FeatLayer = "InstitutesLA_FeatLayer"
# Process: Make Feature Layer - needed to select features
arcpy.MakeFeatureLayer_management(InstitutesLA, InstitutesLA_FeatLayer)

# Process: Select Layer By Location
arcpy.SelectLayerByLocation_management(InstitutesLA_FeatLayer, "INTERSECT", Out_SeepsBuffer, "", "NEW_SELECTION")


# Process: Copy selected Features to another feature class
arcpy.CopyFeatures_management(InstitutesLA_FeatLayer, ImpactedInstitutesLA, "", "0", "0", "0")
arcpy.AddMessage("Impact assessment on institutions (point) features completed")

#--------------------------------------------------------------------------------
#Find line features affected - roads
#--------------------------------------------------------------------------------

#MajorRoadsLA = arcpy.GetParameterAsText(8)
#ImpactedMajorRoadsLA = arcpy.GetParameterAsText(9)

#Make feature layer - needed to select features
MajorRoadsLA_FeatLayer = "MajorRoadsLA_FeatLayer"
arcpy.MakeFeatureLayer_management(MajorRoadsLA,MajorRoadsLA_FeatLayer)

# Process: Select Layer By Location
arcpy.SelectLayerByLocation_management(MajorRoadsLA_FeatLayer, "INTERSECT", Out_SeepsBuffer, "", "NEW_SELECTION")

# Process: Copy selected Features to another feature class
arcpy.CopyFeatures_management(MajorRoadsLA_FeatLayer, ImpactedMajorRoadsLA)
arcpy.AddMessage("Impact assessment on road features (line) completed")

#--------------------------------------------------------------------------------

arcpy.AddMessage("Impact assessment on people and infrastructure is done!")
print "Impact assessment on people and infrastructure is done!"

#--------------------------------------------------------------------------------




No comments:

Post a Comment