Skip to content

Commit

Permalink
fix create_vrt_file
Browse files Browse the repository at this point in the history
  • Loading branch information
jochenklar committed Aug 12, 2017
1 parent 3c56054 commit dbb58f0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ dist
env
env3

*.vrt
*.egg-info
*.pyc

Expand Down
3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@

requirements = [
'mercantile',
'PyYAML',
'numpy'
'PyYAML'
]

scripts = [
Expand Down
15 changes: 13 additions & 2 deletions wms_downloader/download.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env python
import argparse
import glob
import os
import subprocess
import yaml
Expand Down Expand Up @@ -34,11 +35,19 @@ def main():
with open(args.config) as f:
config = yaml.load(f.read())

create_directory(config)
download_images(config)
create_vrt_file(config)


def create_directory(config):
try:
os.makedirs(config['directory'])
except OSError:
pass


def download_images(config):
west_range = list(arange(config['bbox']['west'], config['bbox']['east'], config['size']))
south_range = list(arange(config['bbox']['south'], config['bbox']['north'], config['size']))

Expand Down Expand Up @@ -71,8 +80,10 @@ def main():
args = ['gdal_translate', '-of', 'JPEG', config['tmpfile'], filename]
subprocess.check_call(args)

file_pattern = '%s/*.gdal.tif'
args = ['gdalbuildvrt', '-a_srs', config['projection'], '-overwrite', config['vrtfile'], file_pattern]

def create_vrt_file(config):
args = ['gdalbuildvrt', '-a_srs', config['projection'], '-overwrite', config['vrtfile']]
args += glob.glob('%s/*.gdal.tif' % config['directory'])
subprocess.check_call(args)


Expand Down

0 comments on commit dbb58f0

Please sign in to comment.