-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLandsat.java
More file actions
98 lines (60 loc) · 2.47 KB
/
Landsat.java
File metadata and controls
98 lines (60 loc) · 2.47 KB
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
import gov.nasa.worldwind.geom.Sector;
import gov.nasa.worldwind.geom.Angle;
import gov.nasa.worldwind.layers.Earth.LandsatI3WMSLayer;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.net.SocketTimeoutException;
import javax.imageio.ImageIO;
class Landsat {
public static void main(String[] args) {
LandsatI3WMSLayer layer = new LandsatI3WMSLayer();
final int pix_deg = 1000;
final int widp = pix_deg;
final int lenp = pix_deg;
for (int clat = 0; clat < 180; clat++) {
for (int lon = 0; lon < 360; lon++) {
System.out.printf("clat = %03d; lon = %03d\n", clat, lon);
get_image(clat, lon, widp, lenp, layer);
System.out.printf("\tAcquired\n");
}
}
}
private static void get_image(int clat, int lon, int widp, int lenp,
LandsatI3WMSLayer layer) {
try {
int flag = 1;
while (flag != 0) {
try {
int lat = 90 - clat;
// Compute sector
Sector sector = new Sector(
Angle.fromDegrees(lat - 1),
Angle.fromDegrees(lat),
Angle.fromDegrees(lon),
Angle.fromDegrees(lon + 1));
// Aspect ratio (pixel?)
double ar = 1;
// Timeout (1 minute)
int timeout = 60000;
// Image type & filename
String type = "image/png";
String filename = String.format(
"mosaic/tile_%03d_%03d.png", clat, lon);
// Acquire image
BufferedImage img = layer.composeImageForSector(sector,
widp, lenp, ar, -1, type, true, null, timeout);
// Save image
File outputfile = new File(filename);
ImageIO.write(img, "png", outputfile);
// Success
flag = 0;
} catch (SocketTimeoutException ste) {
System.out.println("\tSocket timed out -- Trying again");
}
}
} catch (Exception e) {
e.printStackTrace(System.out);
}
}
}