In [2]:
import geopandas as gpd

In [3]:
import pandas as pd
import matplotlib
import matplotlib.pyplot as plt
import seaborn as sb
import glob

In [4]:
satskred_list = glob.glob("./data/satskred/AvalDet*.shp")
wyssen_list = glob.glob("./data/wyssen/SHP/join/wyssen*_join.shp")

In [5]:
# Satskred
satskred_1617_aut_file = gpd.read_file("./data/satskred/AvalDet_1617_aut.shp")
satskred_1718_aut_file = gpd.read_file("./data/satskred/AvalDet_1718_aut.shp")
satskred_1819_aut_file = gpd.read_file("./data/satskred/AvalDet_1819_aut.shp")

satskred_1617_man_file = gpd.read_file("./data/satskred/AvalDet_1617_man.shp")
satskred_1718_man_file = gpd.read_file("./data/satskred/AvalDet_1718_man.shp")
satskred_1819_man_file = gpd.read_file("./data/satskred/AvalDet_1819_man.shp")

# Wyssen
wyssen_1617_file = gpd.read_file("./data/wyssen/SHP/join/wyssen1617_join.shp")
wyssen_1718_file = gpd.read_file("./data/wyssen/SHP/join/wyssen1718_join.shp")
wyssen_1819_file = gpd.read_file("./data/wyssen/SHP/join/wyssen1819_join.shp")

In [6]:
# Satskred
satskred_1617_aut = gpd.GeoDataFrame(satskred_1617_aut_file)
satskred_1718_aut = gpd.GeoDataFrame(satskred_1718_aut_file)
satskred_1819_aut = gpd.GeoDataFrame(satskred_1819_aut_file)

satskred_1617_man = gpd.GeoDataFrame(satskred_1617_man_file)
satskred_1718_man = gpd.GeoDataFrame(satskred_1718_man_file)
satskred_1819_man = gpd.GeoDataFrame(satskred_1819_man_file)

# Wyssen
wyssen_1617 = gpd.GeoDataFrame(wyssen_1617_file)
wyssen_1718 = gpd.GeoDataFrame(wyssen_1718_file)
wyssen_1819 = gpd.GeoDataFrame(wyssen_1819_file)

In [7]:
satskred_aut_frames = [satskred_1617_aut,satskred_1718_aut,satskred_1819_aut]
satskred_aut_df = pd.concat(satskred_aut_frames, ignore_index=True)

In [8]:
satskred_man_frames = [satskred_1617_man,satskred_1718_man,satskred_1819_man]
satskred_man_df = pd.concat(satskred_man_frames)
satskred_man_df["Det_Date"] = satskred_man_df["Date"]
satskred_man_df["Ref_Date"] = satskred_man_df["Date"]

In [9]:
satskred_frames = [satskred_man_df, satskred_aut_df]
# satskred_df = pd.concat(satskred_frames)
satskred_df = satskred_aut_df

In [10]:
wyssen_frames = [wyssen_1617,wyssen_1718,wyssen_1819]
wyssen_df = pd.concat(wyssen_frames, join='outer', ignore_index=True)
wyssen_df["d"] = pd.to_datetime(wyssen_df["avalancher"])

In [11]:
import datetime
import numpy as np

# Add date cols
satskred_df["Ref_Date"] = pd.to_datetime(satskred_df["t_0"])
satskred_df["Det_Date"] = pd.to_datetime(satskred_df["t_1"])

In [12]:
wyssen_df.head()


Out[12]:
Name SymbolID event_mapp date local_obse avalancher avalanch_1 path_nr path elevation_ ... terminus_e weak_layer avalanche1 pic_name_s observer_n regobs Shape_Leng Shape_Area geometry d
0 TYIN_torv5_obs_20161202 0 TYIN_obs_20161202_6 2016-12-02 11:00:00 2016-12-02 11:00:00 5 torv5 1190 ... None Poor within slab Yes No SL http://www.regobs.no/Registration/104712 0.002866 3.829140e-07 POLYGON Z ((8.229695371943933 61.2182898893669... 2016-12-02
1 TYIN_mel2_obs_20161202 0 TYIN_obs_20161202_2 2016-12-02 10:40:00 2016-12-02 10:40:00 13 mel2 1310 ... None Loose snow Yes No LS http://www.regobs.no/Registration/104713 0.003863 6.049170e-07 POLYGON Z ((8.19351385997669 61.2598734283161 ... 2016-12-02
2 TYIN_stol1_obs_20161202 0 TYIN_obs_20161202_3 2016-12-02 11:10:00 2016-12-02 11:10:00 10 stol1 1235 ... None Loose snow Yes No LS http://www.regobs.no/Registration/104714 0.003259 3.929210e-07 POLYGON Z ((8.199626012330668 61.2485258438926... 2016-12-02
3 TYIN_varden_obs_20161202 0 TYIN_obs_20161202_1 2016-12-02 10:30:00 2016-12-02 10:30:00 14 varden 1120 ... on the road Poor within slab Yes Yes LS http://www.regobs.no/Registration/104710 0.003501 8.464390e-07 POLYGON Z ((8.202467801647799 61.2705593788123... 2016-12-02
4 TYIN_torv4_obs_20161202 0 TYIN_obs_20161202_5 2016-12-02 11:10:00 2016-12-02 11:10:00 4 torv4 1210 ... None Poor within slab Yes No LS http://www.regobs.no/Registration/104711 0.006411 9.011830e-07 POLYGON Z ((8.228929506591498 61.2167069053994... 2016-12-02

5 rows × 30 columns


In [13]:
satskred_df.head()


Out[13]:
area aspect det_count east length north raster_val refdate sat_geom source ... vv0_median vv0_min vv0_max vh0_mean vh0_median vh0_min vh0_max geometry Ref_Date Det_Date
0 3690.926876 None 1 8.195374 434.031728 61.260144 16.0 2016-12-07 00:00:00 117 AvalDet_20161231_170935_ref_20161207_trno_117_... ... -23.054697 -25.984091 -20.079021 -30.594744 -30.458412 -34.966465 -27.081316 POLYGON ((8.195177439133777 61.25987516789603,... 2016-12-07 2016-12-31 17:09:35
1 21247.808245 None 1 8.198065 973.074430 61.259490 15.0 2016-12-07 00:00:00 117 AvalDet_20161231_170935_ref_20161207_trno_117_... ... -21.699184 -26.825785 -15.982099 -28.841135 -28.720428 -33.217281 -24.667627 POLYGON ((8.197893531082906 61.2585701014953, ... 2016-12-07 2016-12-31 17:09:35
2 5386.821031 None 1 8.213720 630.037545 61.235180 12.0 2016-12-26 00:00:00 44 AvalDet_20170101_170215_ref_20161226_trno_044_... ... -19.695488 -23.344965 -14.922070 -24.228239 -24.471161 -28.440144 -20.455158 POLYGON ((8.21295713335868 61.23481617912952, ... 2016-12-26 2017-01-01 17:02:15
3 22843.884004 None 1 8.197918 1055.520485 61.259463 13.0 2016-12-26 00:00:00 44 AvalDet_20170101_170215_ref_20161226_trno_044_... ... -17.618906 -25.499401 -12.106519 -23.645086 -23.603981 -28.753635 -19.563250 POLYGON ((8.197893531082906 61.2585701014953, ... 2016-12-26 2017-01-01 17:02:15
4 1795.606407 None 1 8.213564 258.482064 61.235182 19.0 2016-12-31 00:00:00 117 AvalDet_20170112_170933_ref_20161231_trno_117_... ... -22.751648 -25.992640 -19.640621 -29.944088 -30.305767 -33.399609 -26.289957 POLYGON ((8.213307762113439 61.23492392616465,... 2016-12-31 2017-01-12 17:09:33

5 rows × 43 columns


In [14]:
satskred_df.columns


Out[14]:
Index(['area', 'aspect', 'det_count', 'east', 'length', 'north', 'raster_val',
       'refdate', 'sat_geom', 'source', 't_0', 't_1', 'time', 'track_id',
       'uuid', 'width', 'dem_mean', 'dem_median', 'dem_min', 'dem_max',
       'slp_mean', 'slp_median', 'slp_min', 'slp_max', 'vv1_mean',
       'vv1_median', 'vv1_min', 'vv1_max', 'vh1_mean', 'vh1_median', 'vh1_min',
       'vh1_max', 'vv0_mean', 'vv0_median', 'vv0_min', 'vv0_max', 'vh0_mean',
       'vh0_median', 'vh0_min', 'vh0_max', 'geometry', 'Ref_Date', 'Det_Date'],
      dtype='object')

In [15]:
wyssen_df.columns


Out[15]:
Index(['Name', 'SymbolID', 'event_mapp', 'date', 'local_obse', 'avalancher',
       'avalanch_1', 'path_nr', 'path', 'elevation_', 'elevation1',
       'avalanche_', 'moisture_d', 'trigger', 'size', 'fracture_w',
       'fracture_d', 'deposition', 'depositi_1', 'uncertaint', 'terminus_e',
       'weak_layer', 'avalanche1', 'pic_name_s', 'observer_n', 'regobs',
       'Shape_Leng', 'Shape_Area', 'geometry', 'd'],
      dtype='object')

In [16]:
wyssen_df.d[:].head()


Out[16]:
0   2016-12-02
1   2016-12-02
2   2016-12-02
3   2016-12-02
4   2016-12-02
Name: d, dtype: datetime64[ns]

In [17]:
wyssen_gdf = gpd.GeoDataFrame(wyssen_df)

In [18]:
satskred_gdf = gpd.GeoDataFrame(satskred_df)

In [19]:
wyssen_gdf['satskred_match'] = "No match"
wyssen_gdf['satskred_indicies'] = list

In [20]:
wyssen_to_satskred = {}

for w_row in wyssen_gdf.itertuples():
    satskred_rows = satskred_gdf[(satskred_gdf["Ref_Date"] <= w_row.d) & (w_row.d <= satskred_gdf["Det_Date"])]
    if len(satskred_rows) == 0:
        wyssen_to_satskred[w_row.Index] = "No match"
    else:
        wyssen_to_satskred[w_row.Index] = satskred_rows.index
        #loop over overlap

In [21]:
wyssen_to_satskred


Out[21]:
{0: 'No match',
 1: 'No match',
 2: 'No match',
 3: 'No match',
 4: 'No match',
 5: 'No match',
 6: Int64Index([4], dtype='int64'),
 7: Int64Index([4], dtype='int64'),
 8: Int64Index([4], dtype='int64'),
 9: Int64Index([4], dtype='int64'),
 10: Int64Index([4], dtype='int64'),
 11: Int64Index([4], dtype='int64'),
 12: Int64Index([4], dtype='int64'),
 13: Int64Index([4], dtype='int64'),
 14: Int64Index([4], dtype='int64'),
 15: Int64Index([4], dtype='int64'),
 16: Int64Index([4], dtype='int64'),
 17: Int64Index([4], dtype='int64'),
 18: 'No match',
 19: 'No match',
 20: 'No match',
 21: 'No match',
 22: 'No match',
 23: 'No match',
 24: 'No match',
 25: 'No match',
 26: 'No match',
 27: 'No match',
 28: 'No match',
 29: 'No match',
 30: 'No match',
 31: 'No match',
 32: 'No match',
 33: 'No match',
 34: 'No match',
 35: 'No match',
 36: 'No match',
 37: 'No match',
 38: 'No match',
 39: 'No match',
 40: 'No match',
 41: 'No match',
 42: 'No match',
 43: 'No match',
 44: 'No match',
 45: Int64Index([6, 7, 8, 9, 10, 11, 12], dtype='int64'),
 46: Int64Index([6, 7, 8, 9, 10, 11, 12], dtype='int64'),
 47: Int64Index([6, 7, 8, 9, 10, 11, 12], dtype='int64'),
 48: Int64Index([6, 7, 8, 9, 10, 11, 12], dtype='int64'),
 49: Int64Index([6, 7, 8, 9, 10, 11, 12], dtype='int64'),
 50: Int64Index([6, 7, 8, 9, 10, 11, 12], dtype='int64'),
 51: Int64Index([6, 7, 8, 9, 10, 11, 12], dtype='int64'),
 52: Int64Index([6, 7, 8, 9, 10, 11, 12], dtype='int64'),
 53: Int64Index([6, 7, 8, 9, 10, 11, 12], dtype='int64'),
 54: Int64Index([6, 7, 8, 9, 10, 11, 12], dtype='int64'),
 55: Int64Index([6, 7, 8, 9, 10, 11, 12], dtype='int64'),
 56: Int64Index([6, 7, 8, 9, 10, 11, 12], dtype='int64'),
 57: Int64Index([6, 7, 8, 9, 10, 11, 12], dtype='int64'),
 58: Int64Index([6, 7, 8, 9, 10, 11, 12], dtype='int64'),
 59: Int64Index([6, 7, 8, 9, 10, 11, 12], dtype='int64'),
 60: Int64Index([6, 7, 8, 9, 10, 11, 12], dtype='int64'),
 61: Int64Index([6, 7, 8, 9, 10, 11, 12], dtype='int64'),
 62: Int64Index([6, 7, 8, 9, 10, 11, 12], dtype='int64'),
 63: Int64Index([6, 7, 8, 9, 10, 11, 12], dtype='int64'),
 64: Int64Index([6, 7, 8, 9, 10, 11, 12], dtype='int64'),
 65: Int64Index([6, 7, 8, 9, 10, 11, 12], dtype='int64'),
 66: Int64Index([6, 7, 8, 9, 10, 11, 12], dtype='int64'),
 67: Int64Index([6, 7, 8, 9, 10, 11, 12], dtype='int64'),
 68: Int64Index([6, 7, 8, 9, 10, 11, 12], dtype='int64'),
 69: Int64Index([6, 7, 8, 9, 10, 11, 12], dtype='int64'),
 70: Int64Index([6, 7, 8, 9, 10, 11, 12], dtype='int64'),
 71: Int64Index([6, 7, 8, 9, 10, 11, 12], dtype='int64'),
 72: Int64Index([6, 7, 8, 9, 10, 11, 12], dtype='int64'),
 73: Int64Index([10, 11, 12], dtype='int64'),
 74: Int64Index([10, 11, 12], dtype='int64'),
 75: Int64Index([10, 11, 12], dtype='int64'),
 76: Int64Index([10, 11, 12], dtype='int64'),
 77: Int64Index([10, 11, 12], dtype='int64'),
 78: Int64Index([10, 11, 12], dtype='int64'),
 79: Int64Index([10, 11, 12], dtype='int64'),
 80: Int64Index([10, 11, 12], dtype='int64'),
 81: Int64Index([10, 11, 12], dtype='int64'),
 82: Int64Index([10, 11, 12], dtype='int64'),
 83: Int64Index([10, 11, 12], dtype='int64'),
 84: Int64Index([10, 11, 12], dtype='int64'),
 85: Int64Index([10, 11, 12], dtype='int64'),
 86: Int64Index([10, 11, 12], dtype='int64'),
 87: Int64Index([10, 11, 12], dtype='int64'),
 88: 'No match',
 89: 'No match',
 90: 'No match',
 91: 'No match',
 92: 'No match',
 93: 'No match',
 94: 'No match',
 95: Int64Index([15], dtype='int64'),
 96: Int64Index([15], dtype='int64'),
 97: Int64Index([15], dtype='int64'),
 98: Int64Index([15], dtype='int64'),
 99: Int64Index([15], dtype='int64'),
 100: Int64Index([15], dtype='int64'),
 101: Int64Index([15], dtype='int64'),
 102: Int64Index([15], dtype='int64'),
 103: Int64Index([15], dtype='int64'),
 104: Int64Index([15], dtype='int64'),
 105: Int64Index([15], dtype='int64'),
 106: Int64Index([15], dtype='int64'),
 107: Int64Index([15], dtype='int64'),
 108: 'No match',
 109: 'No match',
 110: 'No match',
 111: Int64Index([40, 41, 42], dtype='int64'),
 112: Int64Index([40, 41, 42], dtype='int64'),
 113: Int64Index([40, 41, 42], dtype='int64'),
 114: Int64Index([39, 40, 41, 42], dtype='int64'),
 115: 'No match',
 116: 'No match',
 117: 'No match',
 118: 'No match',
 119: 'No match',
 120: 'No match',
 121: 'No match',
 122: 'No match',
 123: 'No match',
 124: 'No match',
 125: 'No match',
 126: 'No match',
 127: 'No match',
 128: 'No match',
 129: 'No match',
 130: 'No match',
 131: 'No match',
 132: 'No match',
 133: 'No match',
 134: 'No match',
 135: 'No match',
 136: 'No match',
 137: 'No match',
 138: 'No match',
 139: 'No match',
 140: 'No match',
 141: 'No match',
 142: 'No match',
 143: 'No match',
 144: 'No match',
 145: 'No match',
 146: 'No match',
 147: 'No match',
 148: 'No match',
 149: 'No match',
 150: 'No match',
 151: 'No match',
 152: 'No match',
 153: 'No match',
 154: 'No match',
 155: 'No match',
 156: 'No match',
 157: 'No match',
 158: 'No match',
 159: 'No match',
 160: 'No match',
 161: 'No match',
 162: 'No match',
 163: 'No match',
 164: 'No match',
 165: 'No match',
 166: 'No match',
 167: 'No match',
 168: 'No match',
 169: 'No match',
 170: 'No match',
 171: 'No match',
 172: 'No match',
 173: 'No match',
 174: 'No match',
 175: 'No match',
 176: 'No match',
 177: 'No match',
 178: 'No match',
 179: 'No match',
 180: 'No match',
 181: 'No match',
 182: 'No match',
 183: 'No match',
 184: 'No match',
 185: 'No match',
 186: 'No match',
 187: 'No match',
 188: 'No match',
 189: 'No match',
 190: 'No match',
 191: 'No match',
 192: 'No match',
 193: 'No match',
 194: 'No match',
 195: 'No match',
 196: 'No match',
 197: 'No match',
 198: 'No match',
 199: 'No match',
 200: 'No match',
 201: 'No match',
 202: 'No match',
 203: 'No match',
 204: 'No match',
 205: 'No match',
 206: 'No match',
 207: Int64Index([24, 25], dtype='int64'),
 208: Int64Index([27, 28], dtype='int64'),
 209: Int64Index([27, 28], dtype='int64'),
 210: Int64Index([30], dtype='int64'),
 211: Int64Index([30], dtype='int64'),
 212: Int64Index([30], dtype='int64'),
 213: Int64Index([30], dtype='int64'),
 214: 'No match',
 215: 'No match',
 216: 'No match',
 217: 'No match',
 218: 'No match',
 219: 'No match',
 220: 'No match',
 221: 'No match',
 222: 'No match',
 223: 'No match',
 224: 'No match',
 225: 'No match',
 226: 'No match',
 227: 'No match',
 228: 'No match',
 229: 'No match',
 230: 'No match',
 231: 'No match',
 232: 'No match',
 233: 'No match',
 234: 'No match',
 235: 'No match',
 236: 'No match',
 237: Int64Index([31], dtype='int64'),
 238: Int64Index([32, 33, 34, 35, 36], dtype='int64'),
 239: Int64Index([32, 33, 34, 35, 36], dtype='int64'),
 240: Int64Index([32, 33, 34, 35, 36], dtype='int64'),
 241: Int64Index([32, 33, 34, 35, 36], dtype='int64'),
 242: Int64Index([32, 33, 34, 35, 36], dtype='int64'),
 243: Int64Index([32, 33, 34, 35, 36], dtype='int64'),
 244: Int64Index([32, 33, 34, 35, 36], dtype='int64'),
 245: Int64Index([32, 33, 34, 35, 36], dtype='int64'),
 246: Int64Index([32, 33, 34, 35, 36], dtype='int64'),
 247: Int64Index([32, 33, 34, 35, 36], dtype='int64'),
 248: Int64Index([32, 33, 34, 35, 36], dtype='int64'),
 249: Int64Index([32, 33, 34, 35, 36], dtype='int64'),
 250: Int64Index([32, 33, 34, 35, 36], dtype='int64'),
 251: Int64Index([32, 33, 34, 35, 36], dtype='int64'),
 252: Int64Index([32, 33, 34, 35, 36], dtype='int64'),
 253: Int64Index([32, 33, 34, 35, 36], dtype='int64'),
 254: Int64Index([37, 38], dtype='int64'),
 255: Int64Index([37, 38, 39], dtype='int64'),
 256: Int64Index([39, 40, 41], dtype='int64'),
 257: Int64Index([39, 40, 41], dtype='int64'),
 258: Int64Index([39, 40, 41], dtype='int64'),
 259: Int64Index([39, 40, 41], dtype='int64'),
 260: 'No match',
 261: 'No match',
 262: Int64Index([57, 58, 59, 60, 61], dtype='int64'),
 263: Int64Index([57, 58, 59, 60, 61], dtype='int64'),
 264: Int64Index([57, 58, 59, 60, 61], dtype='int64'),
 265: Int64Index([57, 58, 59, 60, 61], dtype='int64'),
 266: Int64Index([53, 54, 55, 56, 57, 58, 59], dtype='int64'),
 267: Int64Index([53, 54, 55, 56, 57, 58, 59], dtype='int64'),
 268: Int64Index([53, 54, 55, 56], dtype='int64'),
 269: Int64Index([53, 54, 55, 56], dtype='int64'),
 270: Int64Index([53, 54, 55, 56], dtype='int64'),
 271: Int64Index([53, 54, 55, 56], dtype='int64'),
 272: Int64Index([53, 54, 55, 56], dtype='int64'),
 273: Int64Index([53, 54, 55, 56], dtype='int64'),
 274: Int64Index([53, 54, 55, 56], dtype='int64'),
 275: Int64Index([53, 54, 55, 56], dtype='int64'),
 276: Int64Index([53, 54, 55, 56], dtype='int64'),
 277: Int64Index([53, 54, 55, 56], dtype='int64'),
 278: Int64Index([53, 54, 55, 56], dtype='int64'),
 279: Int64Index([53, 54, 55, 56], dtype='int64'),
 280: Int64Index([53, 54, 55, 56], dtype='int64'),
 281: Int64Index([53, 54, 55, 56], dtype='int64'),
 282: Int64Index([53, 54, 55, 56], dtype='int64'),
 283: 'No match',
 284: 'No match',
 285: 'No match',
 286: 'No match',
 287: 'No match',
 288: 'No match',
 289: 'No match',
 290: 'No match',
 291: 'No match',
 292: 'No match',
 293: 'No match',
 294: 'No match',
 295: 'No match',
 296: 'No match',
 297: 'No match',
 298: 'No match',
 299: 'No match',
 300: 'No match',
 301: 'No match',
 302: 'No match',
 303: 'No match',
 304: 'No match',
 305: 'No match',
 306: 'No match',
 307: Int64Index([49, 50, 51], dtype='int64'),
 308: Int64Index([49, 50, 51], dtype='int64'),
 309: Int64Index([49, 50, 51], dtype='int64'),
 310: Int64Index([49, 50, 51], dtype='int64'),
 311: Int64Index([49, 50, 51], dtype='int64'),
 312: Int64Index([49, 50, 51], dtype='int64'),
 313: Int64Index([49, 50, 51], dtype='int64'),
 314: Int64Index([49, 50, 51], dtype='int64'),
 315: Int64Index([49, 50, 51], dtype='int64'),
 316: Int64Index([49, 50, 51], dtype='int64'),
 317: Int64Index([49, 50, 51], dtype='int64'),
 318: Int64Index([49, 50, 51], dtype='int64'),
 319: Int64Index([49, 50, 51], dtype='int64'),
 320: Int64Index([49, 50, 51], dtype='int64'),
 321: Int64Index([49, 50, 51], dtype='int64'),
 322: Int64Index([49, 50, 51], dtype='int64'),
 323: Int64Index([49, 50, 51], dtype='int64'),
 324: Int64Index([49, 50, 51], dtype='int64'),
 325: Int64Index([49, 50, 51], dtype='int64'),
 326: Int64Index([49, 50, 51], dtype='int64'),
 327: Int64Index([49, 50, 51], dtype='int64'),
 328: Int64Index([49, 50, 51], dtype='int64'),
 329: Int64Index([49, 50, 51], dtype='int64'),
 330: Int64Index([49, 50, 51], dtype='int64'),
 331: Int64Index([49, 50, 51], dtype='int64'),
 332: 'No match',
 333: 'No match',
 334: 'No match',
 335: 'No match',
 336: 'No match',
 337: 'No match',
 338: 'No match',
 339: 'No match',
 340: 'No match',
 341: 'No match',
 342: 'No match',
 343: 'No match',
 344: 'No match',
 345: 'No match',
 346: 'No match',
 347: 'No match',
 348: 'No match',
 349: 'No match',
 350: 'No match',
 351: 'No match',
 352: 'No match',
 353: 'No match',
 354: 'No match',
 355: 'No match',
 356: 'No match',
 357: 'No match',
 358: 'No match',
 359: 'No match',
 360: 'No match',
 361: 'No match',
 362: 'No match',
 363: 'No match',
 364: 'No match',
 365: 'No match',
 366: 'No match',
 367: 'No match',
 368: 'No match'}

In [22]:
#for row in wyssen_gdf.itertuples():
    #overlap = gpd.overlay(wyssen_gdf,satskred_gdf,how='intersection')

In [23]:
print(satskred_gdf['geometry'])


0     POLYGON ((8.195177439133777 61.25987516789603,...
1     POLYGON ((8.197893531082906 61.2585701014953, ...
2     POLYGON ((8.21295713335868 61.23481617912952, ...
3     POLYGON ((8.197893531082906 61.2585701014953, ...
4     POLYGON ((8.213307762113439 61.23492392616465,...
5     POLYGON ((8.198059269205311 61.25866856794975,...
6     POLYGON ((8.19804943237884 61.26560719895456, ...
7     POLYGON ((8.208391998211694 61.24035406196727,...
8     POLYGON ((8.200112182562304 61.25696958649805,...
9     POLYGON ((8.199859625605329 61.26416633560624,...
10    POLYGON ((8.215284490411497 61.23529365175204,...
11    POLYGON ((8.21459791714717 61.2376021737839, 8...
12    POLYGON ((8.201535424300673 61.25127368475768,...
13    POLYGON ((8.198429462512303 61.25868721317511,...
14    POLYGON ((8.1968007398692 61.26446288511351, 8...
15    POLYGON ((8.197534200990948 61.25936306898571,...
16    POLYGON ((8.196570622905508 61.2672449733822, ...
17    POLYGON ((8.194058233176122 61.26847018736235,...
18    POLYGON ((8.197063331352002 61.26411563715929,...
19    POLYGON ((8.190424031901172 61.26882773916955,...
20    POLYGON ((8.230627533383739 61.22831408826197,...
21    POLYGON ((8.200453725884289 61.26401600941668,...
22    POLYGON ((8.19905133136438 61.2713351134561, 8...
23    POLYGON ((8.231443016968344 61.22366901141989,...
24    POLYGON ((8.232988769293664 61.22690055077489,...
25    POLYGON ((8.199946446466249 61.25687112258988,...
26    POLYGON ((8.234995729922664 61.21672810759416,...
27    POLYGON ((8.233902887227273 61.21919652022323,...
28    POLYGON ((8.235385437221064 61.22792184858764,...
29    POLYGON ((8.234785332718861 61.21076999807664,...
                            ...                        
38    POLYGON ((8.234438299718251 61.21931348138805,...
39    POLYGON ((8.194038856039638 61.26855932998357,...
40    POLYGON ((8.233309799101612 61.21934700864639,...
41    POLYGON ((8.233397081210763 61.22674079422791,...
42    POLYGON ((8.212421545781504 61.23469913017685,...
43    POLYGON ((8.200105409878775 61.24579458130233,...
44    POLYGON ((8.200638854854878 61.26402532935825,...
45    POLYGON ((8.23267083969883 61.22057657165877, ...
46    POLYGON ((8.218109691776725 61.23174086069169,...
47    POLYGON ((8.234052465809897 61.22803525878208,...
48    POLYGON ((8.217966874910186 61.23326566228077,...
49    POLYGON ((8.208022012743001 61.24033544714111,...
50    POLYGON ((8.202715059590332 61.24583587731342,...
51    POLYGON ((8.202473919547279 61.2598821484873, ...
52    POLYGON ((8.233352702051125 61.22088111052085,...
53    POLYGON ((8.215411585905214 61.23557039002012,...
54    POLYGON ((8.214972432953676 61.23500761580304,...
55    POLYGON ((8.208002697655994 61.24042459272529,...
56    POLYGON ((8.200192948460248 61.252287503452, 8...
57    POLYGON ((8.215998150977294 61.2319952095467, ...
58    POLYGON ((8.199943941204914 61.25515874872988,...
59    POLYGON ((8.198194771330478 61.2580445633603, ...
60    POLYGON ((8.214197342676737 61.23686110322423,...
61    POLYGON ((8.199963290883359 61.25506960483522,...
62    POLYGON ((8.196736400861489 61.26734344204321,...
63    POLYGON ((8.194818219740846 61.26841835932068,...
64    POLYGON ((8.234975436694528 61.22375602619788,...
65    POLYGON ((8.218363910264314 61.2322943322289, ...
66    POLYGON ((8.217704792025762 61.23361295858912,...
67    POLYGON ((8.198866159984654 61.27132579070681,...
Name: geometry, Length: 68, dtype: object

In [24]:
from shapely.geometry import Polygon

In [42]:
satskred_gdf.intersects(wyssen_df)


Out[42]:
0      False
1      False
2      False
3      False
4      False
5      False
6      False
7      False
8      False
9      False
10     False
11     False
12     False
13     False
14     False
15     False
16     False
17     False
18     False
19     False
20     False
21     False
22     False
23     False
24     False
25     False
26     False
27     False
28     False
29     False
       ...  
339    False
340    False
341    False
342    False
343    False
344    False
345    False
346    False
347    False
348    False
349    False
350    False
351    False
352    False
353    False
354    False
355    False
356    False
357    False
358    False
359    False
360    False
361    False
362    False
363    False
364    False
365    False
366    False
367    False
368    False
Length: 369, dtype: bool

In [26]:
wyssen_gdf.plot()


Out[26]:
<matplotlib.axes._subplots.AxesSubplot at 0x229a08a0ef0>

In [48]:
dt_start = datetime.datetime.strptime("2018-01-01", "%Y-%M-%d")
dt_stop = datetime.datetime.strptime("2018-01-31", "%Y-%M-%d")
print(dt_start, dt_stop)

sat1 = satskred_df[satskred_df[(satskred_df["Ref_Date"] <= dt_start) & (dt_stop <= satskred_df["Det_Date"])]]
sat1.head()


2018-01-01 00:01:00 2018-01-31 00:01:00
Out[48]:
area aspect det_count east length north raster_val refdate sat_geom source ... vv0_median vv0_min vv0_max vh0_mean vh0_median vh0_min vh0_max geometry Ref_Date Det_Date
0 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN ... NaN NaN NaN NaN NaN NaN NaN NaN NaT NaT
1 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN ... NaN NaN NaN NaN NaN NaN NaN NaN NaT NaT
2 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN ... NaN NaN NaN NaN NaN NaN NaN NaN NaT NaT
3 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN ... NaN NaN NaN NaN NaN NaN NaN NaN NaT NaT
4 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN ... NaN NaN NaN NaN NaN NaN NaN NaN NaT NaT

5 rows × 43 columns


In [ ]:
res_intersect = gpd.overlay(sat1, wyssen_gdf, how='intersection')
# res_intersect = gpd.overlay(satskred_gdf, wyssen_gdf, how='intersection')
print(len(res_intersect))

In [45]:
ax = res_intersect.plot(cmap='tab10')
# satskred_gdf.plot(ax=ax, facecolor='none', edgecolor='g')
# wyssen_gdf.plot(ax=ax, facecolor='none', edgecolor='b')
plt.gcf().savefig('sat_wys_intersect.png', dpi=150)



In [41]:



495

In [28]:
from shapely.geometry import Polygon
polys1 = gpd.GeoSeries([Polygon([(0,0), (2,0), (2,2), (0,2)]),
                              Polygon([(2,2), (4,2), (4,4), (2,4)])])


polys2 = gpd.GeoSeries([Polygon([(1,1), (3,1), (3,3), (1,3)]),
                              Polygon([(3,3), (5,3), (5,5), (3,5)])])


df1 = gpd.GeoDataFrame({'geometry': polys1, 'df1':[1,2]})

df2 = gpd.GeoDataFrame({'geometry': polys2, 'df2':[1,2]})

res_union = gpd.overlay(df1, df2, how='intersection')

In [29]:
wyssen_to_satskred


Out[29]:
{0: 'No match',
 1: 'No match',
 2: 'No match',
 3: 'No match',
 4: 'No match',
 5: 'No match',
 6: Int64Index([4], dtype='int64'),
 7: Int64Index([4], dtype='int64'),
 8: Int64Index([4], dtype='int64'),
 9: Int64Index([4], dtype='int64'),
 10: Int64Index([4], dtype='int64'),
 11: Int64Index([4], dtype='int64'),
 12: Int64Index([4], dtype='int64'),
 13: Int64Index([4], dtype='int64'),
 14: Int64Index([4], dtype='int64'),
 15: Int64Index([4], dtype='int64'),
 16: Int64Index([4], dtype='int64'),
 17: Int64Index([4], dtype='int64'),
 18: 'No match',
 19: 'No match',
 20: 'No match',
 21: 'No match',
 22: 'No match',
 23: 'No match',
 24: 'No match',
 25: 'No match',
 26: 'No match',
 27: 'No match',
 28: 'No match',
 29: 'No match',
 30: 'No match',
 31: 'No match',
 32: 'No match',
 33: 'No match',
 34: 'No match',
 35: 'No match',
 36: 'No match',
 37: 'No match',
 38: 'No match',
 39: 'No match',
 40: 'No match',
 41: 'No match',
 42: 'No match',
 43: 'No match',
 44: 'No match',
 45: Int64Index([6, 7, 8, 9, 10, 11, 12], dtype='int64'),
 46: Int64Index([6, 7, 8, 9, 10, 11, 12], dtype='int64'),
 47: Int64Index([6, 7, 8, 9, 10, 11, 12], dtype='int64'),
 48: Int64Index([6, 7, 8, 9, 10, 11, 12], dtype='int64'),
 49: Int64Index([6, 7, 8, 9, 10, 11, 12], dtype='int64'),
 50: Int64Index([6, 7, 8, 9, 10, 11, 12], dtype='int64'),
 51: Int64Index([6, 7, 8, 9, 10, 11, 12], dtype='int64'),
 52: Int64Index([6, 7, 8, 9, 10, 11, 12], dtype='int64'),
 53: Int64Index([6, 7, 8, 9, 10, 11, 12], dtype='int64'),
 54: Int64Index([6, 7, 8, 9, 10, 11, 12], dtype='int64'),
 55: Int64Index([6, 7, 8, 9, 10, 11, 12], dtype='int64'),
 56: Int64Index([6, 7, 8, 9, 10, 11, 12], dtype='int64'),
 57: Int64Index([6, 7, 8, 9, 10, 11, 12], dtype='int64'),
 58: Int64Index([6, 7, 8, 9, 10, 11, 12], dtype='int64'),
 59: Int64Index([6, 7, 8, 9, 10, 11, 12], dtype='int64'),
 60: Int64Index([6, 7, 8, 9, 10, 11, 12], dtype='int64'),
 61: Int64Index([6, 7, 8, 9, 10, 11, 12], dtype='int64'),
 62: Int64Index([6, 7, 8, 9, 10, 11, 12], dtype='int64'),
 63: Int64Index([6, 7, 8, 9, 10, 11, 12], dtype='int64'),
 64: Int64Index([6, 7, 8, 9, 10, 11, 12], dtype='int64'),
 65: Int64Index([6, 7, 8, 9, 10, 11, 12], dtype='int64'),
 66: Int64Index([6, 7, 8, 9, 10, 11, 12], dtype='int64'),
 67: Int64Index([6, 7, 8, 9, 10, 11, 12], dtype='int64'),
 68: Int64Index([6, 7, 8, 9, 10, 11, 12], dtype='int64'),
 69: Int64Index([6, 7, 8, 9, 10, 11, 12], dtype='int64'),
 70: Int64Index([6, 7, 8, 9, 10, 11, 12], dtype='int64'),
 71: Int64Index([6, 7, 8, 9, 10, 11, 12], dtype='int64'),
 72: Int64Index([6, 7, 8, 9, 10, 11, 12], dtype='int64'),
 73: Int64Index([10, 11, 12], dtype='int64'),
 74: Int64Index([10, 11, 12], dtype='int64'),
 75: Int64Index([10, 11, 12], dtype='int64'),
 76: Int64Index([10, 11, 12], dtype='int64'),
 77: Int64Index([10, 11, 12], dtype='int64'),
 78: Int64Index([10, 11, 12], dtype='int64'),
 79: Int64Index([10, 11, 12], dtype='int64'),
 80: Int64Index([10, 11, 12], dtype='int64'),
 81: Int64Index([10, 11, 12], dtype='int64'),
 82: Int64Index([10, 11, 12], dtype='int64'),
 83: Int64Index([10, 11, 12], dtype='int64'),
 84: Int64Index([10, 11, 12], dtype='int64'),
 85: Int64Index([10, 11, 12], dtype='int64'),
 86: Int64Index([10, 11, 12], dtype='int64'),
 87: Int64Index([10, 11, 12], dtype='int64'),
 88: 'No match',
 89: 'No match',
 90: 'No match',
 91: 'No match',
 92: 'No match',
 93: 'No match',
 94: 'No match',
 95: Int64Index([15], dtype='int64'),
 96: Int64Index([15], dtype='int64'),
 97: Int64Index([15], dtype='int64'),
 98: Int64Index([15], dtype='int64'),
 99: Int64Index([15], dtype='int64'),
 100: Int64Index([15], dtype='int64'),
 101: Int64Index([15], dtype='int64'),
 102: Int64Index([15], dtype='int64'),
 103: Int64Index([15], dtype='int64'),
 104: Int64Index([15], dtype='int64'),
 105: Int64Index([15], dtype='int64'),
 106: Int64Index([15], dtype='int64'),
 107: Int64Index([15], dtype='int64'),
 108: 'No match',
 109: 'No match',
 110: 'No match',
 111: Int64Index([40, 41, 42], dtype='int64'),
 112: Int64Index([40, 41, 42], dtype='int64'),
 113: Int64Index([40, 41, 42], dtype='int64'),
 114: Int64Index([39, 40, 41, 42], dtype='int64'),
 115: 'No match',
 116: 'No match',
 117: 'No match',
 118: 'No match',
 119: 'No match',
 120: 'No match',
 121: 'No match',
 122: 'No match',
 123: 'No match',
 124: 'No match',
 125: 'No match',
 126: 'No match',
 127: 'No match',
 128: 'No match',
 129: 'No match',
 130: 'No match',
 131: 'No match',
 132: 'No match',
 133: 'No match',
 134: 'No match',
 135: 'No match',
 136: 'No match',
 137: 'No match',
 138: 'No match',
 139: 'No match',
 140: 'No match',
 141: 'No match',
 142: 'No match',
 143: 'No match',
 144: 'No match',
 145: 'No match',
 146: 'No match',
 147: 'No match',
 148: 'No match',
 149: 'No match',
 150: 'No match',
 151: 'No match',
 152: 'No match',
 153: 'No match',
 154: 'No match',
 155: 'No match',
 156: 'No match',
 157: 'No match',
 158: 'No match',
 159: 'No match',
 160: 'No match',
 161: 'No match',
 162: 'No match',
 163: 'No match',
 164: 'No match',
 165: 'No match',
 166: 'No match',
 167: 'No match',
 168: 'No match',
 169: 'No match',
 170: 'No match',
 171: 'No match',
 172: 'No match',
 173: 'No match',
 174: 'No match',
 175: 'No match',
 176: 'No match',
 177: 'No match',
 178: 'No match',
 179: 'No match',
 180: 'No match',
 181: 'No match',
 182: 'No match',
 183: 'No match',
 184: 'No match',
 185: 'No match',
 186: 'No match',
 187: 'No match',
 188: 'No match',
 189: 'No match',
 190: 'No match',
 191: 'No match',
 192: 'No match',
 193: 'No match',
 194: 'No match',
 195: 'No match',
 196: 'No match',
 197: 'No match',
 198: 'No match',
 199: 'No match',
 200: 'No match',
 201: 'No match',
 202: 'No match',
 203: 'No match',
 204: 'No match',
 205: 'No match',
 206: 'No match',
 207: Int64Index([24, 25], dtype='int64'),
 208: Int64Index([27, 28], dtype='int64'),
 209: Int64Index([27, 28], dtype='int64'),
 210: Int64Index([30], dtype='int64'),
 211: Int64Index([30], dtype='int64'),
 212: Int64Index([30], dtype='int64'),
 213: Int64Index([30], dtype='int64'),
 214: 'No match',
 215: 'No match',
 216: 'No match',
 217: 'No match',
 218: 'No match',
 219: 'No match',
 220: 'No match',
 221: 'No match',
 222: 'No match',
 223: 'No match',
 224: 'No match',
 225: 'No match',
 226: 'No match',
 227: 'No match',
 228: 'No match',
 229: 'No match',
 230: 'No match',
 231: 'No match',
 232: 'No match',
 233: 'No match',
 234: 'No match',
 235: 'No match',
 236: 'No match',
 237: Int64Index([31], dtype='int64'),
 238: Int64Index([32, 33, 34, 35, 36], dtype='int64'),
 239: Int64Index([32, 33, 34, 35, 36], dtype='int64'),
 240: Int64Index([32, 33, 34, 35, 36], dtype='int64'),
 241: Int64Index([32, 33, 34, 35, 36], dtype='int64'),
 242: Int64Index([32, 33, 34, 35, 36], dtype='int64'),
 243: Int64Index([32, 33, 34, 35, 36], dtype='int64'),
 244: Int64Index([32, 33, 34, 35, 36], dtype='int64'),
 245: Int64Index([32, 33, 34, 35, 36], dtype='int64'),
 246: Int64Index([32, 33, 34, 35, 36], dtype='int64'),
 247: Int64Index([32, 33, 34, 35, 36], dtype='int64'),
 248: Int64Index([32, 33, 34, 35, 36], dtype='int64'),
 249: Int64Index([32, 33, 34, 35, 36], dtype='int64'),
 250: Int64Index([32, 33, 34, 35, 36], dtype='int64'),
 251: Int64Index([32, 33, 34, 35, 36], dtype='int64'),
 252: Int64Index([32, 33, 34, 35, 36], dtype='int64'),
 253: Int64Index([32, 33, 34, 35, 36], dtype='int64'),
 254: Int64Index([37, 38], dtype='int64'),
 255: Int64Index([37, 38, 39], dtype='int64'),
 256: Int64Index([39, 40, 41], dtype='int64'),
 257: Int64Index([39, 40, 41], dtype='int64'),
 258: Int64Index([39, 40, 41], dtype='int64'),
 259: Int64Index([39, 40, 41], dtype='int64'),
 260: 'No match',
 261: 'No match',
 262: Int64Index([57, 58, 59, 60, 61], dtype='int64'),
 263: Int64Index([57, 58, 59, 60, 61], dtype='int64'),
 264: Int64Index([57, 58, 59, 60, 61], dtype='int64'),
 265: Int64Index([57, 58, 59, 60, 61], dtype='int64'),
 266: Int64Index([53, 54, 55, 56, 57, 58, 59], dtype='int64'),
 267: Int64Index([53, 54, 55, 56, 57, 58, 59], dtype='int64'),
 268: Int64Index([53, 54, 55, 56], dtype='int64'),
 269: Int64Index([53, 54, 55, 56], dtype='int64'),
 270: Int64Index([53, 54, 55, 56], dtype='int64'),
 271: Int64Index([53, 54, 55, 56], dtype='int64'),
 272: Int64Index([53, 54, 55, 56], dtype='int64'),
 273: Int64Index([53, 54, 55, 56], dtype='int64'),
 274: Int64Index([53, 54, 55, 56], dtype='int64'),
 275: Int64Index([53, 54, 55, 56], dtype='int64'),
 276: Int64Index([53, 54, 55, 56], dtype='int64'),
 277: Int64Index([53, 54, 55, 56], dtype='int64'),
 278: Int64Index([53, 54, 55, 56], dtype='int64'),
 279: Int64Index([53, 54, 55, 56], dtype='int64'),
 280: Int64Index([53, 54, 55, 56], dtype='int64'),
 281: Int64Index([53, 54, 55, 56], dtype='int64'),
 282: Int64Index([53, 54, 55, 56], dtype='int64'),
 283: 'No match',
 284: 'No match',
 285: 'No match',
 286: 'No match',
 287: 'No match',
 288: 'No match',
 289: 'No match',
 290: 'No match',
 291: 'No match',
 292: 'No match',
 293: 'No match',
 294: 'No match',
 295: 'No match',
 296: 'No match',
 297: 'No match',
 298: 'No match',
 299: 'No match',
 300: 'No match',
 301: 'No match',
 302: 'No match',
 303: 'No match',
 304: 'No match',
 305: 'No match',
 306: 'No match',
 307: Int64Index([49, 50, 51], dtype='int64'),
 308: Int64Index([49, 50, 51], dtype='int64'),
 309: Int64Index([49, 50, 51], dtype='int64'),
 310: Int64Index([49, 50, 51], dtype='int64'),
 311: Int64Index([49, 50, 51], dtype='int64'),
 312: Int64Index([49, 50, 51], dtype='int64'),
 313: Int64Index([49, 50, 51], dtype='int64'),
 314: Int64Index([49, 50, 51], dtype='int64'),
 315: Int64Index([49, 50, 51], dtype='int64'),
 316: Int64Index([49, 50, 51], dtype='int64'),
 317: Int64Index([49, 50, 51], dtype='int64'),
 318: Int64Index([49, 50, 51], dtype='int64'),
 319: Int64Index([49, 50, 51], dtype='int64'),
 320: Int64Index([49, 50, 51], dtype='int64'),
 321: Int64Index([49, 50, 51], dtype='int64'),
 322: Int64Index([49, 50, 51], dtype='int64'),
 323: Int64Index([49, 50, 51], dtype='int64'),
 324: Int64Index([49, 50, 51], dtype='int64'),
 325: Int64Index([49, 50, 51], dtype='int64'),
 326: Int64Index([49, 50, 51], dtype='int64'),
 327: Int64Index([49, 50, 51], dtype='int64'),
 328: Int64Index([49, 50, 51], dtype='int64'),
 329: Int64Index([49, 50, 51], dtype='int64'),
 330: Int64Index([49, 50, 51], dtype='int64'),
 331: Int64Index([49, 50, 51], dtype='int64'),
 332: 'No match',
 333: 'No match',
 334: 'No match',
 335: 'No match',
 336: 'No match',
 337: 'No match',
 338: 'No match',
 339: 'No match',
 340: 'No match',
 341: 'No match',
 342: 'No match',
 343: 'No match',
 344: 'No match',
 345: 'No match',
 346: 'No match',
 347: 'No match',
 348: 'No match',
 349: 'No match',
 350: 'No match',
 351: 'No match',
 352: 'No match',
 353: 'No match',
 354: 'No match',
 355: 'No match',
 356: 'No match',
 357: 'No match',
 358: 'No match',
 359: 'No match',
 360: 'No match',
 361: 'No match',
 362: 'No match',
 363: 'No match',
 364: 'No match',
 365: 'No match',
 366: 'No match',
 367: 'No match',
 368: 'No match'}

In [30]:
expr = 'Ref_Date <= d & d => Det_Date'

In [31]:
map(lambda frame: frame.query(expr), [wyssen_df_1, satskred_df_1])


---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-31-f828e7131e87> in <module>
----> 1 map(lambda frame: frame.query(expr), [wyssen_df_1, satskred_df_1])
      2 

NameError: name 'wyssen_df_1' is not defined

In [ ]:
wyssen_df_1['d'].where(satskred_df_1)