forked from ustroetz/cost_model
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_costmodel.py
87 lines (71 loc) · 1.85 KB
/
test_costmodel.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
from forestcost import main_model as m
from forestcost import routing as r
from forestcost import landing
from forestcost import gis
from pprint import pprint
import ogr
if __name__ == '__main__':
### GIS Data
slope_raster = 'testdata//slope.tif'
elevation_raster = 'testdata//dem.tif'
property_shp = ogr.Open('testdata//test_stand.shp')
property_lyr = property_shp.GetLayer()
stand_lyr = property_shp.GetLayer()
feat = stand_lyr.GetFeature(0)
geom = feat.GetGeometryRef()
stand_wkt = geom.ExportToWkt()
area = gis.area(stand_lyr)
elevation = gis.zonal_stats(elevation_raster, stand_lyr)
slope = gis.zonal_stats(slope_raster, stand_lyr)
### Tree Data ###
# Harvest Type (clear cut = 0, partial cut = 1)
PartialCut = 0
# Hardwood Fraction
HdwdFractionCT = 0.15
HdwdFractionSLT = 0.0
HdwdFractionLLT = 0.0
# Chip Trees
RemovalsCT = 200.0
TreeVolCT = 5.0
# Small Log Trees
RemovalsSLT = 100.00
TreeVolSLT = 70.0
# Large Log Trees
RemovalsLLT = 20.00
TreeVolLLT = 100.00
### Mill information
mill_shp = 'testdata//mills.shp'
#mill_coords = (-123.5677, 41.2564)
# Landing Coordinates
landing_coords = landing.landing(property_lyr)
haulDist, haulTime, coord_mill = r.routing(
landing_coords,
mill_shp=mill_shp
)
cost = m.cost_func(
# stand info
area,
elevation,
slope,
stand_wkt,
# harvest info
RemovalsCT,
TreeVolCT,
RemovalsSLT,
TreeVolSLT,
RemovalsLLT,
TreeVolLLT,
HdwdFractionCT,
HdwdFractionSLT,
HdwdFractionLLT,
PartialCut,
# routing info
landing_coords,
haulDist,
haulTime,
coord_mill,
# options
True,
0.5
)
pprint(cost)