Skip to content

Commit

Permalink
Added a shell script that ingests an image catalog and creates a logi…
Browse files Browse the repository at this point in the history
…cal folder hierarchy to the image files.

- Ingests a CSV image catalog containing the filepath, projection, resolution, and color model fields
- Creates a folder hierarchy representing unique combinations of color, projection and scale
- Populates the folder hierarchy with symbolic links to the files in the image catalog
  • Loading branch information
emxsys committed Dec 15, 2017
1 parent a28f6eb commit f63bd4d
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions scripts/mosaics/process_image_catalog.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash
## Must run with bash shell to used variable substitution: "${var//pattern/substituion}"

set -x

# Set the source image catalog CSV file: filename;projcs;geogcs;resolution;color
input=image_catalog.csv

# Process the input file.
# Note: IFS is a special shell variable: the "Internal Field Separator" used by read
while IFS=\; read filename projection resolution color; do

# Skip the header row
if [ "$filename" = "filepath" ]; then
continue
fi

# Get the file name components
dirname=$(dirname $filename)
basename=$(basename $filename)
auxname=${basename}.aux.xml

# Define the filepath where the categorized image (link) will be stored
folder=${projection}"/"${color}"/"${resolution}

# Create the folder hierarchy
if [ ! -d $folder ]; then
mkdir -p $folder
fi

# Create a symbolic link to the image in the folder
ln -s $filename $folder/$basename
ln -s $dirname/$auxname $folder/$auxname

done < "$input"

0 comments on commit f63bd4d

Please sign in to comment.