-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #238 from wri/gtc-2826
GTC-2826 Colombia-specific analysis in forest_change_diagnostic
- Loading branch information
Showing
24 changed files
with
222 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,4 +54,3 @@ nohup.out | |
derby.log | ||
metastore_db/ | ||
*.log | ||
*.tsv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
src/main/scala/org/globalforestwatch/layers/ColFronteraAgricola.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package org.globalforestwatch.layers | ||
|
||
import org.globalforestwatch.grids.GridTile | ||
|
||
// Colombia classification of all its lands into areas where agricultural activity is | ||
// allowed, or is conditional, or is fully restricted. The classification strings are | ||
// intended to be parsed and used directly by the front-end (so front end doesn't | ||
// have to have country-specific information in it). | ||
case class ColFronteraAgricola(gridTile: GridTile, kwargs: Map[String, Any]) extends StringLayer with OptionalILayer { | ||
val datasetName = "col_frontera_agricola" | ||
val uri: String = uriForGrid(gridTile, kwargs) | ||
|
||
def lookup(value: Int): String = value match { | ||
case 1 => "No condicionado;Frontera agricola nacional" | ||
case 2 => "Condicionado;Ambiental" | ||
case 3 => "Condicionado;Ambiental/Riesgo de desastres" | ||
case 4 => "Condicionado;Ambiental/Riesgo de desastres/Étnico-Cultural'" | ||
case 5 => "Condicionado;Ambiental/Étnico-Cultural" | ||
case 6 => "Condicionado;Gestión riesgo de desastres" | ||
case 7 => "Condicionado;Riesgo de desastres/Étnico-Cultural" | ||
case 8 => "Condicionado;Étnico-Cultural" | ||
case 9 => "Zona restricción;Restricciones acuerdo cero deforestación" | ||
case 10 => "Zona restricción;Restricciones legales" | ||
case 11 => "Zona restricción;Restricciones técnicas (Áreas no agropecuarias)" | ||
case _ => "" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
...h/summarystats/forest_change_diagnostic/ForestChangeDiagnosticDataDoubleTwoCategory.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package org.globalforestwatch.summarystats.forest_change_diagnostic | ||
|
||
import frameless.Injection | ||
import io.circe.syntax._ | ||
import io.circe.parser.decode | ||
|
||
case class ForestChangeDiagnosticDataDoubleTwoCategory( | ||
value: Map[String, ForestChangeDiagnosticDataDoubleCategory] | ||
) extends ForestChangeDiagnosticDataParser[ForestChangeDiagnosticDataDoubleTwoCategory] { | ||
def merge( | ||
other: ForestChangeDiagnosticDataDoubleTwoCategory | ||
): ForestChangeDiagnosticDataDoubleTwoCategory = { | ||
|
||
ForestChangeDiagnosticDataDoubleTwoCategory(value ++ other.value.map { | ||
case (key, otherValue) => | ||
key -> value | ||
.getOrElse(key, ForestChangeDiagnosticDataDoubleCategory.empty) | ||
.merge(otherValue) | ||
}) | ||
} | ||
|
||
def toJson: String = { | ||
this.value | ||
.map { | ||
case (key, value) => | ||
key -> value.round | ||
} | ||
.asJson | ||
.noSpaces | ||
} | ||
} | ||
|
||
object ForestChangeDiagnosticDataDoubleTwoCategory { | ||
def empty: ForestChangeDiagnosticDataDoubleTwoCategory = | ||
ForestChangeDiagnosticDataDoubleTwoCategory(Map()) | ||
|
||
def fill( | ||
className1: String, | ||
className2: String, | ||
areaHa: Double, | ||
noData: List[String] = List("", "Unknown", "Not applicable"), | ||
include: Boolean = true | ||
): ForestChangeDiagnosticDataDoubleTwoCategory = { | ||
if (noData.contains(className1)) | ||
ForestChangeDiagnosticDataDoubleTwoCategory.empty | ||
else | ||
ForestChangeDiagnosticDataDoubleTwoCategory( | ||
Map(className1 -> ForestChangeDiagnosticDataDoubleCategory.fill(className2, areaHa, include = include)) | ||
) | ||
} | ||
|
||
def fromString(value: String): ForestChangeDiagnosticDataDoubleTwoCategory = { | ||
|
||
val categories: Map[String, String] = decode[Map[String, String]](value).getOrElse(Map()) | ||
val newValue: Map[String, ForestChangeDiagnosticDataDoubleCategory] = categories.map { case (k, v) => (k, ForestChangeDiagnosticDataDoubleCategory.fromString(v)) } | ||
ForestChangeDiagnosticDataDoubleTwoCategory(newValue) | ||
|
||
} | ||
|
||
implicit def injection: Injection[ForestChangeDiagnosticDataDoubleTwoCategory , String] = Injection(_.toJson, fromString) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.