예제 #1
0
def main():
    # define input directory containing file sto be stacked
    dir_in = '/...'
    
    # define output file name
    dstfile = '/.../x'
    
    # shapefile (for stack boundaries)
    shp = '/../x.shp'
    
    # store results in separate files or one single stack file? If separate then dstfile is used as a directory.
    sep = True
    
    # list files to be resampled; those not overlapping with the shapefile geometry will excluded by function stack
    srcfiles = finder(dir_in, ['S1*_VV_*norm_db.tif'])
    
    # check whether dstfile is already a file
    if os.path.isfile(dstfile):
        raise IOError('dstfile already exists')
    
    # create groups of similar time stamps for mosaicking.
    # All images with a time stamp of less than 30s difference will be grouped
    groups = groupbyTime(srcfiles, seconds, 30)
    
    # final function call
    # groups will be mosaicked first
    # the resulting images will all have the same extent
    stack(srcfiles=groups, dstfile=dstfile, resampling='bilinear',
          targetres=[20, 20], srcnodata=-99, dstnodata=-99,
          shapefile=shp, sortfun=seconds, separate=sep, overwrite=False)
예제 #2
0
def test_groupbyTime():
    filenames = ['S1__IW___A_20151212T120000',
                 'S1__IW___A_20151212T120100',
                 'S1__IW___A_20151212T120300']
    groups = anc.groupbyTime(filenames, anc.seconds, 60)
    print(groups)
    assert len(groups) == 2
    assert isinstance(groups[0], list)
    assert len(groups[0]) == 2

    filenames = ['S1__IW___A_20151212T120000',
                 'S1__IW___A_20151212T120100',
                 'S1__IW___A_20151212T120200']
    groups = anc.groupbyTime(filenames, anc.seconds, 60)
    print(groups)
    assert len(groups[0]) == 3
예제 #3
0
def main():

    dirs = [
        "stack_savi"
    ]  #, "stack_ndvi", "stack_msavi", "stack_reip", "stack_rvi", "stack_dvi"]

    resolution = [30, 30]

    # shapefile (for stack boundaries)
    shp = 'F:/geodata/geo402/02_features/LADYBRAND_final_enlarged_study_area.shp'

    # store results in separate files or one single stack file? If separate then dstfile is used as a directory.
    sep = True

    for dir in dirs:

        # define input directory containing files to be stacked
        dir_in = 'F:/geodata/geo402/S2/xx_S2_indices/' + dir
        print(dir_in)
        os.makedirs(dir_in, exist_ok=True)

        # define output file name
        dstfile = 'F:/geodata/geo402/S2/xx_S2_indices/mosaics/' + dir
        print(dstfile)

        # list files to be resampled; those not overlapping with the shapefile geometry will excluded by function stack
        srcfiles = finder(dir_in, ['*'])

        # check whether dstfile is already a file
        if os.path.isfile(dstfile):
            raise IOError('dstfile already exists')

        # create groups of similar time stamps for mosaicking.
        # All images with a time stamp of less than 30s difference will be grouped
        groups = groupbyTime(srcfiles, seconds, 30)

        # final function call
        # groups will be mosaicked first
        # the resulting images will all have the same extent
        stack(srcfiles=groups,
              dstfile=dstfile,
              resampling='bilinear',
              targetres=resolution,
              srcnodata=-9999,
              dstnodata=-9999,
              shapefile=shp,
              sortfun=seconds,
              separate=sep,
              overwrite=True)
def main():
    '''
    both polarisations are included in the script but are stored in different folders
    '''

    resolution = [30, 30]

    # shapefile (for stack boundaries)
    shp = 'F:/geodata/geo402/##study_area/LADYBRAND_final_enlarged_study_area.shp'

    # store results in separate files or one single stack file? If separate then dstfile is used as a directory.
    sep = False

    # define input directory containing files to be stacked
    dir_in = 'F:/geodata/geo402/S1_GRD/xx_new/GRD_VH_vrts/'
    print(dir_in)
    # os.makedirs(dir_in, exist_ok=True)

    # define output file name
    dstfile = 'F:/geodata/geo402/S1_GRD/xx_new/S1A_IW_GRD_VH_stack'
    print(dstfile)

    # list files to be resampled; those not overlapping with the shapefile geometry will excluded by function stack
    srcfiles = finder(dir_in, ['*'])

    # check whether dstfile is already a file
    if os.path.isfile(dstfile):
        raise IOError('dstfile already exists')

    # create groups of similar time stamps for mosaicking.
    # All images with a time stamp of less than 30s difference will be grouped
    groups = groupbyTime(srcfiles, seconds, 30)

    # final function call
    # groups will be mosaicked first
    # the resulting images will all have the same extent
    stack(srcfiles=groups,
          dstfile=dstfile,
          resampling='bilinear',
          targetres=resolution,
          srcnodata=-99,
          dstnodata=-99,
          shapefile=shp,
          sortfun=seconds,
          separate=sep,
          overwrite=True,
          cores=7)