Skip to content

Commit

Permalink
Fix k interpolate for grid to raster. (#320)
Browse files Browse the repository at this point in the history
  • Loading branch information
Milos Colic authored Mar 21, 2023
1 parent 050e43a commit 53677ba
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,6 @@ object H3IndexSystem extends IndexSystem(LongType) with Serializable {
h3.geoToH3(geo.lat, geo.lng, h3.h3GetResolution(id))
}

override def distance(cellId: Long, cellId2: Long): Long = h3.h3Distance(cellId, cellId2).toLong
override def distance(cellId: Long, cellId2: Long): Long = Try(h3.h3Distance(cellId, cellId2)).map(_.toLong).getOrElse(0)

}
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ class RasterAsGridReader(sparkSession: SparkSession) extends MosaicDataFrameRead
rasterDf
.withColumn("origin_cell_id", col("cell_id"))
.withColumn("cell_id", explode(grid_cellkring(col("origin_cell_id"), k)))
.withColumn("weight", lit(k + 1) - grid_distance(col("origin_cell_id"), col("cell_id)")))
.withColumn("weight", lit(k + 1) - grid_distance(col("origin_cell_id"), col("cell_id")))
.groupBy("band_id", "cell_id")
.agg(weighted_sum("measure", "weight"))
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class RasterAsGridReaderTest extends MosaicSpatialQueryTest with SharedSparkSess
.option("tileSize", "10")
.option("readSubdataset", "true")
.option("subdataset", "1")
.option("kRingInterpolation", "3")
.option("kRingInterpolate", "3")
.load(filePath)
.select("measure")
.queryExecution
Expand All @@ -46,7 +46,7 @@ class RasterAsGridReaderTest extends MosaicSpatialQueryTest with SharedSparkSess
.option("combiner", "min")
.option("retile", "true")
.option("tileSize", "10")
.option("kRingInterpolation", "3")
.option("kRingInterpolate", "3")
.load(filePath)
.select("measure")
.take(1)
Expand All @@ -64,7 +64,7 @@ class RasterAsGridReaderTest extends MosaicSpatialQueryTest with SharedSparkSess
.format("raster_to_grid")
.option("combiner", "max")
.option("tileSize", "10")
.option("kRingInterpolation", "3")
.option("kRingInterpolate", "3")
.load(filePath)
.select("measure")
.take(1)
Expand Down Expand Up @@ -129,9 +129,9 @@ class RasterAsGridReaderTest extends MosaicSpatialQueryTest with SharedSparkSess
.format("invalid")
.load(filePath)

an[Exception] should be thrownBy MosaicContext.read
noException should be thrownBy MosaicContext.read
.format("raster_to_grid")
.option("kRingInterpolate", "3") // Only works on Databricks Photon Cluster.
.option("kRingInterpolate", "3")
.load(filePath)

}
Expand Down

0 comments on commit 53677ba

Please sign in to comment.