-
Notifications
You must be signed in to change notification settings - Fork 0
/
RasterDriver4.py
75 lines (58 loc) · 1.57 KB
/
RasterDriver4.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
# -*- coding: utf-8 -*-
"""
Created on Thu Jan 31 01:39:35 2013
@author: nrjh
"""
from RasterHandler import createRanRasterSlope
import matplotlib.pyplot as mp
from Flow import flowRaster
def plotleaves(flownode,colour):
upnodes=flownode.getUpnodes()
for node in upnodes:
x1=flownode.get_x()
y1=flownode.get_y()
x2=node.get_x()
y2=node.get_y()
mp.plot([x1,x2],[y1,y2],color=colour)
if (node.numUpnodes()>0):
plotleaves(node,colour)
rows=20
cols=30
xorg=0.
yorg=0.
xp=5
yp=5
nodata=-999.999
cellsize=1.
levels=4
datahi=100.
datalow=0
randpercent=0.2
colours=["black","red","blue","yellow","green","cyan","white","orange","grey","brown"]
#raster=createRanRaster()
raster=createRanRasterSlope(rows,cols,cellsize,xorg,yorg,nodata,levels,datahi,datalow,xp,yp,randpercent)
data=raster.getData()
mp.matshow(data)
mp.colorbar()
fr=flowRaster(raster.getData(),raster.getOrgs()[0],raster.getOrgs()[0],raster.getCellsize(),raster.getNoData())
fr.setDownCells()
pointlist=fr.getPointList()
for p in pointlist:
mp.scatter(p.get_x(),p.get_y())
#for p in pointlist:
# if (p.getDownnode()!=None):
# x1=p.get_x()
# y1=p.get_y()
# x2=p.getDownnode().get_x()
# y2=p.getDownnode().get_y()
# mp.plot([x1,x2],[y1,y2],color="black")
pits=fr.getPits()
for p in pits:
mp.scatter(p.get_x(),p.get_y(),color="red")
fr.setUpCells()
i=-1
for p in pits:
i+=1
j=i%len(colours)
plotleaves(p,colours[j])
mp.show()