Hello! I am currently trying to get GeoTrellis to work in Databricks, but I am facing some issue(s). I have installed geotrellis-spark and geotrellis-raster (versions 3.6.0) from the Databrick's UI through Maven. I have the following code:
val rasterFilePath = "path/to/my.tif"
val geoTiff = GeoTiffReader.readSingleband(rasterFilePath)
But I'm getting
java.lang.NoClassDefFoundError: Could not initialize class geotrellis.raster.io.geotiff.TiffType$ error. I noticed that someone else had this problem here before, but unfortunately the solution was never posted here. Any clues what I'm doing wrong here?
hey @pomadchin I'm sorry but I'm still having some trouble with my mosaic task :( . I wrote this starting from your suggestion:
val firstTiff = GeoTiffReader .readSingleband("...") val combinedExtent = firstExtent.expandToInclude(secondExtent) val re = RasterExtent(combinedExtent, firstTiff.cellSize) val newRaster = Raster(ArrayTile.alloc(firstTiff.cellType, re.cols, re.rows), re.extent) val mergedRaster = newRaster.merge(Raster(firstRaster.tile, firstExtent))
I can't understand why but the
merge function with that configuration is not resolved. I tried with other two rasters read form files and the function is correctly resolved. The only difference I noticed between the created raster and the read ones is that the
geotrellis.raster.DoubleUserDefinedNoDataArrayTile produces a
merge while the read raster have a inner
geotrellis.raster.io.geotiff.Float64GeoTiffTile. Did I mess up something with imports and packages?
Thanks in advance
hey @santocp94 what to you mean by not correctly resolved?
I tried with different configurations but an error occurred:
value merge is not a member of geotrellis.raster.Raster[geotrellis.raster.MutableArrayTile]
value merge is not a member of geotrellis.raster.Raster[geotrellis.raster.ArrayTile]
Exception in thread "main" java.lang.ClassCastException: class geotrellis.raster.DoubleUserDefinedNoDataArrayTile cannot be cast to class geotrellis.raster.MultibandTile
withMultibandRasterMergeMethod. I also tried to re-import everything from scratch but the problem persists
import geotrellis.raster._should be able to get it into the scope
geotrellis.raster.merge.Implicits._but I can recommend it only for test / dev purposes
@epursiai just create an uber jar and shade them; check out https://github.com/sbt/sbt-assembly#shading
we usually use sbt-assembly plugin for these purposes; The example of usage in the gt build code is here https://github.com/locationtech/geotrellis/blob/master/project/Settings.scala#L559-L569
So in your case along with the circe rule you would need shapeless and cats kernel shading:
ShadeRule.rename("io.circe.**" -> s”$shadePackage.io.circe.@1").inAll ShadeRule.rename("shapeless.**" -> s"$shadePackage.shapeless.@1").inAll, ShadeRule.rename("cats.kernel.**" -> s"$shadePackage.cats.kernel.@1").inAll
$ sbt $ project example $ // run
Hey @chdsb I don’t think we have
polygonalHistogramDouble method anymore; we have a general polygonalSummary API with visitors passed inside that can be controlled by you
RasterExtent(extent, cellSize).gridToMap(col, row) // the result is a tuple of geospatial coordinates in the extent projection