Created
February 13, 2024 05:42
-
-
Save krishnaglodha/079dfb7aaef5bb785d43657be0fa7931 to your computer and use it in GitHub Desktop.
Send GeoJSON to existing postgis table
This file contains 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
#!/bin/bash | |
# Set the variables | |
PGHOST="" | |
PGDATABASE="" | |
PGUSER="" | |
PGPASSWORD="" | |
PGPORT="" | |
TABLE_NAME="" | |
GEOJSON_FILE="" | |
SCHEMA_NAME="" | |
# Use ogr2ogr to append GeoJSON data to the existing table in PostgreSQL | |
ogr2ogr -f "PostgreSQL" PG:"host=$PGHOST dbname=$PGDATABASE user=$PGUSER password=$PGPASSWORD port=$PGPORT" \ | |
-nln "$SCHEMA_NAME.$TABLE_NAME" -progress -append $GEOJSON_FILE | |
# Check if the ogr2ogr command was successful | |
if [ $? -eq 0 ]; then | |
echo "GeoJSON data appended to the PostgreSQL table successfully." | |
else | |
echo "Error: Unable to append GeoJSON data to the PostgreSQL table." | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment