From 5a20999acd8216b5ea437a70b1cc211faca3a461 Mon Sep 17 00:00:00 2001 From: David Hoese <david.hoese@ssec.wisc.edu> Date: Wed, 15 Jan 2020 21:23:27 -0600 Subject: [PATCH] Add tile gen readme, fix typos, and added multithreading to gdalwarp --- tile_gen/Dockerfile | 8 ++++++-- tile_gen/README.md | 18 ++++++++++++++++++ tile_gen/generate_tiles.py | 8 ++++---- 3 files changed, 28 insertions(+), 6 deletions(-) create mode 100644 tile_gen/README.md diff --git a/tile_gen/Dockerfile b/tile_gen/Dockerfile index adb4951..7d7d9e8 100644 --- a/tile_gen/Dockerfile +++ b/tile_gen/Dockerfile @@ -1,10 +1,14 @@ FROM tiledb/tiledb-geospatial:latest # TODO may need the unzip command to be installed if not already -RUN wget http://ssec.wisc.edu/~rayg/pub/amqpfind.zip && \ +RUN apt-get update && apt-get install -y unzip && \ + wget http://ssec.wisc.edu/~rayg/pub/amqpfind.zip && \ unzip amqpfind.zip && \ - rm amqpfind.zip + rm amqpfind.zip && \ + rm -rf /var/lib/apt/lists/* +# FIXME: Remove once added to parent image +RUN pip3 install shapely COPY tile_index.py . COPY generate_tiles.py . COPY run.sh . diff --git a/tile_gen/README.md b/tile_gen/README.md new file mode 100644 index 0000000..53d434f --- /dev/null +++ b/tile_gen/README.md @@ -0,0 +1,18 @@ +# Tile Generation + +## Build + +```bash +docker build -t gitlab.ssec.wisc.edu:5555/cspp_geo/cspp-geo-web-viewer/tile_gen:latest tile_gen/ +docker push gitlab.ssec.wisc.edu:5555/cspp_geo/cspp-geo-web-viewer/tile_gen:latest +``` + +## Usage + +```bash +docker run -p 8888:80 -d gitlab.ssec.wisc.edu:5555/cspp_geo/cspp-geo-web-viewer/mapserver:latest +``` + +Then the main mapserv CGI script can be accessed with: + +http://localhost:8888/cgi-bin/mapserv diff --git a/tile_gen/generate_tiles.py b/tile_gen/generate_tiles.py index ed8fe09..daeca8b 100644 --- a/tile_gen/generate_tiles.py +++ b/tile_gen/generate_tiles.py @@ -26,7 +26,7 @@ def group_files(products, input_files): def remap_to_lonlat(itif, otif): """Remap a single geotiff by calling gdalwarp.""" try: - subprocess.run(['gdalwarp', '-t_srs', 'EPSG:4326', itif, otif], check=True) + subprocess.run(['gdalwarp', '-multi', '-wo', 'NUM_THREADS=ALL_CPUS', '-t_srs', 'EPSG:4326', itif, otif], check=True) except subprocess.CalledProcessError: LOG.error("Could not remap geotiff %s -> %s" % (itif, otif)) return None @@ -57,15 +57,15 @@ def main(): help="Shapefile filename pattern to use and placed in the output directory. (default: '{product}.shp')") parser.add_argument('out_dir', help="Output path to save tile information to (ex. '/data/tiles/{product}')") - parser.add_argument('input_files', + parser.add_argument('input_files', nargs="+", help="Input geotiffs to generate tiles for (separate from product lists with '--')") args = parser.parse_args() groups = group_files(args.products, args.input_files) for prod, prod_files in groups.items(): - out_dir = args.out_dir.format(prod) + out_dir = args.out_dir.format(product=prod) os.makedirs(out_dir, exist_ok=True) - shp_fn = args.shape_file.format(prod) + shp_fn = args.shape_file.format(product=prod) shp_pathname = os.path.join(out_dir, shp_fn) # remap if needed -- GitLab