-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Updates to 2024 fuel grid - polygonize excludes NoData values
- Loading branch information
Showing
4 changed files
with
54 additions
and
5 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
48 changes: 48 additions & 0 deletions
48
api/alembic/versions/f9ab4e6a7eeb_2024_fuel_grid_update.py
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,48 @@ | ||
"""2024 fuel grid update | ||
Revision ID: f9ab4e6a7eeb | ||
Revises: 2b3755392ad8 | ||
Create Date: 2024-05-08 10:25:04.121562 | ||
""" | ||
from alembic import op | ||
import sqlalchemy as sa | ||
from app.db.models.auto_spatial_advisory import SFMSFuelType, FuelType | ||
from app.auto_spatial_advisory.fuel_type_layer import fuel_type_iterator | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = 'f9ab4e6a7eeb' | ||
down_revision = '2b3755392ad8' | ||
branch_labels = None | ||
depends_on = None | ||
|
||
m3_fuel_type = { | ||
'fuel_type_id': 13, | ||
'fuel_type_code': 'M-3', | ||
'description': 'Dead Balsam Fir Mixedwood' | ||
} | ||
|
||
def upgrade(): | ||
# add missing fuel type to SFMSFuelType table | ||
stmt = sa.insert(SFMSFuelType).values(fuel_type_id=m3_fuel_type['fuel_type_id'], fuel_type_code=m3_fuel_type['fuel_type_code'], description=m3_fuel_type['description']) | ||
op.execute(stmt) | ||
|
||
# Delete all the fuel types. | ||
op.execute(sa.delete(FuelType)) | ||
|
||
# Iterate through the fuel types and insert them. | ||
for fuel_type_id, geom in fuel_type_iterator('fbp2024.tif'): | ||
statement = sa.insert(FuelType).values(fuel_type_id=fuel_type_id, geom=geom) | ||
op.execute(statement) | ||
|
||
|
||
def downgrade(): | ||
stmt = sa.delete(SFMSFuelType).where(SFMSFuelType.fuel_type_id == m3_fuel_type['fuel_type_id']) | ||
op.execute(stmt) | ||
|
||
# Delete all the fuel types. | ||
op.execute(sa.delete(FuelType)) | ||
|
||
for fuel_type_id, geom in fuel_type_iterator('fbp2021.tif'): | ||
statement = sa.insert(FuelType).values(fuel_type_id=fuel_type_id, geom=geom) | ||
op.execute(statement) |
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