An interactive web application for visualizing and analyzing the impact of sea level rise on coastal communities using elevation data and census demographics.
- 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
- Python 3.9+
- PostgreSQL 14+ with PostGIS extension
- Git
# Install PostgreSQL and PostGIS
brew install postgresql@14 postgis
# Start PostgreSQL service
brew services start postgresql@14git clone https://github.com/ovipaul/Under-the-Sea.git
cd Under-the-Seapython -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activatepip install -r requirements.txt# 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# Connect to the new database
psql -d slr
-- Enable PostGIS
CREATE EXTENSION postgis;
\q# 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 \
-overwritestreamlit run app.pyThe application will open in your browser at http://localhost:8501
-
Select Area: Use the sidebar to choose between:
- Draw Rectangle: Interactive map drawing
- Enter Coordinates: Manual coordinate input
-
Draw on Map: Click and drag to draw a rectangle on the map
-
Set Parameters:
- Adjust sea level rise (in meters)
- Click "Run Analysis"
-
View Results:
- Affected area percentage and size
- Elevation distribution chart
- Population and housing impact
- Demographic breakdowns
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
- 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
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.
No API keys are required - the application uses publicly available NASA elevation data.
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 gdalCensus Data Not Found:
- Ensure shapefile was imported successfully
- Check table exists:
psql -d slr -c "\dt"
- Fork the repository
- Create a feature branch:
git checkout -b feature-name - Make changes and test locally
- Commit:
git commit -am 'Add feature' - Push:
git push origin feature-name - Create a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- 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