Skip to content

Instantly share code, notes, and snippets.

@alpha-beta-soup
Last active August 7, 2025 02:16
Show Gist options
  • Select an option

  • Save alpha-beta-soup/26d7116bbc53a47fa3ce9cf7f9cd76f2 to your computer and use it in GitHub Desktop.

Select an option

Save alpha-beta-soup/26d7116bbc53a47fa3ce9cf7f9cd76f2 to your computer and use it in GitHub Desktop.
Experiments with a commit time modification in a Kart archive for pre-existing geospatial data
#!/bin/bash
CLEAR='\033[0m'
RED='\033[0;31m'
function usage() {
if [ -n "$1" ]; then
echo -e "${RED}👉 $1${CLEAR}\n";
fi
echo "Usage: $0 [-u url]"
echo " -u, --url The QEII download URL"
echo ""
echo "Example: $0 --url https://mcusercontent.com/7e7527238b895050d20f82859/files/c8a3ad0e-bf15-31e6-59a2-0482cf0b2481/QEII_OSCovenants_20230929.zip"
exit 1
}
while [[ "$#" -gt 0 ]]; do
case $1 in
-u|--url) URL="$2";shift;shift;;
*) echo "Unknown parameter passed: $1"; exit 1 ;;
esac
shift
done
if [ -z "$URL" ]; then usage "URL is not set"; fi;
TMPF=$(mktemp).zip
BASENAME=./$(basename $URL)
FNAME="${BASENAME%.*}"
curl -iL "$URL" --output $TMPF
unzip -o $TMPF -d $FNAME
rm $TMPF
ogr2ogr -overwrite -nlt MULTIPOLYGON -nln qeii $FNAME/$FNAME.gpkg $FNAME/$FNAME.shp
#!/bin/bash
# Get some downloaded data, in this case, three time-steps of data downloaded from the Queen Elizabeth II National Trust,
# all in the same schema
./download.sh -u https://mcusercontent.com/7e7527238b895050d20f82859/files/0c921999-84b7-0afa-a659-829392844f2e/QEII_OSCovenants_20230328.zip
./download.sh -u https://mcusercontent.com/7e7527238b895050d20f82859/files/c8ee486f-2053-67d0-7b9d-3bfb12a1a5be/QEII_OSCovenants_20230630.zip
./download.sh -u https://mcusercontent.com/7e7527238b895050d20f82859/files/c8a3ad0e-bf15-31e6-59a2-0482cf0b2481/QEII_OSCovenants_20230929.zip
# We want to put these into the same kart repository, and amend the commit date to represent the data's publication date
# These sample times are obtained manually from the response headers of the above links
kart init qeii-kart
cd qeii-kart
kart import ../downloads/QEII_OSCovenants_20230328/QEII_OSCovenants_20230328.gpkg --all-tables --primary-key CovNumber
GIT_COMMITTER_DATE="Tue 28 Mar 03:01:20 2023 GMT" kart commit-files -m "Import from QEII_OSCovenants_20230328.gpkg:qeii to qeii/" --amend
kart import ../downloads/QEII_OSCovenants_20230630/QEII_OSCovenants_20230630.gpkg --all-tables --replace-existing --primary-key CovNumber
GIT_COMMITTER_DATE="Fri 30 Jun 05:04:59 2023 GMT" kart commit-files -m "Import from QEII_OSCovenants_20230630.gpkg:qeii to qeii/" --amend
kart import ../downloads/QEII_OSCovenants_20230929/QEII_OSCovenants_20230929.gpkg --all-tables --replace-existing --primary-key CovNumber
GIT_COMMITTER_DATE="Sun 01 Oct 21:44:12 2023 GMT" kart commit-files -m "Import from QEII_OSCovenants_20230929.gpkg:qeii to qeii/" --amend
@alpha-beta-soup
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment