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

GDALRasterSource unable to read PAM metadata files #105

Open
CloudNiner opened this issue Dec 7, 2020 · 2 comments
Open

GDALRasterSource unable to read PAM metadata files #105

CloudNiner opened this issue Dec 7, 2020 · 2 comments
Labels
bug Something isn't working

Comments

@CloudNiner
Copy link
Contributor

CloudNiner commented Dec 7, 2020

GDALRasterSource, using these bindings, throws an error when attempting to read metadata for files that use the PAM xml metadata specification.

Open a GeoTrellis 3.5.1+ SBT console:

cd path/to/geotrellis
./sbt "project gdal"
> console

Then try to read metadata of a tiff with external PAM metadata using GDALRasterSource

scala> import geotrellis.raster.gdal.GDALRasterSource
scala> val rs = GDALRasterSource("s3://aviris-data/test/f130329t01p00r06_corr_v1.tiff")
scala> rs.metadata
geotrellis.raster.gdal.MalformedProjectionException: Unable to get the metadata. GDAL Error Code: 1
  at geotrellis.raster.gdal.GDALDataset$.getMetadata$extension3(GDALDataset.scala:73)
  at geotrellis.raster.gdal.GDALDataset$.$anonfun$getMetadata$1(GDALDataset.scala:61)
  at scala.collection.immutable.List.map(List.scala:293)
  at geotrellis.raster.gdal.GDALDataset$.getMetadata$extension1(GDALDataset.scala:61)
  at geotrellis.raster.gdal.GDALMetadata$.apply(GDALMetadata.scala:49)
  at geotrellis.raster.gdal.GDALRasterSource.metadata$lzycompute(GDALRasterSource.scala:59)
  at geotrellis.raster.gdal.GDALRasterSource.metadata(GDALRasterSource.scala:59)
  ... 36 elided

See:

  • s3://aviris-data/test/f130329t01p00r06_corr_v1.tiff
  • s3://aviris-data/test/f130329t01p00r06_corr_v1.tiff.aux.xml

I'm able to read all metadata for this COG with gdalinfo, the Python GDAL bindings, and Rasterio. For example, gdalinfo /vsis3/aviris-data/test/f130329t01p00r06_corr_v1.tiff prints all metadata contained in associated xml file.

@pomadchin pomadchin added the bug Something isn't working label Dec 7, 2020
@pomadchin
Copy link
Member

pomadchin commented Dec 7, 2020

Probably connected with #70

@pomadchin
Copy link
Member

pomadchin commented Dec 7, 2020

It looks like the issue happens on this line when we try to access band 0 metadata:

import geotrellis.raster.gdal._
val ds = GDALDataset("/vsis3/aviris-data/test/f130329t01p00r06_corr_v1.tiff")

ds.getAllMetadata(GDALDataset.SOURCE, 0)

//> geotrellis.raster.gdal.MalformedProjectionException: Unable to get the metadata. GDAL Error Code: 1
//   at geotrellis.raster.gdal.GDALDataset$.getMetadata$extension3(GDALDataset.scala:73)
//   at geotrellis.raster.gdal.GDALDataset$.getMetadata$extension2(GDALDataset.scala:63)
//   at geotrellis.raster.gdal.GDALDataset$.$anonfun$getAllMetadata$1(GDALDataset.scala:37)
//   at scala.collection.immutable.List.map(List.scala:293)
//   at geotrellis.raster.gdal.GDALDataset$.getAllMetadata$extension1(GDALDataset.scala:37)
//   ... 36 elided

However the following part still works:

import geotrellis.raster.gdal._

val ds = GDALDataset("/vsis3/aviris-data/test/f130329t01p00r06_corr_v1.tiff")

(1 until ds.bandCount).toList.map(ds.getMetadata(GDALDataset.SOURCE, GDALMetadataDomain.ALL, _))
//>: List[Map[geotrellis.raster.gdal.GDALMetadataDomain,Map[String,String]]] = List(
//   Map( -> Map(wavelength -> 365.9136593, wavelength_units -> Nanometers)), 
//   Map( -> Map(wavelength -> 375.5776593, wavelength_units -> Nanometers)), 
//   Map( -> Map(wavelength -> 385.2466593, wavelength_units -> Nanometers)), 
//   Map( -> Map(wavelength -> 394.9196593, wavelength_units -> Nanometers)), 
//   Map( -> Map(wavelength -> 404.5966593, wavelength_units -> Nanometers)), 
//   Map( -> Map(wavelength -> 414.2786593, wavelength_units -> Nanometers)), 
//   Map( -> Map(wavelength -> 423.9646593, wavelength_units -> Nanometers)), 
//   Map( -> Map(wavelength -> 433.6546593, wavelength_units -> Nanometers)), 
//   Map( -> Map(wavelength -> 443.3496593, wavelength_units -> Nanometers)), 
//   Map( -> Map(wavelength -> 45...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants