Skip to content

Commit

Permalink
Merge pull request #192 from wri/bugfix/afi_ignore_certain_ids
Browse files Browse the repository at this point in the history
GTC-2570 Filter out rows not requiring analysis
  • Loading branch information
manukala6 authored Sep 27, 2023
2 parents 995cd81 + d9391b7 commit ab4e45b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ 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"))
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ import org.apache.sedona.core.spatialRDD.SpatialRDD
import org.globalforestwatch.config.GfwConfig
import org.globalforestwatch.features._
import org.locationtech.jts.geom.Geometry
import cats.data.Validated.Valid


object AFiCommand extends SummaryCommand {

val afiCommand: Opts[Unit] = Opts.subcommand(
name = AFiAnalysis.name,
help = "Compute summary statistics for GFW Pro Dashboard."
) {
) (
(
defaultOptions,
featureFilterOptions,
Expand All @@ -30,14 +32,18 @@ object AFiCommand extends SummaryCommand {

runAnalysis { implicit spark =>
val featureRDD = ValidatedFeatureRDD(default.featureUris, default.featureType, featureFilter, default.splitFeatures)
val filteredFeatureRDD = featureRDD.filter{
case Valid((GfwProFeatureId(_, locationId), _)) => locationId != -2
case _ => true
}

AFiAnalysis(
featureRDD,
filteredFeatureRDD,
default.featureType,
spark,
kwargs
)
}
}
}
)
}

0 comments on commit ab4e45b

Please sign in to comment.