Skip to content

Commit

Permalink
Only read gadm raster if kwargs("getRasterGadm") is set.
Browse files Browse the repository at this point in the history
Still need to make GfwProDashboardGridSources/Tile to be lazy.
  • Loading branch information
danscales committed Jul 16, 2024
1 parent 622d386 commit d433d3d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,13 @@ object GfwProDashboardAnalysis extends SummaryAnalysis {
}
.flatMap { enrichedRDD =>
val fireStatsRDD = fireStats(enrichedRDD, fireAlertRDD, spark)
enrichedRDD.collect().foreach(println)
val tmp = enrichedRDD.map { case Location(id, geom) => Feature(geom, id) }
val validatedSummaryStatsRdd = GfwProDashboardRDD(tmp, GfwProDashboardGrid.blockTileGrid, kwargs)
// This is where the main analysis happens, including calling
// GfwProDashboardSummary.getGridVisitor.visit on each pixel.
val validatedSummaryStatsRdd = GfwProDashboardRDD(tmp,
GfwProDashboardGrid.blockTileGrid,
kwargs + ("getRasterGadm" -> !doGadmIntersect))
ValidatedWorkflow(validatedSummaryStatsRdd).mapValid { summaryStatsRDD =>
summaryStatsRDD
//.flatMapValues(_.toGfwProDashboardData())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,19 @@ object GfwProDashboardSummary {
val naturalForestCategory: String = raster.tile.sbtnNaturalForest.getData(col, row)
val jrcForestCover: Boolean = raster.tile.jrcForestCover.getData(col, row)

val gadmAdm0: String = raster.tile.gadm0.getData(col, row)
// Skip processing this pixel if gadmAdm0 is empty
if (gadmAdm0 == "") {
return
val gadmId: String = if (kwargs("getRasterGadm") == true) {
val gadmAdm0: String = raster.tile.gadm0.getData(col, row)
// Skip processing this pixel if gadmAdm0 is empty
if (gadmAdm0 == "") {
return
}
val gadmAdm1: Integer = raster.tile.gadm1.getData(col, row)
val gadmAdm2: Integer = raster.tile.gadm2.getData(col, row)
s"$gadmAdm0.$gadmAdm1.$gadmAdm2"
} else {
""
}
val gadmAdm1: Integer = raster.tile.gadm1.getData(col, row)
val gadmAdm2: Integer = raster.tile.gadm2.getData(col, row)
val gadmId: String = s"$gadmAdm0.$gadmAdm1.$gadmAdm2"


val groupKey = GfwProDashboardRawDataGroup(gadmId, integratedAlertDateAndConf,
integratedAlertCoverage,
Expand Down

0 comments on commit d433d3d

Please sign in to comment.