Example #1
0
def get_footprints_inters_ext(filelist,
                              extent_base,
                              epsg_base,
                              use_l1a_met=False):
    list_poly = []
    for f in filelist:
        if use_l1a_met:
            poly = vt.l1astrip_polygon(os.path.dirname(f))
            trans = vt.coord_trans(False, 4326, False, epsg_base)
            poly.Transform(trans)
        else:
            ext, proj = vt.extent_rast(f)
            poly = vt.poly_from_extent(ext)
            trans = vt.coord_trans(True, proj, False, epsg_base)
            poly.Transform(trans)
        list_poly.append(poly)

    poly_ext = vt.poly_from_extent(extent_base)

    filelist_out = []
    for poly in list_poly:
        if poly.Intersect(poly_ext):
            filelist_out.append(filelist[list_poly.index(poly)])

    return filelist_out
Example #2
0
def tilename_stack(ds):
    # no checks, we assume it's a latlon tile and just get the tile center coordinates
    extent, proj = extent_stack(ds)
    poly = vt.poly_from_extent(extent)
    trans = vt.coord_trans(True, proj, False, 4326)
    poly.Transform(trans)
    centroid = vt.get_poly_centroid(poly)
    tile_name = vt.latlon_to_SRTMGL1_naming(centroid[1], centroid[0])

    return tile_name
Example #3
0
def raster_to_point(fn_dem):

    extent, proj_wkt = ot.extent_rast(fn_dem)
    poly = ot.poly_from_extent(extent)
    transform = ot.coord_trans(True, proj_wkt, False, 4326)
    poly.Transform(transform)
    center_lon, center_lat = ot.get_poly_centroid(poly)

    epsg, utm_zone = ot.latlon_to_UTM(center_lat, center_lon)

    print('Reprojecting in ' + str(epsg))

    img_vhr = GeoImg(fn_dem)

    dest = gdal.Warp('',
                     img_vhr.gd,
                     format='MEM',
                     dstSRS='EPSG:{}'.format(epsg),
                     xRes=out_res,
                     yRes=out_res,
                     resampleAlg=gdal.GRA_Bilinear,
                     dstNodata=-9999)

    img_lr = GeoImg(dest)

    print('Extracting coords...')

    elevs = img_lr.img.flatten()
    x, y = img_lr.xy(ctype='center')
    coords = list(zip(x.flatten(), y.flatten()))
    coords_latlon = point_to_lonlat_trans(int(epsg), coords)
    lon, lat = zip(*coords_latlon)
    lon = np.array(lon)
    lat = np.array(lat)

    keep = ~np.isnan(elevs)
    h = elevs[keep]
    lat = lat[keep]
    lon = lon[keep]

    print('Done for this DEM')

    return h, lat, lon
Example #4
0
    if fn.endswith('.tif')
]
print('Found ' + str(len(all_dems)) + ' DEMs.')

list_ak = []
list_ant = []
for fn_dem in all_dems:

    print('DEM number ' + str(all_dems.index(fn_dem)) + ': ' + fn_dem)

    img = GeoImg(fn_dem)

    if img.npix_x > 5:  #need to figure out why these LAS files don't process properly?

        extent, proj_wkt = ot.extent_rast(fn_dem)
        poly = ot.poly_from_extent(extent)
        print(proj_wkt)
        transform = ot.coord_trans(True, proj_wkt, False, 4326)
        poly.Transform(transform)
        center_lon, center_lat = ot.get_poly_centroid(poly)
        if center_lat > 0:
            list_ak.append(fn_dem)
        else:
            list_ant.append(fn_dem)

reg_dir = ['01_02_rgi60', '19_rgi60']

for reg in reg_dir:

    print('Working on region: ' + reg)