# Summary of Final Programming Project

Λογισμικό & κατασκευή λογ/κού

7 Νοε 2013 (πριν από 4 χρόνια και 8 μήνες)

65 εμφανίσεις

Helen
Peng

Geo376 Final Project Report

May 2010

1

Summary of
Final

Programming
Project

My final project is to develop Python scripts of creating vacation home footprints in
suitable land. I gain the project idea from the trip to the Smoky Mountains National
Park.

During the visiting, my friend talked

about her dreamed vacation home in the
beautiful mountain areas with road accessibility.

I recommended GIS and Python
programming could help her with selecting good sites for her vacation home.

The
Python scripts
are

divided into
two parts: one is to f
ind suitable lands where can
see rivers and access by roads, the other is to create footprints polygons in the suitable
land. In the first part, it defines three functions. One function is to select proper roads
and buffer roads with a certain distance. Th
e second function is to run viewshed
analysis for a stream data and convert raster data to polygons. The third function is to
intersect road buffer and viewshed polygon, then select polygons with larger areas by
calculating areas

The following is the deta
iled geo
-
processing:

Select major state highway roads, and buffer the selected roads to gain areas within a
150
-
-
buffer zone.

1.2 StreamViwshed function:

Use DEM and stream data to process Viewshed analysis to gain ar
eas which can see
the streams with good views. For the later process, it needs to set null and convert
raster data to polygon. By running
a
SetNull tool, set null for not
-
visible data (value= 0)
to remain all visible data.
Using a r
eclassify tool is to eli
minate polygon numbers. The
final step is to run the tool of Convert to Polygons.

1.3 IntersectCalSel function:

Intersect
the
road buffer and viewshed polygon, calculate area
s

of polygons and select
polygons with larger areas. The selected polygons repre
sent
the
suitable land for
vacation
-
home sites.

In the second part,
t
he
Python scripts reads centroids from the suitable land polygon
and creates footprints polygons from centroids. In this process, two cursors are created.
One is to read geometry featur
es from the suitable land polygon, the other one is to
create new footprint polygons. While loop is used to get each feature and
an
array is
used to create a footprint.

I found several challenges during the project. The following is the challenges I had
during the process.

1.

To intersect road polygon with viewshed raster data, I needed to convert raster
data to polygon and Set Null for raster data. While, I had some trouble with Set
Null and asked our instructor, then got the idea on SetNull. In
the data
,

visible
data is more than 0 and not
-
visible data is equal to 0. By running
a
SetNull tool,
Helen
Peng

Geo376 Final Project Report

May 2010

2

the step eliminated not
-
visible data. Then I found there were hundreds of
polygons and

added one more step

Reclassify to reduce the number of
polygons.

2.

The first

part of my program derives mainly from Model Builder. I thought that all
scripts from Model Builder should work fine. After replacing with different variable
names, my s
c
ripts did not work. I could not find errors from my replaced variables
and wonder wha
t is wrong with my scripts. By communicating with Nate, I found
that the Intersect code exported by Model Builder needs to run in Geo
-
database.
Also, I found the
below
script runs well, which is not in geo
-
database
environment. (see the below)

gp.Intersect_analysis(roads_buffer + ';' + viewshed_poly, x_Intersect_shp, "ALL", "",
"INPUT")

3.

I think it is another challenge to create footprints polygon by reading centroids
from
the

suitable land polygon. When my scripts read a centroid (x,y) from a
p
olygon, the value of x is negative, and the program can not work on the script
(llx = 100
-
x).

The error message says
--

unsupported operand type(s) for
-
: 'int' and 'str'

Suggested by Nate, llx = 100
-

float(x) works. Thus I can get the right coordinates
in the text/excel file. To get more accurate x,y data, the below scrip works better.

#split a string, get x,y values

ctr = centroid.split(' ')

x = float(ctr[0])

y = float(ctr[1])

4.

Additionally, my program appears x=
-
83.xx
xx. I learned from Nate that

degree represents the area in USA and West of the Primer Meridian. As
California

-
121degrees (or 121 degrees West) of the Primer Meridian.
And the site that I selected for the project is Smoky Mountains, TN, so x=
-
83.xxxx.

5.

Data collection is an important step
at the beginning of

the project. The basic
data for this project is DEM data, roads shapefile, and river shapefile. I found
DEM and roads data from USGS but could not find river (hydrology) data. I
searched on states, cities
,
parks government websites, and others, but I coul
d
not find
any data
. After searching for a while, I found at the University of
Tennessee website. I learned that geo
-
data can be available at college websites.

The project is eventually accomplished.
The process of solving program problems is the
process

of learning.

I enjoyed the time on running the program and figuring out the
issues. I would also like to share my result with my friend who is dreaming the vacation
home.

Helen
Peng

Geo376 Final Project Report

May 2010

3