Skip to content

Commit

Permalink
allow to choose TCD year
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Maschler <tmaschler@wri.org>
  • Loading branch information
Thomas Maschler committed Jul 22, 2019
1 parent 57af860 commit a54746b
Show file tree
Hide file tree
Showing 20 changed files with 10 additions and 521 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ object TreeLossRDD extends AnalysisRDD {

def runPolygonalSummary(raster: Raster[TILE],
geometry: Geometry,
options: Rasterizer.Options): SUMMARY = {
options: Rasterizer.Options,
tcdYear: Int = 2000): SUMMARY = {
raster.polygonalSummary(
geometry = geometry,
emptyResult = new TreeLossSummary(),
Expand Down
4 changes: 3 additions & 1 deletion src/main/scala/org/globalforestwatch/treecoverloss/DF.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ object DF {
Seq(
"feature_id",
"threshold",
"tcd_year",
"primary_forest",
"extent_2000",
"extent_2010",
Expand All @@ -32,6 +33,7 @@ object DF {
df.select(
$"feature_id",
$"threshold",
$"tcd_year",
$"primary_forest",
$"extent_2000",
$"extent_2010",
Expand Down Expand Up @@ -172,7 +174,7 @@ object DF {
def primaryForestFilter(include: Boolean)(df: DataFrame): DataFrame = {
if (include) df
else {
df.groupBy($"feature_id", $"threshold")
df.groupBy($"feature_id", $"threshold", $"tcd_year")
.agg(
sum("total_area") as "total_area",
sum("extent_2000") as "extent_2000",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ object TreeLossRDD extends AnalysisRDD {
tcdYear: Int): SUMMARY = {
raster.polygonalSummary(
geometry = geometry,
emptyResult = new TreeLossSummary(),
emptyResult = new TreeLossSummary(tcdYear),
options = options
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package org.globalforestwatch.treecoverloss
case class TreeLossRow(
featureId: Int,
threshold: Int,
tcdYear: Int,
primaryForest: Boolean,
extent2000: Double,
extent2010: Double,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ object TreeLossSparkSession {

val localConf: SparkConf = conf
.setIfMissing("spark.master", "local[*]")
.set("spark.driver.bindAddress", "127.0.0.1")

implicit val spark: SparkSession = try {
SparkSession.builder.config(conf).getOrCreate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ object TreeLossSummaryMain
TreeLossRow(
id.cell_id,
lossDataGroup.threshold,
tcdYear,
lossDataGroup.primaryForest,
lossData.extent2000,
lossData.extent2010,
Expand All @@ -155,6 +156,7 @@ object TreeLossSummaryMain
.toDF(
"feature_id",
"threshold",
"tcd_year",
"primary_forest",
"extent_2000",
"extent_2010",
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit a54746b

Please sign in to comment.