Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tiftag match error #3085

Closed
lovelj opened this issue Sep 25, 2019 · 2 comments
Closed

tiftag match error #3085

lovelj opened this issue Sep 25, 2019 · 2 comments
Assignees

Comments

@lovelj
Copy link

lovelj commented Sep 25, 2019

i use hadoopMultibandGeoTiffRDD to read a tif. then i got the error

scala.MatchError: (34665,13) (of class scala.Tuple2$mcII$sp)
	at geotrellis.raster.io.geotiff.reader.TiffTagsReader$.readTag(TiffTagsReader.scala:125)
	at geotrellis.raster.io.geotiff.reader.TiffTagsReader$.read(TiffTagsReader.scala:101)
	at geotrellis.raster.io.geotiff.reader.GeoTiffReader$.readGeoTiffInfo(GeoTiffReader.scala:359)
	at geotrellis.spark.io.hadoop.HadoopGeoTiffInfoReader.getGeoTiffInfo(HadoopGeoTiffInfoReader.scala:53)
	at geotrellis.spark.io.GeoTiffInfoReader$$anonfun$1.apply(GeoTiffInfoReader.scala:75)
	at geotrellis.spark.io.GeoTiffInfoReader$$anonfun$1.apply(GeoTiffInfoReader.scala:73)

and tif was uploaded here: https://github.com/lovelj/TestData
(it's a part rar file, you need download all parts of rar file.then upzip the rar file ,you will get a tif)
and gdalinfo output is

Driver: GTiff/GeoTIFF
Files: "tifpath"
Size is 20973, 14016
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 = (110.992711196399995,24.007216846799999)
Pixel Size = (0.000143730400000,-0.000143730400000)
Metadata:
  AREA_OR_POINT=Area
  TIFFTAG_DATETIME=2015:01:25 16:58:51
  TIFFTAG_RESOLUTIONUNIT=2 (pixels/inch)
  TIFFTAG_SOFTWARE=Adobe Photoshop CS6 (Windows)
  TIFFTAG_XRESOLUTION=72
  TIFFTAG_YRESOLUTION=72
Image Structure Metadata:
  INTERLEAVE=PIXEL
Corner Coordinates:
Upper Left  ( 110.9927112,  24.0072168) (110d59'33.76"E, 24d 0'25.98"N)
Lower Left  ( 110.9927112,  21.9926916) (110d59'33.76"E, 21d59'33.69"N)
Upper Right ( 114.0071689,  24.0072168) (114d 0'25.81"E, 24d 0'25.98"N)
Lower Right ( 114.0071689,  21.9926916) (114d 0'25.81"E, 21d59'33.69"N)
Center      ( 112.4999400,  22.9999542) (112d29'59.78"E, 22d59'59.84"N)
Band 1 Block=20973x1 Type=Byte, ColorInterp=Red
Band 2 Block=20973x1 Type=Byte, ColorInterp=Green
Band 3 Block=20973x1 Type=Byte, ColorInterp=Blue

i test the geotrellis code "geotrellis-2.3.1\raster\src\main\scala\geotrellis\raster\io\geotiff\reader\TiffTagsReader.scala"

val ByteBuffer = toMappedByteBuffer(tifpath)

    (ByteBuffer.get.toChar, ByteBuffer.get.toChar) match {
      case ('I', 'I') => ByteBuffer.order(ByteOrder.LITTLE_ENDIAN)
      case ('M', 'M') => ByteBuffer.order(ByteOrder.BIG_ENDIAN)
      case _ => throw new Exception("incorrect byte order")
    }

    val byteReader=ByteBuffer
    val typechar = byteReader.getChar
    val tagsStartPosition=byteReader.getInt.toLong
    val pos1 = byteReader.position(tagsStartPosition.toInt)
    val tagcount=byteReader.getShort

    val GeoKeyDirectoryTag = 34735

    for(tag<- 0 until tagcount){
      val tag = byteReader.getChar.toInt // Tag
      val type1 =byteReader.getChar.toInt // Type
      val count1 = byteReader.getInt          // Count
      val offset1 = byteReader.getInt            // Offset
      if(tag==GeoKeyDirectoryTag){
        println("geokey")
      } else{
        println("this")
      }
      println(tag+"###"+type1)
      (tag,type1) match {
        case (ModelPixelScaleTag, _) =>
        {
          println("right")
        }
        case (ModelTiePointsTag, _) =>
        {println("right")}
        case (GeoKeyDirectoryTag, _) =>
        {println("right")}
        case (_, BytesFieldType) =>
        {println("right")}
        case (_, AsciisFieldType) =>
        {println("right")}
        case (_, ShortsFieldType) =>
        {println("right")}
        case (_, IntsFieldType) =>
        {println("right")}
        case (_, FractionalsFieldType) =>
        {}
        case (_, SignedBytesFieldType) =>
        {}
        case (_, UndefinedFieldType) =>
        {}
        case (_, SignedShortsFieldType) =>
        {}
        case (_, SignedIntsFieldType) =>
        {}
        case (_, SignedFractionalsFieldType) =>
        {}
        case (_, FloatsFieldType) =>
        {}
        case (_, DoublesFieldType) =>
        {}
        case (_, LongsFieldType) =>
        {}
        case (_, SignedLongsFieldType) =>
        {}
        case (_, IFDOffset) =>{}
//          println("here")
        case (_,_)=>{
          println("not implemented")
        }
      }
    }

i found that when (tag,type1) equals (34665,13), code in TiffTagsReader.readTag function will throw matcherror. is it a bug?
i could not use gdal_translate to convert this file to standard tiff file for some reason.
Is there any other solution to this problem?

@pomadchin
Copy link
Member

Hey @lovelj if #3088 works for you, I would like to close this issue and create a more general issue to support all TIFF tags.

@pomadchin
Copy link
Member

Replaced by #3091 and fixed in #3088

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants