0

I have issues with some GeoTIFF raster files with positive NS resolution (North-South)

gdalinfo gave me this:

Pixel Size = (1.000000000000000,1.000000000000000)

I run into all kind of problem with gdal_merge or gdalbuildvrt when trying to mosaic a set of files.

I get error messages like:

gdalbuildvrt does not support positive NS resolution

The solution should be to flip the whole thing by moving the vertical origin to other side of the N-S extent and invert Pixel Size/resolution to a negative value, as almost all GDAL tools expect:

Pixel Size = (1.000000000000000,-1.000000000000000)

How is this best achieved? (Preferably with exiting GDAL command line tools)

3
  • 1
    If image is not rotated one alternative is to use use gdal_translate with -a_ullr gdal.org/gdal_translate.html. – user30184 Nov 14 '17 at 20:18
  • Thanks, that fixed the the problem with the VRT builder, had to switch uly and lry there, to get proper geoTransform parameters. Yet the images also appeared flipped after that procedure. Had to flip them with Imagemagick mogrify -flip after adding them to the VRT. Feels more than a bit hacky, would be more convenient if gdal_translate -outsize would allow for negative percentages to effectively mirror images along an axis. – mxfh Nov 15 '17 at 1:06
  • 1
    If you image did look good with positive pixel size for y axis then it has originally written as flipped. That arrangement means "write the first line of pixels, then the next above it". If the source image has some south-up EPSG code you can also reproject image to a north-up system. – user30184 Nov 15 '17 at 5:13
3

I had the same problem. I used gdalwarp to correct the NS resolution of xyz files and converted them to tif (in one step). Here is my solution in bash:

for file in *.xyz; 
    # adjust NS resolution 
    do echo "$file"; gdalwarp -t_srs EPSG:4647 -overwrite "$file" "$(basename "$file" .xyz).tif"
done
0

Or if you only have tiffs that need correcting and need small files to work with:

gdalwarp -t_srs EPSG:EPSGcode -of GTiff -co "COMPRESS=LZW" -co "BIGTIFF=YES" "input.tif" "output.tif"

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.