Exemplo n.º 1
0
def find_las_files_by_polygon(file_list, polygon, print_keep=False):
    las_files = np.genfromtxt(file_list, delimiter=',', dtype='S256')
    keep = []
    n_files = las_files.size
    for i in range(0, n_files):
        UR, LR, UL, LL = get_lasfile_bbox(las_files[i])
        las_box = np.asarray([UR, LR, LL, UL])
        x, y, inside = lidar.points_in_poly(las_box[:, 0], las_box[:, 1],
                                            polygon)  # fix this test
        if inside.sum() > 0:
            keep.append(las_files[i])
        else:
            x, y, inside = lidar.points_in_poly(polygon[:, 0], polygon[:, 1],
                                                las_box)
            if inside.sum() > 0:
                keep.append(las_files[i])
    if print_keep:
        print('las tiles to load in:', len(keep))
        for ll in range(0, len(keep)):
            print(keep[ll])
    return keep
Exemplo n.º 2
0
def find_laz_files_by_polygon(file_list, polygon, print_keep=False):
    laz_files = np.genfromtxt(file_list, delimiter=',', dtype='S256')
    keep = []
    n_files = laz_files.size
    for i in range(0, n_files):
        os.system("las2las %s temp.las" % laz_files[i])
        UR, LR, UL, LL = get_lasfile_bbox('temp.las')
        las_box = np.asarray([UR, LR, LL, UL])
        x, y, inside = lidar.points_in_poly(las_box[:, 0], las_box[:, 1],
                                            polygon)
        if inside.sum() > 0:
            keep.append(laz_files[i])
        os.system("rm temp.las")
    if print_keep:
        print 'las tiles to load in:', len(keep)
        for ll in range(0, len(keep)):
            print keep[ll]
    return keep
Exemplo n.º 3
0
def find_laz_files_by_polygon(file_list, polygon, print_keep=False):
    laz_files = np.genfromtxt(file_list, delimiter=',', dtype='unicode')
    keep = []
    n_files = laz_files.size
    for i in range(0, n_files):
        temp_file = 'temp_%i.las' % np.round(
            np.random.random() * 10**9).astype(int)
        os.system("las2las %s %s" % (laz_files[i], temp_file))
        UR, LR, UL, LL = get_lasfile_bbox(temp_file)
        las_box = np.asarray([UR, LR, LL, UL])
        x, y, inside = lidar.points_in_poly(las_box[:, 0], las_box[:, 1],
                                            polygon)
        if inside.sum() > 0:
            keep.append(laz_files[i])
        os.system("rm %s" % temp_file)
    if print_keep:
        print('las tiles to load in:', len(keep))
        for ll in range(0, len(keep)):
            print(keep[ll])
    return keep