Exemplo n.º 1
0
    def get_product_metadata(self, path_and_file=None, product_type=None):
        from snapme import read_product
        from snapme import get_metadata_S1, get_metadata_S2

        p = read_product(path_and_file=path_and_file)
        if p is None:
            logging.info('ERROR opening zip file = skipping')
            metadata = None
            return

        if product_type == 'S1':
            metadata = get_metadata_S1(p)
        elif product_type == 'S2':
            metadata = get_metadata_S2(p)

        return metadata
Exemplo n.º 2
0
    s1_abspath = glob.glob(path + r + '/S1*.zip')[0]
    s2_abspath = glob.glob(path + r + '/S2*.zip')[0]
    s1_fname = os.path.basename(s1_abspath)
    s2_fname = os.path.basename(s2_abspath)

    print '---'
    print 'idx ' + str(k)
    print 'S1 = ' + s1_fname
    print 'S2 = ' + s2_fname
    # import sys
    # sys.exit()

    # s2 product
    # =====================================================================
    s2 = gpt.read_product(path_and_file=s2_abspath)
    s2 = gpt.resample(s2, referenceBand='B2')
    s2_metadata = gpt.get_metadata_S2(s2)
    subset_bounds = s2_metadata['footprint']

    # s1 product
    # =====================================================================
    s1 = gpt.read_product(path_and_file=s1_abspath)
    s1_metadata = gpt.get_metadata_S1(s1)
    # s1 = gpt.topsar_split(s1, subswath='IW2', polarisation='VV')
    s1 = gpt.apply_orbit_file(s1)
    s1 = gpt.deburst(s1)

    # --- get intensity bands
    # sourceBands = ['Intensity_IW2_VV']
    bdnames = gpt.get_bandnames(s1, print_bands=0)
Exemplo n.º 3
0
import snapme as gpt
import fnmatch
import numpy as np
import matplotlib.pyplot as plt

f = '/home/sebastien/DATA/data_snap/20170128T030737_20170209T030748_IW2_VV.dim'
p = gpt.read_product(path_and_file=f)

bdnames = gpt.get_bandnames(p, print_bands=None)
bname = fnmatch.filter(bdnames, 'coh_*')[0]

# --- get band data
band = p.getBand(bname)
w, h = gpt.get_rasterDim(p, bname)
band_data = np.zeros(w * h, np.float32)
band.readPixels(0, 0, w, h, band_data)
band_data.shape = h, w
B = band_data

# --- analyze
thresh = 0.5
mask = np.where(band_data < thresh, 0, 1)
nbpix = np.count_nonzero(mask == 0)

colormap = None
imgplot = plt.imshow(band_data, cmap=colormap)
plt.show()

# fig = plt.imshow(cube)
# fig.write_png('oulala')
Exemplo n.º 4
0
import snapme as gpt

subset_wkt = 'POLYGON((40.63 13.64, 40.735 13.64, 40.735 13.53, 40.63 13.53, 40.63 13.64))'

p = '/home/sebastien/DATA/data_satellite/ertaale/'
# f = 'S2A_MSIL1C_20170129T075211_N0204_R092_T37PFR_20170129T075205.zip'
f = 'S2A_MSIL1C_20170728T073611_N0205_R092_T37PFR_20170728T075430.zip'
f = 'S2A_OPER_PRD_MSIL1C_PDMC_20161001T130040_R092_V20161001T075212_20161001T075208.zip'

# --- open product
# ------------------------------------------
s2 = gpt.read_product(path_and_file=p + f)
s2 = gpt.resample(s2, referenceBand='B2')
s2 = gpt.subset(s2, geoRegion=subset_wkt)
s2_metadata = gpt.get_metadata_S2(s2)
# prod2export_s2 = gpt.band_select(s2, sourceBands=['B2', 'B3', 'B4', 'B8', 'collocation_flags'])
prod2export_s2 = s2

# --- export product
# ------------------------------------------
fmt_out = 'BEAM-DIMAP'  # 'GeoTIFF-BigTIFF'
f_out = '_'.join(['S2', s2_metadata['acqstarttime_str']])
p_out = '/home/sebastien/DATA/data_sar2opt/ertaale/'
gpt.get_bandnames(prod2export_s2, print_bands=None)
# gpt.write_product(prod2export_s2, f_out=f_out, fmt_out=fmt_out, p_out=p_out)

# --- get info on an operator options
# operator_name = 'Idepix.Sentinel2'
# from snappy import GPF
# GPF.getDefaultInstance().getOperatorSpiRegistry().loadOperatorSpis()
# op_spi = GPF.getDefaultInstance().getOperatorSpiRegistry().getOperatorSpi(operator_name)
Exemplo n.º 5
0
    s2p_abspath = r[2]
    dt_hours = r[3]
    s1_fname = os.path.basename(s1_abspath)
    s2_fname = os.path.basename(s2_abspath)

    print '---'
    print 'idx ' + str(k)
    print 'S1 = ' + s1_fname
    print 'S2 = ' + s2_fname
    print 'dt = ' + str(dt_hours)
    # import sys
    # sys.exit()

    # s2 product
    # =====================================================================
    s2 = gpt.read_product(path_and_file=s2_abspath)
    s2 = gpt.resample(s2, referenceBand='B2')
    s2_metadata = gpt.get_metadata_S2(s2)
    # subset_bounds = s2_metadata['footprint']

    # s1 product
    # =====================================================================
    s1 = gpt.read_product(path_and_file=s1_abspath)
    s1_metadata = gpt.get_metadata_S1(s1)
    # s1 = gpt.topsar_split(s1, subswath='IW2', polarisation='VV')
    s1 = gpt.apply_orbit_file(s1)
    s1 = gpt.deburst(s1)

    # --- get intensity bands
    # sourceBands = ['Intensity_IW2_VV']
    bdnames = gpt.get_bandnames(s1, print_bands=0)
Exemplo n.º 6
0
# --- ex: download quicklook (for Sentinel-1 IW/SLC products)
p[0].getQuicklook()

# --- ex: download full product
p[0].getFullproduct()

# -----------------------------------------------------------------------------------------------------------------------------

# === SNAPME snippets

import snapme as gpt

# --- dinsar processing chain
master_path = '/home/khola/DATA/data_satellite/ertaale/S1A_IW_SLC__1SSV_20170111T152712_20170111T152739_014786_018145_5703.zip'
slave_path = '/home/khola/DATA/data_satellite/ertaale/S1A_IW_SLC__1SSV_20170204T152711_20170204T152738_015136_018C0E_12BD.zip'
m = gpt.read_product(path_and_file=master_path)  # open master product
s = gpt.read_product(path_and_file=slave_path)  # open slave product
m = gpt.topsar_split(m, subswath='IW2',
                     polarisation='VV')  # select swath master
s = gpt.topsar_split(s, subswath='IW2',
                     polarisation='VV')  # select swath slave
m = gpt.apply_orbit_file(m)  # apply orbit file master
s = gpt.apply_orbit_file(s)  # apply orbit file slave
p = gpt.back_geocoding(m, s)  # coregister master/slave
p = gpt.interferogram(p)  # interferogram generation
p = gpt.deburst(p)  # deburst
p = gpt.topo_phase_removal(p)  # topographic phase removal
p = gpt.goldstein_phase_filtering(p)  # phase filtering
bands = gpt.get_bandnames(p)  # get bands in product
p = gpt.terrain_correction(p, bands[3])  # geocoding
p = gpt.subset(