Esempio n. 1
0
def parse_dem_path(path):
    """
    Return datetime and type from DEM path.
    """
    datestr = re.findall(r'([0-9]{8})', glimpse.helpers.strip_path(path))[0]
    # HACK: Aerial and satellite imagery taken around local noon (~ 22:00 UTC)
    t = datetime.datetime.strptime(datestr + str(22), '%Y%m%d%H')
    typestr = re.findall(r'dem-([^\/]+)', path)[0]
    return dict(datetime=t, type=typestr)
Esempio n. 2
0
def parse_image_path(path, sequence=False):
    """
    Return metadata parsed from image path.

    Arguments:
        path (str): Image path or basename
        sequence (bool): Whether to include sequence metadata (camera, service, ...)
    """
    basename = glimpse.helpers.strip_path(path)
    station, date_str, time_str = re.findall('^([^_]+)_([0-9]{8})_([0-9]{6})',
                                             basename)[0]
    capture_time = datetime.datetime.strptime(date_str + time_str,
                                              '%Y%m%d%H%M%S')
    results = dict(basename=basename,
                   station=station,
                   date_str=date_str,
                   time_str=time_str,
                   datetime=capture_time)
    if sequence:
        sequences = Sequences()
        is_row = ((sequences.station == station) &
                  (sequences.first_time_utc <= capture_time) &
                  (sequences.last_time_utc >= capture_time))
        rows = np.where(is_row)[0]
        if len(rows) != 1:
            raise ValueError(
                'Image path has zero or multiple sequence matches: ' + path)
        results = glimpse.helpers.merge_dicts(sequences.loc[rows[0]].to_dict(),
                                              results)
    return results
Esempio n. 3
0
    # 'CG05_20050811_130000',
    # 'CG05_20050811_190000',
    # NOTE: More clarity than CG05_20050827_190000
    'CG05_20050826_190000',
    'CG06_20060712_195953',
    'CG06_20060727_195951'
)
clahe = cv2.createCLAHE(clipLimit=1.0, tileGridSize=(20, 20))

# ---- Select DEMs and Orthos ----

# Prepare DEMs
dem_paths = glob.glob(os.path.join(root, 'dem-aerometric', 'data', '*.tif'))
dem_paths += glob.glob(os.path.join(root, 'dem-arcticdem', 'data', '*.tif'))
dem_paths += glob.glob(os.path.join(root, 'dem-ifsar', 'data', '*.tif'))
dem_dates = [datetime.datetime.strptime(re.findall(r'([0-9]{8})', path)[0], '%Y%m%d')
    for path in dem_paths]

# Prepare orthophotos
ortho_paths = glob.glob(os.path.join(root, 'ortho', '*.tif'))
ortho_paths += glob.glob(os.path.join(root, 'ortho-ifsar', 'data', '*.tif'))
ortho_dates = [datetime.datetime.strptime(re.findall(r'([0-9]{8})', path)[0], '%Y%m%d')
    for path in ortho_paths]

# ---- Control synths (ideal camera) ----

for image in images:
    print(image)
    start = timeit.default_timer()
    basename = os.path.join('svg-synth', image)
    if os.path.isfile(basename + '-synth.JPG'):
Esempio n. 4
0
    # NOTE: 20050811 ortho messed up
    # 'CG05_20050811_130000',
    # 'CG05_20050811_190000',
    # NOTE: More clarity than CG05_20050827_190000
    'CG05_20050826_190000',
    'CG06_20060712_195953',
    'CG06_20060727_195951')

# ---- Select DEMs and Orthos ----

# Prepare DEMs
dem_paths = glob.glob(os.path.join(root, 'dem-aerometric', 'data', '*.tif'))
dem_paths += glob.glob(os.path.join(root, 'dem-arcticdem', 'data', '*.tif'))
dem_paths += glob.glob(os.path.join(root, 'dem-ifsar', 'data', '*.tif'))
dem_dates = [
    datetime.datetime.strptime(re.findall(r'([0-9]{8})', path)[0], '%Y%m%d')
    for path in dem_paths
]

# Prepare orthophotos
ortho_paths = glob.glob(os.path.join(root, 'ortho', '*.tif'))
ortho_paths += glob.glob(os.path.join(root, 'ortho-ifsar', 'data', '*.tif'))
ortho_dates = [
    datetime.datetime.strptime(re.findall(r'([0-9]{8})', path)[0], '%Y%m%d')
    for path in ortho_paths
]

# ---- Validation synths (calibrated camera) ----

for image in images:
    basename = os.path.join('images', image)
Esempio n. 5
0
    glimpse.helpers.elevate_geojson(geo, elevation=dem)
    for coords in glimpse.helpers.geojson_itercoords(geo):
        if any(np.isnan(coords[:, 2])):
            print('Missing elevations in ' + path)
    geo2 = glimpse.helpers.ordered_geojson(geo)
    glimpse.helpers.write_geojson(geo2,
        path=os.path.splitext(path)[0] + '.geojson',
        decimals=(7, 7, 2), crs=32606)

# ---- Ground control points ----

GCP_DEM_PATH = '/volumes/science-b/data/columbia/_new/ArcticDEM/v2.0/tiles/merged_projected_clipped.tif'
dem_ref = glimpse.Raster.read(GCP_DEM_PATH)

geo = glimpse.helpers.read_geojson('geojson/gcp.geojson', crs=32606, key='id')
keys = [key for key in geo['features'] if re.findall('T' + DATE_STR, key)]
keys.sort()
for key in keys:
    coords = geo['features'][key]['geometry']['coordinates']
    coords[:, 2] = dem.sample(coords[:, 0:2])
    if any(np.isnan(coords[:, 2])):
        print('Missing elevation for ' + key)

# Check for gross errors
z = np.vstack([geo['features'][key]['geometry']['coordinates'][:, 2] for key in keys])
z_ref = np.vstack([dem_ref.sample(geo['features'][key]['geometry']['coordinates'][:, 0:2]) for key in keys])
z - z_ref

geo2 = glimpse.helpers.ordered_geojson(geo, properties=('id', 'valid', 'notes'))
glimpse.helpers.write_geojson(geo2, path='geojson/gcp.geojson',
    decimals=(7, 7, 2), crs=32606)
Esempio n. 6
0
    ('20141114_20141130', 'golive'),  # some holes
    ('20150322_20150423', 'golive'),  # many holes
    ('20150430_20150516', 'golive'),  # some holes
    ('20150502_20150518', 'golive'),  # some holes
    ('20150617_20150703', 'golive'),
    ('20150703_20150719', 'golive'),
    ('20150719_20150804', 'golive'),
    ('20150804_20150820', 'golive'),
    ('20150907_20150923', 'golive'),
    ('20150923_20151025', 'golive'),
    ('20160621_20160707', 'golive'),
    ('20161009_20161025', 'golive')
]
# Add all Krimmel velocities
velocity_keys += [
    (re.findall(r'([0-9]{8}_[0-9]{8})', path)[0], 'krimmel')
    for path in glob.glob(
        os.path.join(root, 'velocities-krimmel', 'data', '*_vx.tif'))
]
# Add all early McNabb landsat velocities
velocity_keys += [
    (re.findall(r'([0-9]{8}_[0-9]{8})', path)[0], 'landsat')
    for path in glob.glob(
        os.path.join(root, 'velocities-landsat', 'data', '*_vx.tif'))
    if re.findall(r'([0-9]{8}_[0-9]{8})', path)[0] < '20110101'
]
# Sort by time
velocity_keys.sort(key=lambda x: x[0])

# ---- Read and sample at template ----
# t: start, end, mid