- The default environment (base) has gdal 2.3.3 ($ gdalinfo --version)which doesn't work properly with PostgreSQL 12 for ogr2ogr script. To fix it, I create a new environment named (postgis) which have gdal 3.2.0. Remember to activate postgis ($ conda activate postgis) before running any ogr2ogr scripts
OS: MacOS or Linux
ogr2ogr
# do not use any space!!!
folder=/Users/evan/Ev/Python/postgis_cookbook_learning-notes/chp03/data/HUN_adm
data=$folder/HUN_adm1.shp
ogr2ogr -f "PostgreSQL" -t_srs EPSG:3857 -nlt MULTIPOLYGON -lco GEOMETRY_NAME=geom -nln chp03.hungary -lco OVERWRITE=YES PG:"host="127.0.0.1" user="evan" dbname="postgis_cookbook" password="Toptiger1234"" $data
shp2phsql
path_in=/Users/evan/Ev/Python/PostGIS-Cookbook/Chapter03/wborders
path_out=/Users/evan/Ev/Python/PostGIS-Cookbook/ev/shp2pgsql
data_in=$path_in/wborders.shp
data_out=$path_out/wborders.sql
shp2pgsql -s 4326 -g geom -W LATIN1 -I $data_in chp03.wborders > $data_out
- Improving proximity filtering with KNN – advanced: Provide two methods to calculate KNN of every single point in one dataset
- Translating, scaling, and rotating geometries - advanced: Provides an extremely useful cases to create a set of grid around points of interest