Skip to content

Instantly share code, notes, and snippets.

@stuzero
Last active April 20, 2022 03:01
Show Gist options
  • Save stuzero/f6d0137dd3a46aa2bfec5533d71a7da4 to your computer and use it in GitHub Desktop.
Save stuzero/f6d0137dd3a46aa2bfec5533d71a7da4 to your computer and use it in GitHub Desktop.

Prepare the Server

$ sudo apt install build-essential unzip

Install PROJ 7.1

$ cd /usr/local/src
$ sudo wget https://download.osgeo.org/proj/proj-7.1.1.tar.gz
$ sudo tar -xzvf proj-7.1.1.tar.gz
$ sudo rm proj-7.1.1.tar.gz
$ cd proj-7.1.1
$ sudo apt install pkg-config libsqlite3-dev sqlite3 libtiff-dev libcurl4-openssl-dev
$ sudo ./configure
$ sudo make
$ sudo make install

Install GEOS 3.8

$ cd /usr/local/src
$ sudo wget http://download.osgeo.org/geos/geos-3.8.1.tar.bz2
$ sudo tar -xvf geos-3.8.1.tar.bz2
$ sudo rm geos-3.8.1.tar.bz2
$ cd geos-3.8.1
$ sudo apt-get install swig python3-dev
$ sudo ./configure --enable-python
$ sudo make
$ sudo make install

Install GDAL 3.1.3

$ cd /usr/local/src
$ sudo wget https://github.com/OSGeo/gdal/releases/download/v3.1.3/gdal-3.1.3.tar.gz
$ sudo ./configure
$ sudo make
$ sudo make install
$ sudo /sbin/ldconfig

Load Shapefile to Postgresql Server

$ mkdir us_county
$ cd us_county
$ wget https://www2.census.gov/geo/tiger/TIGER2021/COUNTY/tl_2021_us_county.zip
$ unzip tl_2021_us_county.zip
$ ogr2ogr -f "PostgreSQL" -a_srs "EPSG:4326"  PG:"host=db.prod.example.com dbname=mydb user=postgres password=password" tl_2021_us_county.shp -nln us_county -nlt PROMOTE_TO_MULTI
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment