3

When you download a large image from Google Earth Engine, it is in multiple small images. Each sub-image name contains the x_min and y_min coordinates of that image. enter image description here

It is described here - https://developers.google.com/earth-engine/image_upload#tfrecord

How to join all these .tif files into one .tif file in right order by using a Python script.

1
  • take a look at this, you can merge the tiffs like this, if you are merging a complete set I don't think the order would be an issue. gis.stackexchange.com/questions/56985/… Commented Nov 5, 2019 at 11:41

2 Answers 2

6

Merging tiles can be accomplished using:

  1. GDAL's gdal_merge. An example is given in calling gdal_merge into python script
  2. Rasterio's rasterio.merge. An example is given in Rasterio: tool for creating mosaic?

It is not necessary to order the tiles in a specific way... they are non-overlapping.

1
  • Are these tiles connected automatically in the right order? I mean if the correct order of tiles in 1-2-3-4 horizontally, I hope they will not be connected in some random fashion. All tiles are non-overlapping but adjoining (cab be vertical or horizontal) Commented Nov 6, 2019 at 17:08
0

If you want to order the tif files by coordinate pair this will do it.

from osgeo import gdal tiffiles=["basefilename-99-100.tif","basefilename-98.7-200.tif","basefilename-101-300.tif","basefilename-100.25-400.tif","basefilename-99.925-500.tif","basefilename-97.552-100.tif"] coordarray=[] tifdict={} for tf in tiffiles: ds = gdal.Open(tf) w = ds.RasterXSize h = ds.RasterYSize gtrans = ds.GetGeoTransform() minx = gtrans[0] miny = gtrans[3] + w*gtrans[4] + h*gtrans[5] # splittifname=tf.split("-") coords=(minx,miny) coordarray.append(coords) tifdict[coords]=tf coordarray=sorted(coordarray,key=lambda k:(k[0],k[1])) for coord in coordarray: ### DO STUFF TO COMBINE THE RASTER TO A STACK print(tifdict[coord]) 

I don't think I explain myself clearly, this will put your tif in order by coordinate from min x min y of the set, then you can merge or place the file names in order on .txt file and batch process. I change the code to use the coord value in the tif file instead of value in file name but I have not had a chance to test you may need to declare the spatial reference somewhere.

1
  • I want to combine tiff files to make one big tif file. They should be combined at their right places as per coordinates, not just random place. Commented Nov 5, 2019 at 13:12

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.