def geocode_file(inps):
    """
    Geocodes the input file
    :param inps: input name space
    """
    if 'stripmap' in inps.prefix:
        sys.path.append(os.path.join(os.getenv('ISCE_STACK'), 'stripmapStack'))
    else:
        sys.path.append(os.path.join(os.getenv('ISCE_STACK'), 'topsStack'))

    import geocodeGdal as gg

    inps.cropbox = [val for val in inps.cropbox.split()]
    if len(inps.cropbox) != 4:
        raise Exception('Bbox should contain 4 floating point values')

    scp_arg = {'latFile': os.path.abspath(os.path.join(inps.geo_reference_dir, inps.lat_file)),
                'lonFile': os.path.abspath(os.path.join(inps.geo_reference_dir, inps.lon_file)),
                'xOff': 0,
                'yOff': 0,
                'prodlist': [inps.input_file + '.slc.ml'],
                'resamplingMethod': 'near'}

    scp_arg = argparse.Namespace(**scp_arg)
    #scp_arg.prodlist = [inps.prod_list + '.slc.ml']

    WSEN = str(inps.cropbox[2]) + ' ' + str(inps.cropbox[0]) + ' ' + str(inps.cropbox[3]) + ' ' + str(inps.cropbox[1])
    latFile, lonFile = gg.prepare_lat_lon(scp_arg)

    gg.getBound(latFile, float(inps.cropbox[0]), float(inps.cropbox[1]), 'lat')
    gg.getBound(lonFile, float(inps.cropbox[2]), float(inps.cropbox[3]), 'lon')

    infile = os.path.abspath(inps.input_file + '.slc.ml')
    print('geocoding ' + infile)
    outFile = os.path.join(os.path.dirname(infile), "geo_" + os.path.basename(infile))
    gg.writeVRT(infile, latFile, lonFile)

    cmd = 'gdalwarp -of ENVI -geoloc  -te ' + WSEN + ' -tr ' + str(inps.lat_step) + ' ' + \
          str(inps.lon_step) + ' -srcnodata 0 -dstnodata 0 ' + ' -r ' + inps.resampling_method + \
          ' -co INTERLEAVE=BIL ' + infile + '.vrt ' + outFile
    print(cmd)
    os.system(cmd)

    # write_xml(outFile)
    cmd = "gdal2isce_xml.py -i " + outFile
    os.system(cmd)

    return
Exemple #2
0
def geocode_file(inps):
    """
    Geocodes the input file
    :param inps: input name space
    """
    import geocodeGdal as gg

    inps.cropbox = [val for val in inps.cropbox.split()]
    if len(inps.cropbox) != 4:
        raise Exception('Bbox should contain 4 floating point values')

    inps.lat_file = os.path.abspath(
        os.path.join(inps.geo_master_dir, inps.lat_file))
    inps.lon_file = os.path.abspath(
        os.path.join(inps.geo_master_dir, inps.lon_file))
    inps.prod_list = [inps.prod_list + '.slc.ml']

    WSEN = str(inps.cropbox[2]) + ' ' + str(inps.cropbox[0]) + ' ' + str(
        inps.cropbox[3]) + ' ' + str(inps.cropbox[1])
    latFile, lonFile = gg.prepare_lat_lon(inps)

    gg.getBound(latFile, float(inps.cropbox[0]), float(inps.cropbox[1]), 'lat')
    gg.getBound(lonFile, float(inps.cropbox[2]), float(inps.cropbox[3]), 'lon')

    for infile in inps.prod_list:
        infile = os.path.abspath(infile)
        print('geocoding ' + infile)
        outFile = os.path.join(os.path.dirname(infile),
                               "geo_" + os.path.basename(infile))
        gg.writeVRT(infile, latFile, lonFile)

        cmd = 'gdalwarp -of ENVI -geoloc  -te ' + WSEN + ' -tr ' + str(inps.lat_step) + ' ' + \
              str(inps.lon_step) + ' -srcnodata 0 -dstnodata 0 ' + ' -r ' + inps.resampling_method + \
              ' -co INTERLEAVE=BIL ' + infile + '.vrt ' + outFile
        print(cmd)
        os.system(cmd)

        # write_xml(outFile)
        cmd = "gdal2isce_xml.py -i " + outFile
        os.system(cmd)

    return