Skip to content

ovipaul/Under-the-Sea

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Under the Sea - Sea Level Rise Explorer

An interactive web application for visualizing and analyzing the impact of sea level rise on coastal communities using elevation data and census demographics.

Features

  • Interactive Map Interface: Draw rectangles on a map to select areas for analysis
  • Elevation Analysis: Download and process DEM (Digital Elevation Model) data from NASA
  • Flood Simulation: Visualize areas that would be underwater at different sea level rise scenarios
  • Census Demographics: Analyze population and housing impacts using 2020 US Census data
  • Real-time Calculations: See affected population, housing units, and demographic breakdowns

Prerequisites

Required Software

  • Python 3.9+
  • PostgreSQL 14+ with PostGIS extension
  • Git

macOS Installation

# Install PostgreSQL and PostGIS
brew install postgresql@14 postgis

# Start PostgreSQL service
brew services start postgresql@14

Setup Instructions

1. Clone the Repository

git clone https://github.com/ovipaul/Under-the-Sea.git
cd Under-the-Sea

2. Create Virtual Environment

python -m venv .venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate

3. Install Dependencies

pip install -r requirements.txt

4. Database Setup

Create Database and User

# Connect to PostgreSQL
psql

-- Create user and database
CREATE ROLE slr_user WITH LOGIN PASSWORD 'your_secure_password';
CREATE DATABASE slr OWNER slr_user;
\q

Enable PostGIS Extension

# Connect to the new database
psql -d slr

-- Enable PostGIS
CREATE EXTENSION postgis;
\q

Import Census Data

# Import shapefile to PostgreSQL (requires ogr2ogr)
ogr2ogr -f "PostgreSQL" \
  PG:"host=localhost dbname=slr user=slr_user password=your_secure_password" \
  USA_Census_2020_Redistricting_Tracts/Tracts.shp \
  -nln census_tracts \
  -lco GEOMETRY_NAME=geom \
  -lco PRECISION=NO \
  -nlt PROMOTE_TO_multi \
  -overwrite

Running the Application

streamlit run app.py

The application will open in your browser at http://localhost:8501

How to Use

  1. Select Area: Use the sidebar to choose between:

    • Draw Rectangle: Interactive map drawing
    • Enter Coordinates: Manual coordinate input
  2. Draw on Map: Click and drag to draw a rectangle on the map

  3. Set Parameters:

    • Adjust sea level rise (in meters)
    • Click "Run Analysis"
  4. View Results:

    • Affected area percentage and size
    • Elevation distribution chart
    • Population and housing impact
    • Demographic breakdowns

Project Structure

Under-the-Sea/
├── app.py                          # Main Streamlit application
├── requirements.txt                # Python dependencies
├── README.md                      # This file
├── LICENSE                        # MIT License
├── utility/
│   ├── census_analysis.py         # Census data processing
│   └── download_dem.py           # DEM data download
└── USA_Census_2020_Redistricting_Tracts/
    ├── Tracts.shp                # Census tract shapefile
    ├── Tracts.dbf                # Attribute data
    ├── Tracts.prj                # Projection info
    ├── Tracts.shx                # Spatial index
    └── Tracts.cpg                # Code page info

Data Sources

  • Elevation Data: NASA SRTM GL1 30m resolution DEM
  • Census Data: 2020 US Census PL 94-171 Redistricting Data
  • Geographic Projections: WGS84 (EPSG:4326) for coordinates, US Albers Equal Area (EPSG:5070) for calculations

Configuration

Database Connection

The application connects to PostgreSQL using these default settings:

DATABASE_URL = "postgresql://slr_user:your_secure_password@localhost:5432/slr"

To change the connection, modify the db_url variable in utility/census_analysis.py.

API Keys

No API keys are required - the application uses publicly available NASA elevation data.

Troubleshooting

Common Issues

Database Connection Error:

  • Ensure PostgreSQL is running: brew services start postgresql@14
  • Check database credentials and name
  • Verify PostGIS extension is installed

Import Error for ogr2ogr:

# Install GDAL tools
brew install gdal

Census Data Not Found:

  • Ensure shapefile was imported successfully
  • Check table exists: psql -d slr -c "\dt"

Contributing

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature-name
  3. Make changes and test locally
  4. Commit: git commit -am 'Add feature'
  5. Push: git push origin feature-name
  6. Create a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  • NASA for providing free elevation data through SRTM
  • US Census Bureau for demographic data
  • Open source geospatial community (GDAL, GeoPandas, Rasterio)
  • Streamlit for the web framework

Made for coastal resilience research

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors