I'm using gdal_grid to convert a shapefile with points and I would like to set the pixel size of the output. I've only found the -outsize flag that lets me set the size of the output raster, but I would prefer to just say that I want 2 x 2 m pixels and let the tool figure out the size of the output raster.

With gdal_rasterize you can set the -tr flag, but that tool won't do interpolation.


GDAL version <3.2

To set the pixel size in gdal_grid, you have to play with the following options:

-txe xmin xmax:

Set georeferenced X extents of output file to be created.

-tye ymin ymax:

Set georeferenced Y extents of output file to be created.

-outsize xsize ysize:

Set the size of the output file in pixels and lines.


xcellsize = (xmax - xmin) / xsize
ycellsize = (ymax - ymin) / ysize

New in GDAL version 3.2.

-tr xres yres

Set output file resolution (in target georeferenced units). Note that -tr just works in combination with a valid input from -txe and -tye

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.