Create and Prepare the nyc Example DataBaseΒΆ

This small section contains a step-by-step guide for the creation and population of an database containing few geospatial tables of New York City:

  • giant_polygon
  • poi
  • poly_landmarks
  • tiger_roads
  1. Log as postgres system user

    $ su - postgres
    
  2. Create the role bob with password postgres

    $ psql -c "CREATE ROLE bob LOGIN ENCRYPTED PASSWORD 'md565170a859842ceb2930dc2fa1454af9d' CREATEDB VALID UNTIL 'infinity';"
    
  3. Create the database nyc with the geospatial extensions

    $ createdb nyc
    $ psql -d nyc -c 'CREATE EXTENSION postgis;'
    $ psql -d nyc -c 'GRANT ALL ON geometry_columns TO PUBLIC;'
    $ psql -d nyc -c 'GRANT ALL ON spatial_ref_sys TO PUBLIC;'
    
  4. Restore the tables into the database from the dump

    $ psql -d nyc < /tmp/nyc.dump
    
  5. Test that everything is OK by connecting to the database and listing the tables

    $ psql nyc
    \dt