1

I am trying to use gdal_merge.py to create a mosaic from a set of geotiffs, however the command fails with the error message: "ERROR 1: Attempt to create -3510x1817 dataset is illegal,sizes must be larger than zero.". I have tried with gdalbuildvrt, but the .vrt also has negative dimensions.

The source geotiffs are not north-south aligned, but instead were generated from .jpgs using

gdal_translate -a_srs WGS84 -a_ullr tlx tly brx bry src dst

with the bounds calculated from the (known) image footprint extents, and so have a range of different orientations.

The geotiffs I'm trying to mosaic are here: https://www.dropbox.com/s/hvhhpsrb913l3xb/geotiffs.zip?dl=0

gdalinfo on a sample geotiff:

Driver: GTiff/GeoTIFF
Files: geo_pict20140910_131133_0.tif
Size is 1616, 1080
Coordinate System is:
GEOGCS["WGS 84",
    DATUM["WGS_1984",
        SPHEROID["WGS 84",6378137,298.257223563,
            AUTHORITY["EPSG","7030"]],
        AUTHORITY["EPSG","6326"]],
    PRIMEM["Greenwich",0],
    UNIT["degree",0.0174532925199433],
    AUTHORITY["EPSG","4326"]]
Origin = (-121.459108654999994,38.582958816199998)
Pixel Size = (-0.000000523938738,-0.000000765216574)
Metadata:
  AREA_OR_POINT=Area
  EXIF_BrightnessValue=(4.22031)
  EXIF_ColorSpace=1
  EXIF_ComponentsConfiguration=0x1 0x2 0x3 00
  EXIF_CompressedBitsPerPixel=(3)
  EXIF_Contrast=0
  EXIF_CustomRendered=0
  EXIF_DateTime=2014:09:10 13:11:32
  EXIF_DateTimeDigitized=2014:09:10 13:11:32
  EXIF_DateTimeOriginal=2014:09:10 13:11:32
  EXIF_DigitalZoomRatio=(1)
  EXIF_ExifVersion=0230
  EXIF_ExposureBiasValue=(0)
  EXIF_ExposureMode=0
  EXIF_ExposureProgram=4
  EXIF_ExposureTime=(0.001)
  EXIF_FileSource=0x3
  EXIF_Flash=16
  EXIF_FlashpixVersion=0100
  EXIF_FNumber=(4)
  EXIF_FocalLength=(16)
  EXIF_FocalLengthIn35mmFilm=24
  EXIF_GPSAltitude=(67)
  EXIF_GPSAltitudeRef=00
  EXIF_GPSImgDirection=(95)
  EXIF_GPSImgDirectionRef=T
  EXIF_GPSLatitude=(38) (34) (57.16)
  EXIF_GPSLatitudeRef=N
  EXIF_GPSLongitude=(121) (27) (34.32)
  EXIF_GPSLongitudeRef=W
  EXIF_GPSVersionID=0x2 0x3 00 00
  EXIF_Interoperability_Index=R98
  EXIF_Interoperability_Version=0x30 0x31 0x30 0x30
  EXIF_ISOSpeedRatings=2500
  EXIF_LightSource=0
  EXIF_Make=SONY
  EXIF_MaxApertureValue=(2.96875)
  EXIF_MeteringMode=5
  EXIF_Model=NEX-5T
  EXIF_Orientation=1
  EXIF_PixelXDimension=1616
  EXIF_PixelYDimension=1080
  EXIF_ResolutionUnit=2
  EXIF_Saturation=0
  EXIF_SceneCaptureType=0
  EXIF_SceneType=0x1
  EXIF_Sharpness=0
  EXIF_Software=NEX-5T v1.01
  EXIF_WhiteBalance=0
  EXIF_XResolution=(350)
  EXIF_YCbCrPositioning=2
  EXIF_YResolution=(350)
Image Structure Metadata:
  INTERLEAVE=PIXEL
Corner Coordinates:
Upper Left  (-121.4591087,  38.5829588) (121d27'32.79"W, 38d34'58.65"N)
Lower Left  (-121.4591087,  38.5821324) (121d27'32.79"W, 38d34'55.68"N)
Upper Right (-121.4599553,  38.5829588) (121d27'35.84"W, 38d34'58.65"N)
Lower Right (-121.4599553,  38.5821324) (121d27'35.84"W, 38d34'55.68"N)
Center      (-121.4595320,  38.5825456) (121d27'34.32"W, 38d34'57.16"N)
Band 1 Block=1616x1 Type=Byte, ColorInterp=Red
Band 2 Block=1616x1 Type=Byte, ColorInterp=Green
Band 3 Block=1616x1 Type=Byte, ColorInterp=Blue
  • 1
    Try translating into a different format (like HFA) before mosaic. Is it possible you're mixing projected and geographic data? If so use gdal warp to project to the same spatial reference before proceeding. (I can't get to dropbox because of I.T. restrictions to see the images). – Michael Stimson Apr 16 '15 at 1:05
  • Thanks for the reply; changing to hfa did enable the merge to proceed - could you explain why that works rather than with a conversion to geotiffs? – jeremyeastwood Apr 16 '15 at 1:23
  • 1
    ERDAS Imagine doesn't support a lot of things that TIFFs do so translate rectifies the images and drops tags that are unsupported (not needed) - basically it cleans the image. For this reason, and because most of the sofware I use supports them, I use .img (HFA) images as my 'lowest common denominator' for raster, much like shapefiles for vector. – Michael Stimson Apr 16 '15 at 1:32
  • great, thanks for the explanation - much appreciated – jeremyeastwood Apr 16 '15 at 1:43
0

As commented by @MichaelMiles-Stimson:

Try translating into a different format (like HFA) before mosaic. Is it possible you're mixing projected and geographic data? If so use gdal warp to project to the same spatial reference before proceeding.

and:

ERDAS Imagine doesn't support a lot of things that TIFFs do so translate rectifies the images and drops tags that are unsupported (not needed) - basically it cleans the image. For this reason, and because most of the sofware I use supports them, I use .img (HFA) images as my 'lowest common denominator' for raster, much like shapefiles for vector.

| improve this answer | |

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.