-
Notifications
You must be signed in to change notification settings - Fork 66
/
tutorial.py
executable file
·58 lines (45 loc) · 1.65 KB
/
tutorial.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
#!/usr/bin/env python
# Name: tutorial.py
# Author: Anton Korosov
# Licence: GPL v.3
# This file is part of NANSAT. You can redistribute it or modify
# under the terms of GNU General Public License, v.3
# http://www.gnu.org/licenses/gpl-3.0.html
import matplotlib.pyplot as plt
import os
from nansat import Nansat, Domain
from testio import testio
# Set input and output file names
iPath, oPath = testio()
iFileName = os.path.join(iPath, 'gcps.tif')
oFileName = os.path.join(oPath, 'tutor_')
# Open an input satellite image with Nansat
n = Nansat(iFileName)
# List bands and georeference of the object
print n
# Write picture with map of the file location
n.write_map(oFileName + 'map.png')
# Write indexed picture with data from the first band
n.write_figure(oFileName + '.png', clim='hist')
# Reproject input image onto map of Norwegian Coast
# 1. Create domain describing the desired map
# 2. Transform the original satellite image
# 3. Write the transfromed image into RGB picture
dLatlong = Domain("+proj=latlong +datum=WGS84 +ellps=WGS84 +no_defs",
"-te 27 70.2 31 71.5 -ts 500 500")
n.reproject(dLatlong)
# Export projected satelite image into NetCDF format
n.export(oFileName + '.nc')
# Collect values from interactively drawn transect
# 1. draw transect interactively
# 2. plot the values
values, lonlat, pixlinCoord = n.get_transect()
plt.plot(lonlat[0], values[0], '.-'); plt.show()
# run tests of other nansat components
import test_domain
import test_nansat
import test_figure
import test_nansatmap
import test_nansatshape
import test_mosaic; test_mosaic.main() # run this way due to multiprocessing
import test_pointbrowser