Skip to content

Commit

Permalink
Merge pull request #200 from wri/bugfix/afi_gadm_filter
Browse files Browse the repository at this point in the history
GTC-2598 Fix gadm null filter
  • Loading branch information
manukala6 authored Nov 15, 2023
2 parents 0a040b8 + f0ae12f commit 0abc076
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/main/resources/raster-catalog-pro.json
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@
},
{
"name": "sbtn_natural_forests_map",
"source_uri": "s3://gfw-data-lake/sbtn_natural_forests_map/v202305/raster/epsg-4326/{grid_size}/{row_count}/class/gdal-geotiff/{tile_id}.tif"
"source_uri": "s3://gfw-data-lake/sbtn_natural_forests_map/v202310/raster/epsg-4326/{grid_size}/{row_count}/class/gdal-geotiff/{tile_id}.tif"
},
{
"name": "gfwpro_negligible_risk_analysis",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,8 @@ object AFiAnalysis extends SummaryAnalysis {
val summaryDF = AFiAnalysis.aggregateResults(
AFiDF
.getFeatureDataFrame(summaryRDD, spark)
.filter(!$"gadm_id".contains("null"))
.withColumn(
"gadm_id", when(col("location_id") =!= -1|| col("gadm_id").contains("null"), lit("") ).otherwise(col("gadm_id"))
"gadm_id", when(col("location_id") =!= -1, lit("") ).otherwise(col("gadm_id"))
)
.groupBy($"list_id", $"location_id", $"gadm_id")
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,14 @@ object AFiSummary {
val naturalForestCategory: String = raster.tile.sbtnNaturalForest.getData(col, row)
val negligibleRisk: String = raster.tile.negligibleRisk.getData(col, row)

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

// pixel Area
val lat: Double = raster.rasterExtent.gridRowToMap(row)
Expand Down

0 comments on commit 0abc076

Please sign in to comment.