Datasets:

Modalities:
Geospatial
License:
File size: 2,156 Bytes
2a2d14d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# File              : read_file.py
# Author            : Jingliang Hu
# Date              : 15.08.2018 14:05:08
# Last Modified Date: 15.08.2018 14:05:08
# Last Modified By  : Yuanyuan Wang <[email protected]>

# Last modified: 15.08.2018 14:06:23 Yuanyuan Wang
# added visualization

# Last modified: 19.11.2025 Qi Zhang, Yi Wang
# added geolocation

import h5py
import numpy as np
import matplotlib.pyplot as plt

# select one of the given files
fileOfChoice = 'validation.h5'

# show the variables in selected file
fid = h5py.File(fileOfChoice,'r')
print('INFO:    The names of variables in the file of \''+fileOfChoice+'\':')
print fid.keys()

# load the data into memory
print('INFO:    Loading sentinel-1 data patches ...')
s1 = np.array(fid['sen1'])
print('INFO:    Sentinel-1 data dimension:')
print(s1.shape)

print('INFO:    Loading sentinel-2 data patches ...')
s2 = np.array(fid['sen2'])
print('INFO:    Sentinel-2 data dimension:')
print(s2.shape)

print('INFO:    Loading label ...')
lab = np.array(fid['label'])
print('INFO:    Label dimension:')
print(lab.shape)


# visualization, plot the first pair of Sentinel-1 and Sentinel-2 patches of training.h5
plt.subplot(121)
plt.imshow(10*np.log10(s1[0,:,:,4]),cmap=plt.cm.get_cmap('gray'))
plt.colorbar()
plt.title('Sentinel-1')

plt.subplot(122)
plt.imshow(s2[0,:,:,1],cmap=plt.cm.get_cmap('gray'))
plt.colorbar()
plt.title('Sentinel-2')

plt.show()

#%%
# select one of the given files
fileOfChoice = 'validation_geo.h5'

# show the variables in selected file
fid = h5py.File(fileOfChoice,'r')
print('INFO:    The names of variables in the file of \''+fileOfChoice+'\':')

# load the data into memory
print('INFO:    Loading coordinate data ...')
coord = np.array(fid['coord'])
print('INFO:    Coordinate data dimension:')
print(coord.shape)

# load the data into memory
print('INFO:    Loading epsg data ...')
tfw = np.array(fid['tfw'])
print('INFO:    tfw data dimension:')
print(tfw.shape)

# load the data into memory
print('INFO:    Loading epsg data ...')
epsg = np.array(fid['epsg'])
print('INFO:    epsg data dimension:')
print(epsg.shape)