File: get-tiles.py

package info (click to toggle)
gpsprune 19.2-1~bpo9+1
  • links: PTS, VCS
  • area: main
  • in suites: stretch-backports
  • size: 4,516 kB
  • sloc: java: 42,704; sh: 25; makefile: 24; python: 15
file content (24 lines) | stat: -rwxr-xr-x 753 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# © 2010, David Paleino <dapal@debian.org>
#
# This script is released under the GNU General Public License, version 2.

from urllib2 import urlopen
import re

base = "https://dds.cr.usgs.gov/srtm/version2_1/SRTM3/%s/"
regions = ["Eurasia", "North_America", "Australia", "Islands", "South_America", "Africa"]

for reg in regions:
    url = base % reg
    tiles = []
    for line in urlopen(url).readlines():
        if line.startswith("<li>"):
            match = re.match("^<li><.*> ([^>]*)<.*>", line)
            if match:
                tiles.append(match.group(1).replace(".hgt.zip", ""))
    f = open("tiles%s.txt" % (regions.index(reg)+1), "w")
    f.write('\n'.join([reg] + tiles))
    f.close()