Project

General

Profile

« Previous | Next » 

Revision d732553c

Added by Rick Reeves over 13 years ago

  • ID d732553c03809ccec492b9935549693564e9a1e1

Very first version of plot making script. Plots need consolidation into 'panel plots', and plot labels need to be improved.

Uses input file:
tableForMark4000_5_8_SortColID.csv, also checked in.

View differences:

terrain/rscripts/MosaicCdemDifferencePlots.r
1
#setwd("f:/Projects/NCEAS/EnviromentAndOrganisms")
2
CreateDiffPlots <- function()
3
{
4
   pointTable <-read.csv("tableForMark4000_5_8_SortColID.csv")
5
#
6
# Table created by randomly sampling from two superimposed 
7
# image: 
8
#  1) DOM mosaic image comprised of ASTER and SRTM components.
9
#  2) 'Baseline' Canadian DEM (CDEM) image.
10
# 
11
# The input table contains three rows for each randomly-selected
12
# pixel pair from both images. Each row contains two pixel pairs,
13
# the first pair drawn from the image mosaic, the second pair
14
# drawn from the CDEM image: 
15
#   First pair: North pixel, South pixel (ASTER/SRTM mosaic)
16
#   Second pair: North pixel, South pixel (CDEM)
17
#
18
#  The first row of each 'triplet' contains pixel pairs North of border,
19
#  The second row contains pixel pairs spanning  border,
20
#  The third row contains pixel pairs South of border,
21
#
22
# This script generates a series of plots that display
23
# differences between:
24
#    1) The mosaic and CDEM images
25
#    2) Image pixels on and away from the ASTER / SRTM boundary.
26
# 
27
   northRowIndexes = seq(from=1, to=(nrow(pointTable) - 3),by=3)
28
   borderRowIndexes = seq(from=2, to=(nrow(pointTable) - 1),by=3)   
29
   southRowIndexes = seq(from=3, to=(nrow(pointTable)),by=3)
30
#
31
# calculate and append the difference between elevations
32
# and CDEM
33
# these lines create the inputs for differnce image plots for each of three
34
# pixel pair subsets: North of border (All Aster), border (combo Aster/Srtm),
35
#                     South of border (all Srtm)
36
# 
37
# First, add the 'difference columns' to the entire table
38
#
39
   pointTable <-cbind(pointTable,(pointTable$elevNorth - pointTable$elevSouth))
40
   pointTable <-cbind(pointTable,(pointTable$cdemNorth - pointTable$cdemSouth))
41
   pointTable <-cbind(pointTable,(pointTable$elevNorth - pointTable$cdemNorth))
42
   pointTable <-cbind(pointTable,(pointTable$elevSouth - pointTable$cdemSouth))
43
#   
44
   colnames(pointTable)[6] <- "diffMosaicNorthSouth"
45
   colnames(pointTable)[7] <- "diffCDEMNorthSouth"
46
   colnames(pointTable)[8] <- "diffNorthMosaicCDEM"
47
   colnames(pointTable)[9] <- "diffSouthMosaicCDEM"   
48

  
49
# Difference between Mosaic (ASTER or CGIAR or border) 
50
# and CDEM elevation as pertentage of the mosaic elevation
51

  
52
   pointTable <-cbind(pointTable,pointTable$diffNorthMosaicCDEM/pointTable$elevNorth) * 100
53
   pointTable <-cbind(pointTable,pointTable$diffSouthMosaicCDEM/pointTable$elevSouth) * 100 
54
   
55
   colnames(pointTable)[10] <- "magDiffMosaicCDEMNorthPct"
56
   colnames(pointTable)[11] <- "magDiffMosaicCDEMSouthPct"   
57

  
58
# For the plots, subdivide the table into three segments: 
59
#     rows north of border
60
#     rows crossing border
61
#     rows south of border
62

  
63
   northRowTbl = pointTable[northRowIndexes,]
64
   borderRowTbl = pointTable[borderRowIndexes,]
65
   southRowTbl = pointTable[southRowIndexes,]
66
message("hit key to create plots...")
67
browser()
68
#
69
# Create plots
70
#
71
# First, plot North/South pixel elevation for North/Border/South subsets 'distance East from Western edge'.
72
#
73
   plot(northRowTbl$ColumnID,northRowTbl$elevNorth,main="North (ASTER) Mosaic North Pixel Elevation",col="red",pch=".")
74
   plot(borderRowTbl$ColumnID,borderRowTbl$elevNorth,main="Border Mosaic North Elevation",col="darkgreen",pch=".")
75
   plot(southRowTbl$ColumnID,southRowTbl$elevNorth,main="South (SRTM) Mosaic North Elevation",col="blue",pch=".")
76
   
77
   plot(northRowTbl$ColumnID,northRowTbl$elevNorth,main="North (ASTER) CDEM North Pixel Elevation",col="red",pch=".")
78
   plot(borderRowTbl$ColumnID,borderRowTbl$elevNorth,main="Border CDEM North Pixel Elevation",col="darkgreen",pch=".")
79
   plot(southRowTbl$ColumnID,southRowTbl$elevNorth,main="South (SRTM) CDEM North Elevation",col="blue",pch=".")
80

  
81
   plot(northRowTbl$ColumnID,northRowTbl$elevSouth,main="North (ASTER) Mosaic South Pixel Elevation",col="red",pch=".")
82
   plot(borderRowTbl$ColumnID,borderRowTbl$elevSouth,main="Border Mosaic South Elevation",col="darkgreen",pch=".")
83
   plot(southRowTbl$ColumnID,southRowTbl$elevSouth,main="South (SRTM) Mosaic South Elevation",col="blue",pch=".")
84

  
85
   plot(northRowTbl$ColumnID,northRowTbl$elevSouth,main="North (ASTER) CDEM South Pixel Elevation",col="red",pch=".")
86
   plot(borderRowTbl$ColumnID,borderRowTbl$elevSouth,main="Border CDEM South Pixel Elevation",col="darkgreen",pch=".")
87
   plot(southRowTbl$ColumnID,southRowTbl$elevSouth,main="South (SRTM) CDEM South Elevation",col="blue",pch=".")   
88
#
89
# Next, (for now) difference between North and South pixels in pair, for various regions
90
# 
91
   plot(northRowTbl$ColumnID,northRowTbl$diffMosaicNorthSouth,main="North (ASTER) Mosaic North/South Diff",col="red",pch=".")
92
   plot(borderRowTbl$ColumnID,borderRowTbl$diffMosaicNorthSouth,main="Border Mosaic North/South Diff",col="darkgreen",pch=".")
93
   plot(southRowTbl$ColumnID,southRowTbl$diffMosaicNorthSouth,main="South (SRTM) Mosaic North/South Diff",col="darkgreen",pch=".")   
94
#   
95
   plot(northRowTbl$ColumnID,northRowTbl$diffCDEMNorthSouth,main="North (ASTER) CDEM North/South Diff",col="red",pch=".")
96
   plot(borderRowTbl$ColumnID,borderRowTbl$diffCDEMNorthSouth,main="Border CDEM North/South Diff",col="darkgreen",pch=".")
97
   plot(southRowTbl$ColumnID,southRowTbl$diffCDEMNorthSouth,main="South (SRTM) CDEM North/South Diff",col="blue",pch=".")
98

  
99
# Next: the Mosaic/CDEM difference divided by the (ASTER or SRTM) elevation
100

  
101
  plot(northRowTbl$ColumnID,northRowTbl$magDiffMosaicCDEMNorthPct,col="red",pch=".",main="Elev Diff as PerCent of Mosaic Elev (North)")
102
  plot(borderRowTbl$ColumnID,borderRowTbl$magDiffMosaicCDEMNorthPct,col="darkgreen",pch=".",main="Elev Diff as PerCent of Mosaic Elev (Border)")  
103
  plot(southRowTbl$ColumnID,southRowTbl$magDiffMosaicCDEMSouthPct,col="blue",pch=".",main="Elev Diff as PerCent of Mosaic Elev (South)")  
104
  
105
# Finally: Mosaic vs CDEM difference vs elevation (north or south)
106

  
107
  plot(northRowTbl$elevNorth,northRowTbl$diffCDEMNorthSouth,col="red",pch=".",main="ASTER Elev Diff vs Mosaic Elev (North Pixel)")
108
# plot(northRowTbl$elevSouth,southRowTbl$diffCDEMNorthSouth,col="darkgreen",pch=".",main="ASTER Elev Diff vs Mosaic Elev (South Pixel)")  
109
  
110
  plot(borderRowTbl$elevNorth,borderRowTbl$diffCDEMNorthSouth,col="darkgreen",pch=".",main="Border Elev Diff vs Mosaic Elev (North Pixel)")
111
#  plot(borderRowTbl$elevSouth,borderRowTbl$diffCDEMNorthSouth,col="darkgreen",pch=".",main="Border Elev Diff vs Mosaic Elev (South Pixel)")  
112
  
113
  plot(southRowTbl$elevNorth,southRowTbl$diffCDEMNorthSouth,col="blue",pch=".",main="SRTM Elev Diff vs Mosaic Elev (North Pixel)")
114
#  plot(southRowTbl$elevSouth,southRowTbl$diffCDEMNorthSouth,col="darkgreen",pch=".",main="SRTM Elev Diff vs Mosaic Elev (South Pixel)")  
115
  
116

  
117

  
118

  
119

  
120

  
121
}

Also available in: Unified diff