eubtube / HOT_GCC_Collines

Automation Scripts for QGIS Project Creation
0 stars 0 forks source link

iterate_grid: Sort Out Iteration over Grid #1

Closed eubtube closed 3 years ago

eubtube commented 3 years ago

Need to sort out how to iterate row and column ids to pull out a grouping as shown in below, where the first grouping takes Rows and columns 1-3, second takes R1-3, C4-6, etc. This is in the iterate_grid.ipynb file.

    C1 C2 C3 C4 C5 C6 C7 C8 C9
R1  1  1  1  2  2  2  3  3  3 
R2  1  1  1  2  2  2  3  3  3 
R3  1  1  1  2  2  2  3  3  3 
R4  4  4  4  5  5  5  6  6  6
 ... etc 
eubtube commented 3 years ago

Fundamental to issues #2 and #3, completed with this snippet to define filter and break up grid into smaller projects:


def make_groups(df,nrow,ncol):
    # A function to make new df columns "grouprow" and "groupcol" for filter iteration
    # with user defined size
    df['grouprow'] = df['row'].apply(lambda x: np.floor((x-1)/nrow+1).astype(int))
    df['groupcol'] = df['col'].apply(lambda x: np.floor((x-1)/ncol+1).astype(int))
    return df