[GIS] gdal_translate with srcwin and center reference point

gdal-translate

i want to use subset a large raster image using gdal_translate with srcwin parameter
but i want also to give some reference point to be at the center of the output file .

so if the output file size is 2000X2000 pixel for exemple, i want that my given point(lat/lon) to be at the center

How can this be achieved?

Best Answer

Instead of using -srcwin, try using -projwin. -projwin takes the form -projwin ulx uly lrx lry and works in georeferenced coordinates, so if you know your center point and know the size (2000x2000 pixels) it is very simple to work out the values ulx uly lrx lry relative to your center.