<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">Hi All,<div><br></div><div>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.</div><div>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:</div><div><br></div><div><div>def get_extent(fn):</div><div>    #Returns min_x, max_y, max_x, min_y</div><div>    ds = gdal.Open(fn)</div><div>    gt = ds.GetGeoTransform()</div><div>    return (gt[0], gt[3], gt[0] + gt[1] * ds.RasterXSize, gt[3] + gt[5] * ds.RasterYSize)</div><div><br></div><div>os.chdir(r'Path_to_images'')</div><div>in_files = glob.glob('O*.png')</div></div><div><br></div><div><div>min_x, max_y, max_x, min_y = get_extent(in_files[0])</div><div># calculate output extent from all inputs</div><div>for fn in in_files[1:]:</div><div>    minx, maxy, maxx, miny = get_extent(fn)</div><div>    min_x = min(min_x, minx)</div><div>    max_y = max(max_y, maxy)</div><div>    max_x = max(max_x, maxx)</div><div>    min_y = min(min_y, miny)</div><div><br></div><div>in_ds = gdal.Open(in_files[0])</div><div>gt = in_ds.GetGeoTransform()</div></div><div><br></div><div>When I run this code, I receive error:</div><div><div><font color="#990000"> min_x, max_y, max_x, min_y = get_extent(in_files[0])</font></div><div><font color="#990000"><br></font></div><div><font color="#990000">IndexError: list index out of range</font></div></div><div><font color="#990000"><br></font></div><div><font color="#000000">My<b> in_files</b> are empty. </font></div><div><font color="#000000"><br></font></div><div><font color="#000000">When I change the way of loading data to:</font></div><div><font color="#000000"><br></font></div><div><font color="#000000">in_files = [cv2.imread(file) for file in glob.glob('D:/_work(z pulpitu)/mosaicing/GDAL_test/data/*png')]<br></font></div><div><font color="#000000"><br></font></div><div><font color="#000000">My in_files type is a list with two attributes (nuppy_arrays) byt I get the error:</font></div><div><div style=""><font color="#990000">return _gdal.Open(*args)</font></div><div style=""><font color="#990000"><br></font></div><div style=""><font color="#990000">RuntimeError: not a string</font></div></div><div><font color="#000000"><br></font></div><div><font color="#000000">Can anyone help me with solving this problem?</font></div><div><font color="#000000"><br></font></div><div><font color="#000000">Thanks,</font></div><div><font color="#000000">Ania</font></div></div></div></div></div></div></div>