Skip to content

Instantly share code, notes, and snippets.

@glw
Last active June 21, 2024 18:52
Show Gist options
  • Save glw/9928081 to your computer and use it in GitHub Desktop.
Save glw/9928081 to your computer and use it in GitHub Desktop.
load shapefile into Amazon RDS PostGIS
shp2pgsql -s 4326 -d -g the_geom shapefilename.shp shapefilename |psql -U username --password -p 5432 -h reallylonghostnametoamazonaws.com dbname
@rfilmyer
Copy link

rfilmyer commented May 3, 2017

I found this gist on google, so I wanted to offer some tips and explanation to other people who want to load a shapefile into PostGIS:

Arguments of the shp2pgsql command:

  • -s 4326: This specifies the SRID (projection) of your shapefile. Use 4326 if your shapefile uses WGS84. But if you are using TIGER shapefiles from the US Census Bureau, you are looking for NAD83 (SRID 4269).
  • -d: This drops the table and rebuilds it.
  • -g the_geom: This is what the column with the actual polygon geometry will be named in your table
  • shapefilename.shp: This is the filename of your shapefile
  • shapefilename: This will be the name of the table created with your shapefile data.

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