-
Notifications
You must be signed in to change notification settings - Fork 0
/
getLSS.py
101 lines (86 loc) · 3.07 KB
/
getLSS.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
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
99
#!/usr/bin/env python
"""
/***************************************************************************
Get Lidar Slovenia data.
-------------------
begin : 2016-11-12
git sha : $Format:%H$
copyright : (C) 2016 by Nejc Dougan
email : [email protected]
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
"""
import urllib
import time
def getLSS(tiles, CRS, product, destination):
"""Download LIDAR Slovenia
:param tiles: Array of tiles (E, N)
:type tiles: int
:param CRS: Coordinate system D96TM or D48GK
:type CRS: string
:param product: Point Cloud (OTR), Classified Point Cloud (GKOT), Digital Elevation Model (DMR)
:type product: string
:param destination: Folder location
:type destination: string
"""
blocks = [11, 12, 13, 14, 15, 16, 21, 22, 23, 24, 25, 26, 31, 32, 33, 34, 35, 36, 37]
fileurl = urllib.URLopener()
if product == 'OTR':
extension = 'zlas'
fileprefix = 'R'
elif product == 'GKOT':
extension = 'zlas'
fileprefix = ''
elif product == 'DMR':
extension = 'asc'
fileprefix = '1'
product = 'dmr1'
else:
print 'Wrong product name'
[tileE, tileN] = tiles
filename = '{0}{1}_{2}_{3}.{4}'.format(CRS[-2:], fileprefix, tileE, tileN, extension)
print 'Downloading: ' + filename
download = False
for block in blocks:
if download:
time.sleep(1)
break
url = 'http://gis.arso.gov.si/lidar/{0}/b_{1}/{2}/{3}'.format(product, block, CRS, filename)
try:
fileurl.retrieve(url, destination + '/' + filename)
download = True
except:
next
if download:
print 'Done downloading: ' + filename
else:
print 'Download failed'
return
def creatListOfTiles(startE, startN, endE, endN):
"""Create list of tiles from opposite corner tiles.
:param startE: Upper left Tile Easting E
:type startE: int
:param startN: Upper left Tile Northing N
:type startN: int
:param endE: Lower right Tile Easting N
:type endE: int
:param endN: Lower right Tile Northing N
:type endN: int
"""
E = startE
N = startN
tiles = []
while E <= endE:
N = startN
while N >= endN:
tiles.append([E, N])
N -= 1
E += 1
return tiles