From dbb58f0bfd571fabbe3a2dfdb4ce52514117a2d2 Mon Sep 17 00:00:00 2001 From: Jochen Klar Date: Sat, 12 Aug 2017 12:59:59 +0200 Subject: [PATCH] fix create_vrt_file --- .gitignore | 1 - setup.py | 3 +-- wms_downloader/download.py | 15 +++++++++++++-- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index c55829b..816f4f2 100644 --- a/.gitignore +++ b/.gitignore @@ -4,7 +4,6 @@ dist env env3 -*.vrt *.egg-info *.pyc diff --git a/setup.py b/setup.py index 1a7eb43..3ae2840 100644 --- a/setup.py +++ b/setup.py @@ -13,8 +13,7 @@ requirements = [ 'mercantile', - 'PyYAML', - 'numpy' + 'PyYAML' ] scripts = [ diff --git a/wms_downloader/download.py b/wms_downloader/download.py index f15bb87..cce9a50 100755 --- a/wms_downloader/download.py +++ b/wms_downloader/download.py @@ -1,5 +1,6 @@ #!/usr/bin/env python import argparse +import glob import os import subprocess import yaml @@ -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'])) @@ -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)