1
|
library(rgdal)
|
2
|
aster.dir <- "DEM/asterGdem"
|
3
|
|
4
|
#Check that path=correct:
|
5
|
a<- GDALinfo("DEM/asterGdem/ASTGTM_N59E069_dem.tif",
|
6
|
silent=TRUE,returnRAT=TRUE)
|
7
|
|
8
|
# for a given file, return TRUE if file name matches the internally
|
9
|
# specified lower left corner, otherwise return string with those
|
10
|
# coordinates
|
11
|
check <- function(tilename, path=".", silent=TRUE) {
|
12
|
# build expected filename
|
13
|
origin <- round(GDALinfo(file.path(path, tilename),
|
14
|
silent=silent)[c("ll.x", "ll.y")])
|
15
|
ly <- origin["ll.y"]
|
16
|
y <- sprintf("%s%02d", if (ly>=0) "N" else "S", abs(ly))
|
17
|
lx <- origin["ll.x"]
|
18
|
x <- sprintf("%s%03d", if (lx>=0) "E" else "W", abs(lx))
|
19
|
expected.name <- paste("ASTGTM_", y, x, "_dem.tif", sep="")
|
20
|
# compare to actual filename
|
21
|
if (tilename==expected.name) {
|
22
|
TRUE
|
23
|
} else {
|
24
|
paste(y, x)
|
25
|
}
|
26
|
}
|
27
|
|
28
|
aster.tiles <- list.files(aster.dir, pattern="^ASTGTM.*_dem.tif$")
|
29
|
titlecheck <- sapply(aster.tiles, check, path=aster.dir)
|
30
|
|
31
|
BadAster_df<- data.frame(expected=titlecheck[titlecheck!="TRUE"])
|
32
|
|
33
|
# ASTGTM_N59E069_dem.tif N63 E109
|
34
|
#ASTGTM_N63E113_dem.tif N69 E107
|
35
|
# ASTGTM_N63E117_dem.tif N69 E113
|
36
|
#ASTGTM_N64E098_dem.tif N70 E117
|
37
|
#ASTGTM_N65E104_dem.tif N73 E084
|
38
|
# ASTGTM_N65E111_dem.tif N73 E098
|
39
|
# ASTGTM_N65E117_dem.tif N66 E130
|
40
|
|
41
|
KnownBadcheck <- function(badtilename, path="DEM/asterGdem/incorrectTilesJuly2011", silent=TRUE) {
|
42
|
# build expected filename
|
43
|
origin <- round(GDALinfo(file.path(path, badtilename),
|
44
|
silent=silent)[c("ll.x", "ll.y")])
|
45
|
ly <- origin["ll.y"]
|
46
|
y <- sprintf("%s%02d", if (ly>=0) "N" else "S", abs(ly))
|
47
|
lx <- origin["ll.x"]
|
48
|
x <- sprintf("%s%03d", if (lx>=0) "E" else "W", abs(lx))
|
49
|
Badexpected.name <- paste("ASTGTM_", y, x, "_dem.tif", sep="")
|
50
|
# compare to actual filename
|
51
|
if (badtilename==Badexpected.name) {
|
52
|
TRUE
|
53
|
} else {
|
54
|
paste(y, x)
|
55
|
}
|
56
|
}
|
57
|
|
58
|
bad.tiles <- list.files("DEM/asterGdem/incorrectTilesJuly2011", pattern="^ASTGTM.*_dem.tif$")
|
59
|
badtitlecheck <- sapply(bad.tiles, KnownBadcheck, path="DEM/asterGdem/incorrectTilesJuly2011")
|
60
|
|
61
|
BadTitle_df<- data.frame(expected=badtitlecheck[badtitlecheck!="TRUE"])
|
62
|
|
63
|
#----------------------------------------------------------------------------------------------------------------------
|
64
|
#Check num.tif files
|
65
|
b<- GDALinfo("DEM/asterGdem/ASTGTM_N49E000_num.tif",
|
66
|
silent=TRUE,returnRAT=TRUE)
|
67
|
b
|
68
|
|
69
|
Numcheck <- function(Numtilename, path=".", silent=TRUE) {
|
70
|
# build expected filename
|
71
|
origin <- round(GDALinfo(file.path(path, Numtilename),
|
72
|
silent=silent)[c("ll.x", "ll.y")])
|
73
|
ly <- origin["ll.y"]
|
74
|
y <- sprintf("%s%02d", if (ly>=0) "N" else "S", abs(ly))
|
75
|
lx <- origin["ll.x"]
|
76
|
x <- sprintf("%s%03d", if (lx>=0) "E" else "W", abs(lx))
|
77
|
Numexpected.name <- paste("ASTGTM_", y, x, "_num.tif", sep="")
|
78
|
# compare to actual filename
|
79
|
if (Numtilename==Numexpected.name) {
|
80
|
TRUE
|
81
|
} else {
|
82
|
paste(y, x)
|
83
|
}
|
84
|
}
|
85
|
|
86
|
Num.tiles <- list.files("DEM/asterGdem/NewTiles", pattern="^ASTGTM.*_num.tif$")
|
87
|
Numtitlecheck <- sapply(Num.tiles, Numcheck, path="DEM/asterGdem/NewTiles")
|
88
|
|
89
|
NumTitle_df<- data.frame(expected=Numtitlecheck[Numtitlecheck!="TRUE"])
|
90
|
|
91
|
#Located one bad num.tif file
|
92
|
N49E007_NumRead<- GDALinfo("DEM/asterGdem/ASTGTM_N49E007_num.tif",
|
93
|
silent=TRUE,returnRAT=TRUE)
|
94
|
|
95
|
GDALinfo("DEM/asterGdem/ASTGTM_N59E069_dem.tif",
|
96
|
silent=TRUE,returnRAT=TRUE)
|
97
|
|
98
|
#--------------------------------------------------------------------------------
|
99
|
#Check new tiles uploaded to replace faulty tiles
|
100
|
|
101
|
Newcheck <- function(Newtilename, path=".", silent=TRUE) {
|
102
|
# build expected filename
|
103
|
origin <- round(GDALinfo(file.path(path, Newtilename),
|
104
|
silent=silent)[c("ll.x", "ll.y")])
|
105
|
ly <- origin["ll.y"]
|
106
|
y <- sprintf("%s%02d", if (ly>=0) "N" else "S", abs(ly))
|
107
|
lx <- origin["ll.x"]
|
108
|
x <- sprintf("%s%03d", if (lx>=0) "E" else "W", abs(lx))
|
109
|
Newexpected.name <- paste("ASTGTM_", y, x, "_dem.tif", sep="")
|
110
|
# compare to actual filename
|
111
|
if (Newtilename==Newexpected.name) {
|
112
|
TRUE
|
113
|
} else {
|
114
|
paste(y, x)
|
115
|
}
|
116
|
}
|
117
|
|
118
|
New.tiles <- list.files("DEM/asterGdem/NewTiles", pattern="^ASTGTM.*_dem.tif$")
|
119
|
Newtitlecheck <- sapply(New.tiles, Newcheck, path="DEM/asterGdem/NewTiles")
|
120
|
|
121
|
NewAster_df<- data.frame(Newexpected=Newtitlecheck[Newtitlecheck!="TRUE"])
|
122
|
|
123
|
#Yeah, no mistakes in first 4!
|
124
|
|
125
|
g<- list.files("DEM/asterGdem/N59to81_E60to99", pattern="^ASTGTM.*_dem.tif$")
|
126
|
h<- list.files("DEM/asterGdem/N59to81_E60to99/Non_DEM's", pattern="^ASTGTM.*_num.tif$")
|
127
|
|
128
|
GDALinfo("DEM/asterGdem/N59to81_E60to99/ASTGTM_N64E098_dem.tif",
|
129
|
silent=TRUE,returnRAT=TRUE)
|
130
|
|
131
|
#--------------------------------------------------------------------------
|
132
|
#new folder check
|
133
|
nfcheck <- function(nftilename, path=".", silent=TRUE) {
|
134
|
# build expected filename
|
135
|
origin <- round(GDALinfo(file.path(path, nftilename),
|
136
|
silent=silent)[c("ll.x", "ll.y")])
|
137
|
ly <- origin["ll.y"]
|
138
|
y <- sprintf("%s%02d", if (ly>=0) "N" else "S", abs(ly))
|
139
|
lx <- origin["ll.x"]
|
140
|
x <- sprintf("%s%03d", if (lx>=0) "E" else "W", abs(lx))
|
141
|
nfexpected.name <- paste("ASTGTM_", y, x, "_dem.tif", sep="")
|
142
|
# compare to actual filename
|
143
|
if (nftilename==nfexpected.name) {
|
144
|
TRUE
|
145
|
} else {
|
146
|
paste(y, x)
|
147
|
}
|
148
|
}
|
149
|
|
150
|
nf.tiles <- list.files("DEM/asterGdem/N59to81_E60to99", pattern="^ASTGTM.*_dem.tif$")
|
151
|
nftitlecheck <- sapply(nf.tiles, nfcheck, path="DEM/asterGdem/N59to81_E60to99")
|
152
|
|
153
|
nfAster_df<- data.frame(nfexpected=nftitlecheck[nftitlecheck!="TRUE"])
|
154
|
|
155
|
|
156
|
Numcheck <- function(Numtilename, path=".", silent=TRUE) {
|
157
|
# build expected filename
|
158
|
origin <- round(GDALinfo(file.path(path, Numtilename),
|
159
|
silent=silent)[c("ll.x", "ll.y")])
|
160
|
ly <- origin["ll.y"]
|
161
|
y <- sprintf("%s%02d", if (ly>=0) "N" else "S", abs(ly))
|
162
|
lx <- origin["ll.x"]
|
163
|
x <- sprintf("%s%03d", if (lx>=0) "E" else "W", abs(lx))
|
164
|
Numexpected.name <- paste("ASTGTM_", y, x, "_num.tif", sep="")
|
165
|
# compare to actual filename
|
166
|
if (Numtilename==Numexpected.name) {
|
167
|
TRUE
|
168
|
} else {
|
169
|
paste(y, x)
|
170
|
}
|
171
|
}
|