Skip to content

Instantly share code, notes, and snippets.

@nikmolnar
Created July 10, 2016 21:34
Show Gist options
  • Save nikmolnar/9f9ecb16877fe0f812f8cf4f5275e0cc to your computer and use it in GitHub Desktop.
Save nikmolnar/9f9ecb16877fe0f812f8cf4f5275e0cc to your computer and use it in GitHub Desktop.
import os
from pyproj import Proj
DEM = 'aligned_elevation.nc'
DATA_DIR = 'west1/1961_1990Y/'
ZONES_DIR = 'seed_zones/'
OUTPUT_DIR = 'output/'
CRS = {'init': 'EPSG:4326'}
PROJECTION = Proj(**CRS)
VARIABLES = (
'AHM', 'bFFP', 'CMD', 'DD_0', 'DD_18', 'DD5', 'DD18', 'eFFP', 'EMT', 'Eref', 'EXT', 'FFP', 'MAP', 'MAR', 'MAT',
'MCMT', 'MSP', 'MWMT', 'NFFD', 'PAS', 'RH', 'SHM', 'TD'
)
SEED_ZONES = (
{
'name': 'oregon_douglas_fir',
'data': os.path.join(ZONES_DIR, 'Oregon_Seed_Zones', 'Douglas_Fir.shp'),
'species': 'psme',
'zone_id_field': 'SZPSME',
'zones': {
1: {
'id': 1,
'bands': [
[0, 2000],
[2000, 2750],
[2750, 3250],
[3250, 3750]
]
},
2: {
'id': 2,
'bands': [
[0, 2000],
[2000, 2750],
[2750, 3250],
[3250, 3750],
[3750, 4250]
],
},
3: {
'id': 3,
'bands': [
[0, 2000],
[2000, 2750],
[2750, 3250],
[3250, 3750],
[3750, 4250],
[4250, 4750]
]
},
4: {
'id': 4,
'bands': [
[0, 1000],
[1000, 1500],
[1500, 2000]
],
},
5: {
'id': 5,
'bands': [
[0, 500],
[500, 1000],
[1000, 1500]
]
},
6: {
'id': 6,
'bands': [
[0, 1000],
[1000, 1500],
[1500, 2000]
]
},
7: {
'id': 7,
'bands': [
[0, 1000],
[1000, 1500],
[1500, 2000],
[2000, 2500]
]
},
8: {
'id': 8,
'bands': [
[0, 1000],
[1000, 1500],
[1500, 2000],
[2000, 2500]
]
},
9: {
'id': 9,
'bands': [
[0, 1000],
[1000, 1500],
[1500, 2000],
[2000, 2500],
[2500, 3000]
]
},
10: {
'id': 10,
'bands': [
[0, 1000],
[1000, 1500],
[1500, 2000],
[2000, 2500],
[2500, 3000],
[3000, 3500]
]
},
11: {
'id': 11,
'bands': [
[0, 1000],
[1000, 1500],
[1500, 2000],
[2000, 2500],
[2500, 3000]
]
},
12: {
'id': 12,
'bands': [
[1000, 1500],
[1500, 2000],
[2000, 2500],
[2500, 3000],
[3000, 3500]
]
},
13: {
'id': 13,
'bands': [
[2000, 2500],
[2500, 3000],
[3000, 3500]
]
},
14: {
'id': 14,
'bands': [
[0, 1000],
[1000, 1500],
[1500, 2000],
[2000, 2500],
[2500, 3000],
[3000, 3500]
]
},
15: {
'id': 15,
'bands': [
[1500, 2000],
[2000, 2500],
[2500, 3000],
[3000, 3500]
]
},
16: {
'id': 16,
'bands': [
[1000, 1500],
[1500, 2000],
[2000, 2500],
[2500, 3000],
[3000, 3500]
]
}
}
},
{
'name': 'washington_douglas_fir',
'data': os.path.join(ZONES_DIR, 'WA_NEW_ZONES', 'PSME.shp'),
'species': 'psme',
'zone_id_field': 'ZONE_NO',
'zones': {
1: {
'id': 1,
'bands': [
[0, 1000],
[1000, 2000],
[2000, 3000],
[3000, 4000]
]
},
2: {
'id': 2,
'bands': [
[1000, 2000],
[2000, 3000],
[3000, 4000],
[4000, 5000],
[5000, 6000],
[6000, 7000]
]
},
3: {
'id': 3,
'bands': [
[0, 1000],
[1000, 2000],
[2000, 3000]
]
},
4: {
'id': 4,
'bands': [
[0, 1000],
[1000, 2000],
[2000, 3000],
[3000, 4000]
]
},
5: {
'id': 5,
'bands': [
[0, 1000],
[1000, 2000],
[2000, 3000],
[3000, 4000],
[4000, 5000]
]
},
6: {
'id': 6,
'bands': [
[0, 1000],
[1000, 2000],
[2000, 3000],
[3000, 4000]
]
},
7: {
'id': 7,
'bands': [
[0, 1000],
[1000, 2000],
[2000, 3000],
[3000, 4000],
[4000, 5000],
[5000, 6000]
]
},
8: {
'id': 8,
'bands': [
[0, 1000],
[1000, 2000],
[2000, 3000],
[3000, 4000],
[4000, 5000],
[5000, 6000]
]
},
9: {
'id': 9,
'bands': [
[0, 1000],
[1000, 2000],
[2000, 3000],
[3000, 4000],
[4000, 5000],
[5000, 6000]
]
},
10: {
'id': 10,
'bands': [
[1000, 2000],
[2000, 3000],
[3000, 4000],
[4000, 5000],
[5000, 6000],
[6000, 7000],
[7000, 8000]
]
},
11: {
'id': 11,
'bands': [
[1000, 2000],
[2000, 3000],
[3000, 4000],
[4000, 5000],
[5000, 6000],
[6000, 7000]
]
},
12: {
'id': 12,
'bands': [
[0, 1000],
[1000, 2000],
[2000, 3000],
[3000, 4000],
[4000, 5000],
[5000, 6000]
]
},
13: {
'id': 13,
'bands': [
[0, 1400],
[1400, 2100],
[2100, 2800],
[2800, 3500],
[3500, 4200],
[4200, 4900],
[4900, 999999]
]
},
14: {
'id': 14,
'bands': [
[0, 1400],
[1400, 2100],
[2100, 2800],
[2800, 3500],
[3500, 4200],
[4200, 4900],
[4900, 999999]
]
},
15: {
'id': 15,
'bands': [
[0, 1400],
[1400, 2100],
[2100, 2800],
[2800, 3500],
[3500, 4200],
[4200, 4900],
[4900, 999999]
]
},
16: {
'id': 16,
'bands': [
[0, 1400],
[1400, 2100],
[2100, 2800],
[2800, 3500],
[3500, 4200],
[4200, 4900],
[4900, 999999]
]
}
}
},
{
'name': 'oregon_lodgepole_pine',
'data': os.path.join(ZONES_DIR, 'Oregon_Seed_Zones', 'Lodgepole_Pine.shp'),
'species': 'pico',
'zone_id_field': 'szpico',
'zones': {
1: {
'id': 1,
'bands': [
[-1, 1000],
[1000, 2000],
[2000, 3000],
[3000, 4000],
[4000, 5000],
[5000, 6000]
]
},
2: {
'id': 2,
'bands': [
[-1, 1000],
[1000, 2000],
[2000, 3000],
[3000, 4000],
[4000, 5000],
[5000, 6000]
]
},
3: {
'id': 3,
'bands': [
[-1, 1000],
[1000, 2000],
[2000, 3000],
[3000, 4000],
[4000, 5000],
[5000, 6000]
]
},
4: {
'id': 4,
'bands': [
[1000, 2000],
[2000, 3000],
[3000, 4000],
[4000, 5000],
[5000, 6000]
]
},
5: {
'id': 5,
'bands': [
[1000, 2000],
[2000, 3000],
[3000, 4000],
[4000, 5000],
[5000, 6000]
]
},
6: {
'id': 6,
'bands': [
[1000, 2000],
[2000, 3000],
[3000, 4000],
[4000, 5000],
[5000, 6000]
]
},
7: {
'id': 7,
'bands': [] # No bands provided by Brad
}
}
},
{
'name': 'washington_lodgepole_pine',
'data': os.path.join(ZONES_DIR, 'WA_NEW_ZONES', 'PICO.shp'),
'species': 'pico',
'zone_id_field': 'ZONE_NO',
'zones': {
1: {
'id': 1,
'bands': [
[0, 1000],
[1000, 2000],
[2000, 3000],
[3000, 4000]
]
},
2: {
'id': 2,
'bands': [
[0, 1000],
[1000, 2000],
[2000, 3000],
[3000, 4000]
]
},
3: {
'id': 3,
'bands': [
[0, 1000],
[1000, 2000],
[2000, 3000],
[3000, 4000]
]
},
4: {
'id': 4,
'bands': [
[0, 1000],
[1000, 2000],
[2000, 3000],
[3000, 4000]
]
},
5: {
'id': 5,
'bands': [
[0, 1000],
[1000, 2000],
[2000, 3000],
[3000, 4000]
]
},
6: {
'id': 6,
'bands': [
[0, 1000],
[1000, 2000],
[2000, 3000],
[3000, 4000]
]
},
7: {
'id': 7,
'bands': [
[0, 1000],
[1000, 2000],
[2000, 3000],
[3000, 4000]
]
},
8: {
'id': 8,
'bands': [
[0, 1000],
[1000, 2000],
[2000, 3000],
[3000, 4000],
[4000, 5000],
[5000, 999999]
]
},
9: {
'id': 9,
'bands': [
[0, 1000],
[1000, 2000],
[2000, 3000],
[3000, 4000],
[4000, 5000],
[5000, 999999]
]
},
10: {
'id': 10,
'bands': [
[0, 1000],
[1000, 2000],
[2000, 3000],
[3000, 4000],
[4000, 5000],
[5000, 999999]
]
},
11: {
'id': 11,
'bands': [
[0, 1000],
[1000, 2000],
[2000, 3000],
[3000, 4000],
[4000, 5000],
[5000, 999999]
]
},
12: {
'id': 12,
'bands': [
[0, 1000],
[1000, 2000],
[2000, 3000],
[3000, 4000],
[4000, 5000],
[5000, 999999]
]
},
13: {
'id': 13,
'bands': [
[0, 1000],
[1000, 2000],
[2000, 3000],
[3000, 4000],
[4000, 5000],
[5000, 999999]
]
},
14: {
'id': 14,
'bands': [
[1999, 2700],
[2700, 3400],
[3400, 4100],
[4100, 4800],
[4800, 5500],
[5500, 6100],
[6100, 999999]
]
},
15: {
'id': 15,
'bands': [
[1999, 2700],
[2700, 3400],
[3400, 4100],
[4100, 4800],
[4800, 5500],
[5500, 6100],
[6100, 999999]
]
},
16: {
'id': 16,
'bands': [
[1999, 2700],
[2700, 3400],
[3400, 4100],
[4100, 4800],
[4800, 5500],
[5500, 6100],
[6100, 999999]
]
},
17: {
'id': 17,
'bands': [
[1999, 2700],
[2700, 3400],
[3400, 4100],
[4100, 4800],
[4800, 5500],
[5500, 6100],
[6100, 999999]
]
}
}
},
{
'name': 'oregon_ponderosa_pine',
'data': os.path.join(ZONES_DIR, 'Oregon_Seed_Zones', 'Ponderosa_Pine.shp'), # File is missing zones
'species': 'pipo',
'zone_id_field': 'SZPIPO',
'zones': {
1: {
'id': 1,
'bands': [
[-1, 1000],
[1000, 2000],
[2000, 3000],
[3000, 4000],
[4000, 5000],
[5000, 6000]
]
},
2: {
'id': 2,
'bands': [
[-1, 1000],
[1000, 2000],
[2000, 3000],
[3000, 4000],
[4000, 5000],
[5000, 6000]
]
},
3: {
'id': 3,
'bands': [
[-1, 1000],
[1000, 2000],
[2000, 3000],
[3000, 4000],
[4000, 5000],
[5000, 6000]
]
},
4: {
'id': 4,
'bands': [
[-1, 1000],
[1000, 2000],
[2000, 3000],
[3000, 4000],
[4000, 5000],
[5000, 6000]
]
},
5: {
'id': 5,
'bands': [
[-1, 1000],
[1000, 2000],
[2000, 3000],
[3000, 4000],
[4000, 5000],
[5000, 6000]
]
},
6: {
'id': 6,
'bands': [
[-1, 1000],
[1000, 2000],
[2000, 3000],
[3000, 4000],
[4000, 5000],
[5000, 6000]
]
},
7: {
'id': 7,
'bands': [
[-1, 1000],
[1000, 2000],
[2000, 3000],
[3000, 4000],
[4000, 5000],
[5000, 6000]
]
},
8: {
'id': 8,
'bands': [
[-1, 1000],
[1000, 2000],
[2000, 3000],
[3000, 4000],
[4000, 5000],
[5000, 6000]
]
},
9: {
'id': 9,
'bands': [
[-1, 1000],
[1000, 2000],
[2000, 3000],
[3000, 4000],
[4000, 5000],
[5000, 6000]
]
},
10: {
'id': 10,
'bands': [
[-1, 1000],
[1000, 2000],
[2000, 3000],
[3000, 4000],
[4000, 5000],
[5000, 5700],
[5700, 6400]
]
},
11: {
'id': 11,
'bands': [
[-1, 2000]
]
},
12: {
'id': 12,
'bands': [
[-1, 1000],
[1000, 2000],
[2000, 3000],
[3000, 4000],
[4000, 5000],
[5000, 6000]
]
},
13: {
'id': 13,
'bands': [
[-1, 1000],
[1000, 2000],
[2000, 3000],
[3000, 4000],
[4000, 5000],
[5000, 6000]
]
},
14: {
'id': 14,
'bands': [
[-1, 1000],
[1000, 2000],
[2000, 3000],
[3000, 4000],
[4000, 5000],
[5000, 6000]
]
},
15: {
'id': 15,
'bands': [
[-1, 1000],
[1000, 2000],
[2000, 3000],
[3000, 4000],
[4000, 5000],
[5000, 6000]
]
}
}
},
{
'name': 'washington_ponderosa_pine',
'data': os.path.join(ZONES_DIR, 'WA_NEW_ZONES', 'PIPO.shp'),
'species': 'pipo',
'zone_id_field': 'ZONE_NO',
'zones': {
1: {
'id': 1,
'bands': [
[0, 999999]
]
},
2: {
'id': 2,
'bands': [
[0, 999999]
]
},
3: {
'id': 3,
'bands': [
[0, 999999]
]
},
4: {
'id': 4,
'bands': [
[-1, 1000],
[1000, 2000],
[2000, 3000],
[3000, 4000],
[4000, 5000]
]
},
5: {
'id': 5,
'bands': [
[-1, 1000],
[1000, 2000],
[2000, 3000],
[3000, 4000],
[4000, 5000]
]
},
6: {
'id': 6,
'bands': [
[-1, 1000],
[1000, 2000],
[2000, 3000],
[3000, 4000],
[4000, 5000]
]
},
7: {
'id': 7,
'bands': [
[-1, 1000],
[1000, 2000],
[2000, 3000],
[3000, 4000],
[4000, 5000]
]
},
8: {
'id': 8,
'bands': [
[-1, 1000],
[1000, 2000],
[2000, 3000],
[3000, 4000],
[4000, 5000]
]
},
9: {
'id': 9,
'bands': [
[-1, 1000],
[1000, 2000],
[2000, 3000],
[3000, 4000],
[4000, 5000]
]
},
10: {
'id': 10,
'bands': [
[-1, 1000],
[1000, 2000],
[2000, 3000],
[3000, 4000],
[4000, 5000]
]
},
11: {
'id': 11,
'bands': [
[-1, 1000],
[1000, 2000],
[2000, 3000],
[3000, 4000],
[4000, 5000]
]
}
}
},
{
'name': 'oregon_western_redcedar',
'data': os.path.join(ZONES_DIR, 'Oregon_Seed_Zones', 'Western_Red_Cedar.shp'),
'species': 'thpl',
'zone_id_field': 'SZTHPL',
'zones': {
1: {
'id': 1,
'bands': [
[-1, 999999]
]
},
2: {
'id': 2,
'bands': [
[-1, 999999]
]
},
3: {
'id': 3,
'bands': [
[1999, 3500],
[3500, 999999]
]
},
4: {
'id': 4,
'bands': [
[1999, 3500],
[3500, 999999]
]
}
}
},
{
'name': 'washington_western_redcedar',
'data': os.path.join(ZONES_DIR, 'WA_NEW_ZONES', 'THPL.shp'),
'species': 'thpl',
'zone_id_field': 'ZONE_NO',
'zones': {
1: {
'id': 1,
'bands': [
[-1, 2000],
[2000, 4000],
[4000, 6000],
[6000, 999999]
]
},
2: {
'id': 2,
'bands': [
[-1, 2000],
[2000, 4000],
[4000, 6000],
[6000, 999999]
]
},
3: {
'id': 3,
'bands': [
[-1, 2000],
[2000, 4000],
[4000, 6000],
[6000, 999999]
]
},
4: {
'id': 4,
'bands': [
[-1, 2000],
[2000, 4000],
[4000, 6000],
[6000, 999999]
]
},
5: {
'id': 5,
'bands': [
[-1, 1500],
[1500, 3000],
[3000, 4500],
[4500, 6000],
[6000, 999999]
]
},
6: {
'id': 6,
'bands': [
[-1, 1500],
[1500, 3000],
[3000, 4500],
[4500, 6000],
[6000, 999999]
]
},
7: {
'id': 7,
'bands': [
[-1, 1500],
[1500, 3000],
[3000, 4500],
[4500, 6000],
[6000, 999999]
]
}
}
},
{
'name': 'oregon_western_white_pine',
'data': os.path.join(ZONES_DIR, 'Oregon_Seed_Zones', 'Western_White_Pine.shp'), # File is missing zone 1
'species': 'pimo',
'zone_id_field': 'SZPIMO',
'zones': {
1: {
'id': 1,
'bands': [
[-1, 999999]
]
},
2: {
'id': 2,
'bands': [
[-1, 999999]
]
},
3: {
'id': 3,
'bands': [
[-1, 999999]
]
},
4: {
'id': 4,
'bands': [
[-1, 999999]
]
},
5: {
'id': 5,
'bands': [
[-1, 999999]
]
},
6: {
'id': 6,
'bands': [
[-1, 999999]
]
}
}
},
{
'name': 'washington_western_white_pine',
'data': os.path.join(ZONES_DIR, 'WA_NEW_ZONES', 'PIMO.shp'),
'species': 'pimo',
'zone_id_field': 'ZONE_NO',
'zones': {
1: {
'id': 1,
'bands': [
[-1, 999999]
]
},
2: {
'id': 2,
'bands': [
[-1, 999999]
]
},
3: {
'id': 3,
'bands': [
[-1, 999999]
]
},
4: {
'id': 4,
'bands': [
[-1, 999999]
]
},
5: {
'id': 5,
'bands': [
[-1, 999999]
]
},
6: {
'id': 6,
'bands': [
[-1, 999999]
]
},
7: {
'id': 7,
'bands': [
[-1, 999999]
]
}
}
},
{
'name': 'oregon_washington_historic',
'data': os.path.join(ZONES_DIR, 'historic_seed_zones', 'historic_seed_zones.shp'),
'species': '',
'zone_id_field': 'OBJECTID',
'zones': {i: {'id': i, 'bands': None} for i in range(1, 133)} # No elevation bands for historic zones
}
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment