-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ac0d403
commit efefa51
Showing
74 changed files
with
7,904 additions
and
8,529 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
processed_data/merged_basin_groups/region_polygons.zip filter=lfs diff=lfs merge=lfs -text | ||
input_data/adjusted_region_polygons.zip filter=lfs diff=lfs merge=lfs -text |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import pandas as pd | ||
import numpy as np | ||
import geopandas as gpd | ||
import psycopg2 | ||
|
||
columns = [ | ||
'official_id', 'watershed_id', 'name', 'centroid_lat_deg_n', 'centroid_lon_deg_e', | ||
'drainage_area_km2', 'drainage_area_gsim_km2', 'flag_gsim_boundaries', 'flag_artificial_boundaries', | ||
'elevation_m', 'slope_deg', 'gravelius', 'perimeter', 'flag_shape_extraction', 'aspect_deg', 'flag_terrain_extraction', | ||
'land_use_forest_frac_2010', 'land_use_grass_frac_2010', 'land_use_wetland_frac_2010', | ||
'land_use_water_frac_2010', 'land_use_urban_frac_2010', 'land_use_shrubs_frac_2010', | ||
'land_use_crops_frac_2010', 'land_use_snow_ice_frac_2010', 'flag_land_use_extraction', | ||
'logk_ice_x100', 'porosity_x100', 'flag_subsoil_extraction', 'year_from', 'year_to', | ||
'record_length', 'agency', 'status', 'updated_official_basin', 'in_bcub', | ||
'prcp', 'srad', 'swe', 'tmax', 'tmin', 'vp', | ||
'high_prcp_freq', 'high_prcp_duration', 'low_prcp_freq', 'low_prcp_duration' | ||
] | ||
|
||
def get_hysets_attributes(columns, conn): | ||
""" | ||
Get hysets attributes by hysets_id | ||
:param hysets_id: int | ||
:param conn: psycopg2 connection | ||
:return: pd.DataFrame | ||
""" | ||
# Get hysets attributes | ||
if columns is None: | ||
query = f""" | ||
SELECT * FROM basins_schema.hysets_basins | ||
WHERE in_bcub = True | ||
LIMIT 10; | ||
""" | ||
hysets_attributes = gpd.read_postgis(query, conn, geom_col='centroid') | ||
else: | ||
column_string = ', '.join(columns) | ||
query = f""" | ||
SELECT {column_string} FROM basins_schema.hysets_basins | ||
WHERE in_bcub = True | ||
ORDER BY official_id; | ||
""" | ||
hysets_attributes = pd.read_sql_query(query, conn) | ||
return hysets_attributes | ||
|
||
conn_info = { | ||
'dbname': 'basins', | ||
'user': 'postgres', | ||
'password': 'pgpass', | ||
'host': 'localhost', | ||
'port': '5432' | ||
} | ||
conn = psycopg2.connect(**conn_info) | ||
|
||
df = get_hysets_attributes(columns, conn) | ||
df.to_csv('BCUB_HYSETS_properties_with_climate.csv', index=False) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
102.93548597422287116 | ||
0 | ||
0 | ||
-102.93548597422287116 | ||
1158699.56954298727214336 | ||
1110379.6146800983697176 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Binary file not shown.
Oops, something went wrong.