Hi All, I am working on blending two georeferenced images. My idea was to open them in Python using GDAL library , finding the overlapping area and then do some more work. I found this book about Geoprocessing with Python where they talk about convertingpixel coordinates to another image. Unfortunately I stuck at the beginning. The beggigning of the code looks like this:
def get_extent(fn): #Returns min_x, max_y, max_x, min_y ds = gdal.Open(fn) gt = ds.GetGeoTransform() return (gt[0], gt[3], gt[0] + gt[1] * ds.RasterXSize, gt[3] + gt[5] * ds.RasterYSize) os.chdir(r'Path_to_images'') in_files = glob.glob('O*.png') min_x, max_y, max_x, min_y = get_extent(in_files[0]) # calculate output extent from all inputs for fn in in_files[1:]: minx, maxy, maxx, miny = get_extent(fn) min_x = min(min_x, minx) max_y = max(max_y, maxy) max_x = max(max_x, maxx) min_y = min(min_y, miny) in_ds = gdal.Open(in_files[0]) gt = in_ds.GetGeoTransform() When I run this code, I receive error: min_x, max_y, max_x, min_y = get_extent(in_files[0]) IndexError: list index out of range My* in_files* are empty. When I change the way of loading data to: in_files = [cv2.imread(file) for file in glob.glob('D:/_work(z pulpitu)/mosaicing/GDAL_test/data/*png')] My in_files type is a list with two attributes (nuppy_arrays) byt I get the error: return _gdal.Open(*args) RuntimeError: not a string Can anyone help me with solving this problem? Thanks, Ania
_______________________________________________ gdal-dev mailing list gdal-dev@lists.osgeo.org https://lists.osgeo.org/mailman/listinfo/gdal-dev