Created
February 8, 2023 14:16
-
-
Save arbakker/8f4c045f3d7d08c855dc54f9023bc69d to your computer and use it in GitHub Desktop.
check if layers in geopackage are within bbox #bash #geopackage #ogr/gdal
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#/usr/bin/env bash | |
layer_count=0 | |
for file in *.gpkg;do | |
while read -r layer;do | |
echo "$layer" | |
count=$(ogrinfo $file -sql "select count(*) as count_outside from ${layer} where not Intersects(geom, BuildMbr(3419623.11185873579233885, 3033416.80487128812819719, 4526147.91013043466955423, 3477617.21156968083232641, 3035))" | grep "count_outside.*=" | cut -d= -f2) | |
if [[ count -ne 0 ]];then | |
echo "${count} features outside Netherlands in ${file}/${layer}" | |
else | |
echo "... ${count} features outside Netherlands in ${file}/${layer}" | |
fi | |
layer_count=$((layer_count+1)) | |
done < <(ogrinfo $file | tail -n+3 | cut -d: -f2 | cut -d" " -f2) | |
done | |
echo "layer_count: $layer_count" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment