I have a raster that needs to be split into tiles (each tile a new raster). I have a Shapefile with multiple polygons (these polygons are how I want the raster split).

How do I do this using GDAL?

  • 2
    Plenty. Possibly the easiest would be to add Xmin, Ymin, Xmax and Ymax fields for each grid then populate with field calculator, export to Text and make into a batch file. Do you have any python/coding experience? This can be done with existing tools and a bit of find&replace but would (possibly) be easier to script - or at least less typing. – Michael Stimson Jul 14 '15 at 4:02

You can split the image to small tiles by the size of the (tile_size) using a code like this one:

file_path,file_name = {{put-yor-path-and-name-here}}
gdal_img = gdal.Open(img)

RasterXSize = gdal_img.RasterXSize
RasterYSize = gdal_img.RasterYSize
transform = gdal_img.GetGeoTransform()
minX = transform[0]
maxY = transform[3]
img_pixelWidth = transform[1]

img_out = str(path) + "\\" + str(out_img_name) + r".TIF"          

  • this will cut small tile from the big image given the parameters startX = the coord of start splitting and sizeX how many pix to cut – Moshe Yaniv Oct 22 '17 at 9:12

You can use the Select by Attributes tool to select all of the raster features inside the shapefiles. Then right click on the raster in the Table of Contents and go to Data > Export to CAD.

  • This answer is not correct. If you are selecting features within features in the shape file you would use select by location (Vector>research tools>select by location) but that works for vector layers and the question regards splitting raster layers – Sethinacan Jan 22 '16 at 10:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.