reorganized folders

This commit is contained in:
2025-04-19 06:48:25 -07:00
parent a45e8ca299
commit 3c8b4fccd3
19 changed files with 0 additions and 125 deletions

53136
data/Nursing_Homes.geojson Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

491
data/geojson.ipynb Normal file
View File

@@ -0,0 +1,491 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd\n",
"from sqlalchemy import create_engine\n",
"import geopandas as gpd\n",
"\n",
"\n",
"from dotenv import load_dotenv\n",
"load_dotenv()\n",
"\n",
"db_name = 'colorado_spills'\n",
"user = os.getenv('DB_USER')\n",
"password = os.getenv('DB_PASSWORD')\n",
"host = os.getenv('DB_HOST')\n",
"port = os.getenv('DB_PORT')\n",
"\n",
"\n",
"# Create an engine to connect to the PostgreSQL database\n",
"engine = create_engine(f'postgresql+psycopg2://{user}:{password}@{host}:{port}/{db_name}')\n",
"\n",
"# Read in the spills as spills\n",
"spills = pd.read_sql('spills', engine)"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Document #</th>\n",
" <th>Report</th>\n",
" <th>Operator</th>\n",
" <th>Operator #</th>\n",
" <th>Tracking #</th>\n",
" <th>Initial Report Date</th>\n",
" <th>Date of Discovery</th>\n",
" <th>Spill Type</th>\n",
" <th>Qtr Qtr</th>\n",
" <th>Section</th>\n",
" <th>...</th>\n",
" <th>Offsite Disposal</th>\n",
" <th>Onsite Treatment</th>\n",
" <th>Other Disposition</th>\n",
" <th>Other Disposition Description</th>\n",
" <th>Ground Water Removed</th>\n",
" <th>Surface Water Removed</th>\n",
" <th>Corrective Actions Completed</th>\n",
" <th>Approved Form 27</th>\n",
" <th>Form 27 Project Number</th>\n",
" <th>geometry</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>400628833</td>\n",
" <td>I w/S</td>\n",
" <td>GREAT WESTERN OPERATING COMPANY LLC</td>\n",
" <td>10110</td>\n",
" <td>400628833</td>\n",
" <td>06/18/2014</td>\n",
" <td>06/11/2014</td>\n",
" <td>Historical</td>\n",
" <td>SESE</td>\n",
" <td>2</td>\n",
" <td>...</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>1.0</td>\n",
" <td>No work performed yet</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>False</td>\n",
" <td>NaN</td>\n",
" <td>2141471.0</td>\n",
" <td>POINT (-104.51097 39.81959)</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>400629910</td>\n",
" <td>I</td>\n",
" <td>COLORADO OIL &amp; GAS CONSERVATION COMMISSION</td>\n",
" <td>5</td>\n",
" <td>400629910</td>\n",
" <td>06/19/2014</td>\n",
" <td>06/14/2014</td>\n",
" <td>Historical</td>\n",
" <td>NWNE</td>\n",
" <td>1</td>\n",
" <td>...</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>None</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>False</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>POINT (-104.61818 40.08456)</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>400629998</td>\n",
" <td>S</td>\n",
" <td>COLORADO OIL &amp; GAS CONSERVATION COMMISSION</td>\n",
" <td>5</td>\n",
" <td>400629910</td>\n",
" <td>06/19/2014</td>\n",
" <td>06/14/2014</td>\n",
" <td>Historical</td>\n",
" <td>NWNE</td>\n",
" <td>1</td>\n",
" <td>...</td>\n",
" <td>1.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>None</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>True</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>POINT (-104.61818 40.08456)</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>400630821</td>\n",
" <td>I</td>\n",
" <td>KERR MCGEE GATHERING LLC</td>\n",
" <td>47121</td>\n",
" <td>400630821</td>\n",
" <td>06/20/2014</td>\n",
" <td>06/19/2014</td>\n",
" <td>Recent</td>\n",
" <td>NWNW</td>\n",
" <td>15</td>\n",
" <td>...</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>None</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>False</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>POINT (-104.88494 40.05447)</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>400631216</td>\n",
" <td>I</td>\n",
" <td>NOBLE ENERGY INC</td>\n",
" <td>100322</td>\n",
" <td>400631216</td>\n",
" <td>06/23/2014</td>\n",
" <td>06/20/2014</td>\n",
" <td>Recent</td>\n",
" <td>NENW</td>\n",
" <td>36</td>\n",
" <td>...</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>None</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>False</td>\n",
" <td>NaN</td>\n",
" <td>2141511.0</td>\n",
" <td>POINT (-104.84506 40.44426)</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>16885</th>\n",
" <td>403825450</td>\n",
" <td>I w/S</td>\n",
" <td>NOBLE ENERGY INC</td>\n",
" <td>100322</td>\n",
" <td>403825450</td>\n",
" <td>06/14/2024</td>\n",
" <td>06/13/2024</td>\n",
" <td>Historical</td>\n",
" <td>SWSE</td>\n",
" <td>7</td>\n",
" <td>...</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>None</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>False</td>\n",
" <td>1.0</td>\n",
" <td>33291.0</td>\n",
" <td>POINT (-104.48176 40.3205)</td>\n",
" </tr>\n",
" <tr>\n",
" <th>16886</th>\n",
" <td>403825485</td>\n",
" <td>I w/S</td>\n",
" <td>NOBLE ENERGY INC</td>\n",
" <td>100322</td>\n",
" <td>403825485</td>\n",
" <td>06/14/2024</td>\n",
" <td>06/13/2024</td>\n",
" <td>Historical</td>\n",
" <td>SWSE</td>\n",
" <td>7</td>\n",
" <td>...</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>None</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>False</td>\n",
" <td>1.0</td>\n",
" <td>33291.0</td>\n",
" <td>POINT (-104.48225 40.32023)</td>\n",
" </tr>\n",
" <tr>\n",
" <th>16887</th>\n",
" <td>403825575</td>\n",
" <td>I w/S</td>\n",
" <td>NOBLE ENERGY INC</td>\n",
" <td>100322</td>\n",
" <td>403825575</td>\n",
" <td>06/14/2024</td>\n",
" <td>06/13/2024</td>\n",
" <td>Historical</td>\n",
" <td>SWSE</td>\n",
" <td>7</td>\n",
" <td>...</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>None</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>False</td>\n",
" <td>1.0</td>\n",
" <td>33291.0</td>\n",
" <td>POINT (-104.48256 40.32007)</td>\n",
" </tr>\n",
" <tr>\n",
" <th>16888</th>\n",
" <td>403826200</td>\n",
" <td>I</td>\n",
" <td>NOBLE ENERGY INC</td>\n",
" <td>100322</td>\n",
" <td>403826200</td>\n",
" <td>06/14/2024</td>\n",
" <td>06/14/2024</td>\n",
" <td>Recent</td>\n",
" <td>SWSE</td>\n",
" <td>5</td>\n",
" <td>...</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>None</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>False</td>\n",
" <td>0.0</td>\n",
" <td>NaN</td>\n",
" <td>POINT (-104.57222 40.50979)</td>\n",
" </tr>\n",
" <tr>\n",
" <th>16889</th>\n",
" <td>403826294</td>\n",
" <td>I</td>\n",
" <td>CAERUS PICEANCE LLC</td>\n",
" <td>10456</td>\n",
" <td>403826294</td>\n",
" <td>06/15/2024</td>\n",
" <td>06/15/2024</td>\n",
" <td>Recent</td>\n",
" <td>NESW</td>\n",
" <td>22</td>\n",
" <td>...</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>None</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>False</td>\n",
" <td>0.0</td>\n",
" <td>NaN</td>\n",
" <td>POINT (-108.15951 39.59893)</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>16890 rows × 107 columns</p>\n",
"</div>"
],
"text/plain": [
" Document # Report Operator \\\n",
"0 400628833 I w/S GREAT WESTERN OPERATING COMPANY LLC \n",
"1 400629910 I COLORADO OIL & GAS CONSERVATION COMMISSION \n",
"2 400629998 S COLORADO OIL & GAS CONSERVATION COMMISSION \n",
"3 400630821 I KERR MCGEE GATHERING LLC \n",
"4 400631216 I NOBLE ENERGY INC \n",
"... ... ... ... \n",
"16885 403825450 I w/S NOBLE ENERGY INC \n",
"16886 403825485 I w/S NOBLE ENERGY INC \n",
"16887 403825575 I w/S NOBLE ENERGY INC \n",
"16888 403826200 I NOBLE ENERGY INC \n",
"16889 403826294 I CAERUS PICEANCE LLC \n",
"\n",
" Operator # Tracking # Initial Report Date Date of Discovery \\\n",
"0 10110 400628833 06/18/2014 06/11/2014 \n",
"1 5 400629910 06/19/2014 06/14/2014 \n",
"2 5 400629910 06/19/2014 06/14/2014 \n",
"3 47121 400630821 06/20/2014 06/19/2014 \n",
"4 100322 400631216 06/23/2014 06/20/2014 \n",
"... ... ... ... ... \n",
"16885 100322 403825450 06/14/2024 06/13/2024 \n",
"16886 100322 403825485 06/14/2024 06/13/2024 \n",
"16887 100322 403825575 06/14/2024 06/13/2024 \n",
"16888 100322 403826200 06/14/2024 06/14/2024 \n",
"16889 10456 403826294 06/15/2024 06/15/2024 \n",
"\n",
" Spill Type Qtr Qtr Section ... Offsite Disposal Onsite Treatment \\\n",
"0 Historical SESE 2 ... 0.0 0.0 \n",
"1 Historical NWNE 1 ... NaN NaN \n",
"2 Historical NWNE 1 ... 1.0 0.0 \n",
"3 Recent NWNW 15 ... NaN NaN \n",
"4 Recent NENW 36 ... NaN NaN \n",
"... ... ... ... ... ... ... \n",
"16885 Historical SWSE 7 ... 0.0 0.0 \n",
"16886 Historical SWSE 7 ... 0.0 0.0 \n",
"16887 Historical SWSE 7 ... 0.0 0.0 \n",
"16888 Recent SWSE 5 ... NaN NaN \n",
"16889 Recent NESW 22 ... NaN NaN \n",
"\n",
" Other Disposition Other Disposition Description Ground Water Removed \\\n",
"0 1.0 No work performed yet NaN \n",
"1 NaN None NaN \n",
"2 0.0 None 0.0 \n",
"3 NaN None NaN \n",
"4 NaN None NaN \n",
"... ... ... ... \n",
"16885 0.0 None 0.0 \n",
"16886 0.0 None 0.0 \n",
"16887 0.0 None 0.0 \n",
"16888 NaN None NaN \n",
"16889 NaN None NaN \n",
"\n",
" Surface Water Removed Corrective Actions Completed Approved Form 27 \\\n",
"0 NaN False NaN \n",
"1 NaN False NaN \n",
"2 0.0 True NaN \n",
"3 NaN False NaN \n",
"4 NaN False NaN \n",
"... ... ... ... \n",
"16885 0.0 False 1.0 \n",
"16886 0.0 False 1.0 \n",
"16887 0.0 False 1.0 \n",
"16888 NaN False 0.0 \n",
"16889 NaN False 0.0 \n",
"\n",
" Form 27 Project Number geometry \n",
"0 2141471.0 POINT (-104.51097 39.81959) \n",
"1 NaN POINT (-104.61818 40.08456) \n",
"2 NaN POINT (-104.61818 40.08456) \n",
"3 NaN POINT (-104.88494 40.05447) \n",
"4 2141511.0 POINT (-104.84506 40.44426) \n",
"... ... ... \n",
"16885 33291.0 POINT (-104.48176 40.3205) \n",
"16886 33291.0 POINT (-104.48225 40.32023) \n",
"16887 33291.0 POINT (-104.48256 40.32007) \n",
"16888 NaN POINT (-104.57222 40.50979) \n",
"16889 NaN POINT (-108.15951 39.59893) \n",
"\n",
"[16890 rows x 107 columns]"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"spills['geometry'] = gpd.points_from_xy(spills['Longitude'], spills['Latitude'])\n",
"spills = gpd.GeoDataFrame(spills, geometry='geometry')\n",
"spills.set_crs(epsg=4326, inplace=True) # WGS 84"
]
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {},
"outputs": [],
"source": [
"from geoalchemy2 import Geometry, WKTElement\n",
"\n",
"# Convert to GeoDataFrame\n",
"spills['geometry'] = gpd.points_from_xy(spills['Longitude'], spills['Latitude'])\n",
"spills = gpd.GeoDataFrame(spills, geometry='geometry')\n",
"spills.set_crs(epsg=4326, inplace=True)\n",
"\n",
"# Save to database and create geojson\n",
"spills.to_postgis('spills', engine, if_exists='replace', index=False)\n",
"spills.to_file('spills.geojson', driver='GeoJSON')\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "spatial_env2",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.15"
}
},
"nbformat": 4,
"nbformat_minor": 2
}

16897
data/spills.geojson Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long