Skip to content

Instantly share code, notes, and snippets.

@JhoLee
Last active August 6, 2020 12:53
Show Gist options
  • Save JhoLee/caffd4b05137ffa395216265033e0885 to your computer and use it in GitHub Desktop.
Save JhoLee/caffd4b05137ffa395216265033e0885 to your computer and use it in GitHub Desktop.
#!/bin/bash
# $1: osm_directory_path
## if directory exists, parse file lists,
EXT_LIST=(".osm" ".osm.pbf")
if [ -e $1 ]; then
# OSM2PGSQL
count=1
OSM_LIST=($(ls $1/*.osm*))
echo "[O2P] Found ${#OSM_LIST[@]} osm files from $1"
for f in $OSM_LIST; do
echo "[O2P] ${count}/${#OSM_LIST[@]} Importing \"$f\"..."
/o2p $f
count=$((count+1))
done
# SHP2PGSQL
count=1
SHP_LIST=($(ls $1/*.shp))
echo "[S2P] Found ${#SHP_LIST[@]} shp files from $1"
for f in $SHP_LIST; do
echo "[S2P] ${count}/${#SHP_LIST[@]} Importing \"$f\"..."
/s2p $f
count=$((count+1))
done
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment