Skip to content
Snippets Groups Projects
Commit 5a20999a authored by David Hoese's avatar David Hoese
Browse files

Add tile gen readme, fix typos, and added multithreading to gdalwarp

parent 2038d8d6
No related merge requests found
FROM tiledb/tiledb-geospatial:latest FROM tiledb/tiledb-geospatial:latest
# TODO may need the unzip command to be installed if not already # 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 && \ 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 tile_index.py .
COPY generate_tiles.py . COPY generate_tiles.py .
COPY run.sh . COPY run.sh .
# 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
...@@ -26,7 +26,7 @@ def group_files(products, input_files): ...@@ -26,7 +26,7 @@ def group_files(products, input_files):
def remap_to_lonlat(itif, otif): def remap_to_lonlat(itif, otif):
"""Remap a single geotiff by calling gdalwarp.""" """Remap a single geotiff by calling gdalwarp."""
try: 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: except subprocess.CalledProcessError:
LOG.error("Could not remap geotiff %s -> %s" % (itif, otif)) LOG.error("Could not remap geotiff %s -> %s" % (itif, otif))
return None return None
...@@ -57,15 +57,15 @@ def main(): ...@@ -57,15 +57,15 @@ def main():
help="Shapefile filename pattern to use and placed in the output directory. (default: '{product}.shp')") help="Shapefile filename pattern to use and placed in the output directory. (default: '{product}.shp')")
parser.add_argument('out_dir', parser.add_argument('out_dir',
help="Output path to save tile information to (ex. '/data/tiles/{product}')") 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 '--')") help="Input geotiffs to generate tiles for (separate from product lists with '--')")
args = parser.parse_args() args = parser.parse_args()
groups = group_files(args.products, args.input_files) groups = group_files(args.products, args.input_files)
for prod, prod_files in groups.items(): 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) 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) shp_pathname = os.path.join(out_dir, shp_fn)
# remap if needed # remap if needed
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment