-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
"raster_to_grid" [iterim] "toTif" option.
- Loading branch information
1 parent
c5bac6d
commit 83268eb
Showing
20 changed files
with
878 additions
and
397 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/bash | ||
|
||
# run from within docker container | ||
# run from the repo root ('mosaic') level | ||
|
||
# [1] delete existing jars in python dir | ||
rm python/mosaic/lib/*.jar | ||
|
||
# [2] package | ||
mvn package -DskipTests=true | ||
|
||
# [3] build | ||
cd python && python3 -m build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
src/main/scala/com/databricks/labs/mosaic/core/raster/operator/TranslateToGTiff.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package com.databricks.labs.mosaic.core.raster.operator | ||
|
||
import com.databricks.labs.mosaic.core.raster.gdal.{RasterGDAL, RasterWriteOptions} | ||
import com.databricks.labs.mosaic.core.raster.operator.gdal.GDALTranslate | ||
import com.databricks.labs.mosaic.functions.ExprConfig | ||
import com.databricks.labs.mosaic.gdal.MosaicGDAL | ||
import com.databricks.labs.mosaic.utils.PathUtils | ||
|
||
import scala.util.Try | ||
|
||
object TranslateToGTiff { | ||
|
||
/** | ||
* Translate a RasterGDAL [[org.gdal.gdal.Dataset]] to GeoTiff. | ||
* | ||
* @param inRaster | ||
* [[RasterGDAL]] to translate. | ||
* @param exprConfigOpt | ||
* Option [[ExprConfig]] | ||
* @return | ||
* New RasterGDAL translated to GeoTiff. | ||
*/ | ||
def compute(inRaster: RasterGDAL, exprConfigOpt: Option[ExprConfig]): RasterGDAL = { | ||
|
||
// try to hydrate the provided raster | ||
inRaster.getDatasetOpt() match { | ||
case Some(dataset) => | ||
if (Try(dataset.GetSpatialRef()).isFailure || dataset.GetSpatialRef() == null) { | ||
// if SRS not set, try to set it to WGS84 | ||
Try(dataset.SetSpatialRef(MosaicGDAL.WSG84)) | ||
} | ||
val tifPath = PathUtils.createTmpFilePath("tif", exprConfigOpt) | ||
// Modify defaults | ||
// - essentially `RasterWriteOptions.GTiff` | ||
// with the SRS set. | ||
val outOptions = RasterWriteOptions( | ||
crs = dataset.GetSpatialRef() // default - MosaicGDAL.WSG84 | ||
) | ||
|
||
GDALTranslate.executeTranslate( | ||
tifPath, | ||
inRaster, | ||
command = s"""gdal_translate""", | ||
outOptions, | ||
exprConfigOpt | ||
) | ||
case _ => | ||
val result = RasterGDAL() // <- empty raster | ||
result.updateLastCmd("'gdal' format -> option 'toTif'") | ||
result.updateError("Dataset is invalid (prior to tif convert") | ||
result | ||
} | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.