0

I am using gdal to try to clip bioclim geotif file to a smaller size and am finding that the resulting output file has no meaningful data:

gdal_translate -projwin 114.5 -33.0 120.0 -35.5 -of GTiff 9.tif clip_9.tif

I may be doing something wrong that is simple but I'm not sure what. Any ideas? Cheers, Steve

SteveResearch
  • 119
  • 3
  • 6
  • Check the order of your arguments to -projwin. Should be: [-projwin ulx uly lrx lry] Or possibly the signs on your values... –  Feb 24 '16 at 22:34
  • I have checked the order of the -projwin arguments and the signs are fine. The clipped area is well within the bounds of the original file. Gdalinfo gives good info for the source file but the info for the output file is truncated with no 'min' 'max' or statistics values. Any help gratefully received as I am keen to get on with the next stages. – SteveResearch Feb 25 '16 at 14:42
  • The file won't have stats by default, run gdalinfo -stats to generate them. Have you opened the output in a GIS and viewed the results? Are you sure it's blank? –  Feb 25 '16 at 16:59
  • I have seen the same problem. I input `-projwin -122.55 46.5 -122.0 46.0` and I get the error `Error: Computed -srcwin 329062 131509 0 0 has negative width and/or height`. If I try reversing the coordinates, I get an identical error message. – craigim Jan 11 '17 at 20:48

1 Answers1

2

This question really belongs over in the GIS Stack Exchange.

I was getting a similar error when trying to crop an image in QGIS. When I input -projwin -122.55 46.5 -122.0 46.0, I got the error Computed -srcwin 329062 131509 0 0 has negative width and/or height.

Using the information in this thread, the problem is that the projection in your source tiff doesn't allow for a nice square cropping. You need to first use gdalwarp to convert your tiff to a projection that allows such a square cropping. I got it to work just by converting to EPSG:4326, which is the wgs84 projection. Cropping the warped tiff worked just fine.

Community
  • 1
  • 1
craigim
  • 3,884
  • 1
  • 22
  • 42