Skip to content

Commit

Permalink
Merge pull request #158 from wri/develop
Browse files Browse the repository at this point in the history
Merge develop to master
  • Loading branch information
jterry64 authored May 10, 2022
2 parents 8c988f7 + 0a7cf24 commit 4f4dc1f
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/main/resources/raster-catalog-pro.json
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@
},
{
"name":"umd_tree_cover_loss",
"source_uri":"s3://gfw-data-lake/umd_tree_cover_loss/v1.8/raster/epsg-4326/{grid_size}/{row_count}/year/gdal-geotiff/{tile_id}.tif"
"source_uri":"s3://gfw-data-lake/umd_tree_cover_loss/v1.9/raster/epsg-4326/{grid_size}/{row_count}/year/gdal-geotiff/{tile_id}.tif"
},
{
"name":"gfw_managed_forests",
Expand Down Expand Up @@ -278,7 +278,7 @@
},
{
"name":"umd_soy_planted_area",
"source_uri": "s3://gfw-data-lake/umd_soy_planted_area/v1/raster/epsg-4326/{grid_size}/{row_count}/is__year_2020/gdal-geotiff/{tile_id}.tif"
"source_uri": "s3://gfw-data-lake/umd_soy_planted_area/v2/raster/epsg-4326/{grid_size}/{row_count}/is__year_2021/gdal-geotiff/{tile_id}.tif"
},
{
"name":"inpe_prodes",
Expand Down
23 changes: 18 additions & 5 deletions src/main/scala/org/globalforestwatch/summarystats/SummaryRDD.scala
Original file line number Diff line number Diff line change
Expand Up @@ -112,23 +112,36 @@ trait SummaryRDD extends LazyLogging with java.io.Serializable {
readWindow(rs, windowKey, windowLayout)
}

// flatMap here flattens out and ignores the errors
// Intersect with window extent and group by resulting geom, so we only do polygonal summary
// once per each geometry tile. This will speed up overlapping geometries a lot, where often we're
// analyzing the full window extent across many features.
val groupedByWindowGeom: Map[Geometry, Array[Feature[Geometry, FEATUREID]]] = features.groupBy {
case feature: Feature[Geometry, FEATUREID] =>
val windowGeom: Extent = windowLayout.mapTransform.keyToExtent(windowKey)
feature.geom.intersection(windowGeom)

try {
if (feature.geom.isValid) {
// if valid geometry, attempt to intersect
feature.geom.intersection(windowGeom)
} else {
// otherwise, just use original geometry, since sometimes
// making complex geometries valid can be very slow
feature.geom
}
} catch {
case e: org.locationtech.jts.geom.TopologyException =>
// fallback to original geometry if there are any intersection issues
feature.geom
}
}

groupedByWindowGeom.flatMap {
case (windowGeom: Geometry, features: Array[Feature[Geometry, FEATUREID]]) =>
// val id: FEATUREID = feature.data
val rasterizeOptions = Rasterizer.Options(
includePartial = false,
sampleType = PixelIsPoint
)

println(s"Size of features for spatial key $windowKey: ${features.size}")

maybeRaster match {
case Left(exception) =>
logger.error(s"Raster could not bread at spatial key:\n$windowKey\n$exception")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ object ForestChangeDiagnosticAnalysis extends SummaryAnalysis {
.mapValues { case (data, fire) =>
data.copy(
commodity_threat_fires = fire.getOrElse(ForestChangeDiagnosticDataLossYearly.empty),
tree_cover_loss_soy_yearly = data.tree_cover_loss_soy_yearly.limitToMaxYear(2019)
tree_cover_loss_soy_yearly = data.tree_cover_loss_soy_yearly.limitToMaxYear(2020)
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ object ForestChangeDiagnosticDataLossYearly {
2017 -> 0,
2018 -> 0,
2019 -> 0,
2020 -> 0
2020 -> 0,
2021 -> 0,
)
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ object ForestChangeDiagnosticDataValueYearly {
2017 -> 0,
2018 -> 0,
2019 -> 0,
2020 -> 0
2020 -> 0,
2021 -> 0,
)
)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
list_id location_id status_code location_error tree_cover_loss_total_yearly tree_cover_loss_primary_forest_yearly tree_cover_loss_peat_yearly tree_cover_loss_intact_forest_yearly tree_cover_loss_protected_areas_yearly tree_cover_loss_sea_landcover_yearly tree_cover_loss_idn_landcover_yearly tree_cover_loss_soy_yearly tree_cover_loss_idn_legal_yearly tree_cover_loss_idn_forest_moratorium_yearly tree_cover_loss_prodes_yearly tree_cover_loss_prodes_wdpa_yearly tree_cover_loss_prodes_primary_forest_yearly tree_cover_loss_brazil_biomes_yearly tree_cover_extent_total tree_cover_extent_primary_forest tree_cover_extent_protected_areas tree_cover_extent_peat tree_cover_extent_intact_forest natural_habitat_primary natural_habitat_intact_forest total_area protected_areas_area peat_area brazil_biomes idn_legal_area sea_landcover_area idn_landcover_area idn_forest_moratorium_area south_america_presence legal_amazon_presence brazil_biomes_presence cerrado_biome_presence southeast_asia_presence indonesia_presence commodity_value_forest_extent commodity_value_peat commodity_value_protected_areas commodity_threat_deforestation commodity_threat_peat commodity_threat_protected_areas commodity_threat_fires
1 31 2 {"2001":1021.7622,"2002":851.014,"2003":310.1835,"2004":2169.8398,"2005":2325.3843,"2006":4162.4968,"2007":2968.7863,"2008":4015.4403,"2009":2002.9194,"2010":1173.7001,"2011":1703.6902,"2012":2838.0498,"2013":1841.7568,"2014":2468.7732,"2015":2028.9672,"2016":3344.8135,"2017":1026.7609,"2018":525.5327,"2019":618.7052,"2020":924.699,"2021":857.8225} {"2001":154.8617,"2002":306.7253,"2003":92.3781,"2004":717.7405,"2005":1202.6952,"2006":1831.5766,"2007":1668.2764,"2008":1753.2317,"2009":797.282,"2010":454.5023,"2011":872.3613,"2012":1251.8543,"2013":1083.6799,"2014":1290.2177,"2015":1360.2574,"2016":2313.5001,"2017":286.2809,"2018":159.8557,"2019":162.3929,"2020":134.2652,"2021":167.4697} {"2001":557.4251,"2002":236.2539,"2003":71.8566,"2004":741.25,"2005":957.52,"2006":1229.3335,"2007":1037.5018,"2008":891.235,"2009":486.4665,"2010":363.5759,"2011":411.9212,"2012":1078.9246,"2013":862.5621,"2014":974.783,"2015":942.4571,"2016":1472.8429,"2017":211.3403,"2018":144.7173,"2019":148.7917,"2020":142.3323,"2021":122.7372} {} {"2001":42.2692,"2002":228.1732,"2003":11.3743,"2004":3.9196,"2005":1.614,"2006":15.3711,"2007":4.4576,"2008":2.8437,"2009":4.765,"2010":7.9931,"2011":10.7597,"2012":8.1466,"2013":0.1537,"2014":8.5307,"2015":18.6758,"2016":139.2616,"2017":10.7596,"2018":0.3843,"2019":0.2306,"2020":0.0,"2021":0.0769} {"Rubber plantation":{"2001":3.0745,"2002":16.5256,"2003":36.0493,"2004":66.1791,"2005":73.4812,"2006":25.9797,"2007":5.9184,"2008":56.571,"2009":47.7317,"2010":33.3581,"2011":21.9825,"2012":52.9583,"2013":11.9137,"2014":42.2742,"2015":34.2038,"2016":63.4883,"2017":10.6839,"2018":24.4423,"2019":22.1363,"2020":10.4533,"2021":25.826},"Secondary forest":{"2001":240.1012,"2002":352.6874,"2003":51.186,"2004":522.8408,"2005":879.6014,"2006":1310.6826,"2007":981.6686,"2008":756.8744,"2009":359.2934,"2010":232.485,"2011":575.4717,"2012":1110.4372,"2013":787.2514,"2014":772.2979,"2015":966.528,"2016":1571.8466,"2017":149.9382,"2018":89.3794,"2019":136.8781,"2020":121.8915,"2021":68.6318},"Agriculture":{"2001":3.151,"2002":9.1452,"2003":5.4563,"2004":53.8715,"2005":30.3561,"2006":22.9009,"2007":6.5323,"2008":10.9893,"2009":159.7649,"2010":38.7323,"2011":100.4403,"2012":104.3592,"2013":15.3698,"2014":35.8124,"2015":19.6734,"2016":38.1942,"2017":19.2886,"2018":10.5282,"2019":11.2197,"2020":7.9922,"2021":12.1419},"Oil palm plantation":{"2001":389.5357,"2002":222.339,"2003":103.9797,"2004":96.4524,"2005":67.8614,"2006":368.7244,"2007":440.2632,"2008":428.9814,"2009":151.7946,"2010":184.5942,"2011":113.5139,"2012":263.0128,"2013":147.9443,"2014":88.3878,"2015":58.1061,"2016":70.7105,"2017":44.5029,"2018":31.2823,"2019":233.0475,"2020":526.052,"2021":395.9972},"Swamp":{"2001":265.2372,"2002":112.4372,"2003":38.2726,"2004":648.495,"2005":548.2747,"2006":855.4703,"2007":1129.3025,"2008":2086.08,"2009":484.4962,"2010":300.1085,"2011":526.378,"2012":478.8799,"2013":482.4034,"2014":742.3953,"2015":446.518,"2016":539.8938,"2017":620.8959,"2018":204.1215,"2019":105.5176,"2020":122.2736,"2021":197.9767},"Settlements":{"2001":0.1537,"2002":0.9992,"2003":0.0,"2004":0.6918,"2005":0.1537,"2006":1.1529,"2007":1.1529,"2008":0.538,"2009":1.0761,"2010":0.8455,"2011":1.1529,"2012":0.8454,"2013":0.0,"2014":0.6918,"2015":0.1537,"2016":0.2306,"2017":0.3843,"2018":0.0,"2019":0.1537,"2020":1.1529,"2021":1.3067},"Grassland/shrub":{"2001":59.3337,"2002":89.231,"2003":37.5821,"2004":445.7701,"2005":432.4583,"2006":514.3995,"2007":235.9463,"2008":500.7963,"2009":334.6362,"2010":269.6786,"2011":186.2981,"2012":378.8895,"2013":330.4736,"2014":424.3189,"2015":165.2413,"2016":151.5619,"2017":77.7013,"2018":84.6964,"2019":29.59,"2020":91.3842,"2021":53.8004},"Primary forest":{"2001":41.1934,"2002":30.6653,"2003":13.68,"2004":98.6793,"2005":209.8123,"2006":379.429,"2007":115.8962,"2008":96.2208,"2009":368.2156,"2010":47.8819,"2011":42.0413,"2012":228.795,"2013":26.1305,"2014":255.8481,"2015":270.3755,"2016":823.8133,"2017":81.5399,"2018":47.9595,"2019":64.4845,"2020":22.7495,"2021":71.7856},"Water bodies":{"2001":0.8454,"2002":0.0768,"2003":0.0,"2004":0.1537,"2005":0.0,"2006":0.0,"2007":0.0769,"2008":0.0,"2009":0.0,"2010":0.1537,"2011":0.2306,"2012":0.6916,"2013":0.6917,"2014":0.6148,"2015":0.0,"2016":0.2306,"2017":0.0768,"2018":0.0,"2019":0.0,"2020":0.0,"2021":0.2305},"Mixed tree crops":{"2001":19.1363,"2002":16.9073,"2003":23.9776,"2004":236.7062,"2005":83.3852,"2006":683.7575,"2007":52.029,"2008":78.3891,"2009":95.9108,"2010":65.8624,"2011":136.1808,"2012":219.1809,"2013":39.5784,"2014":106.132,"2015":68.1674,"2016":84.8439,"2017":21.749,"2018":33.1229,"2019":15.6777,"2020":20.7498,"2021":30.1257}} {"Bare land":{"2001":3.8428,"2002":35.2766,"2003":5.3801,"2004":14.4491,"2005":17.6005,"2006":39.8116,"2007":99.1447,"2008":141.5687,"2009":59.9482,"2010":20.7508,"2011":136.3415,"2012":129.3478,"2013":94.2991,"2014":83.0794,"2015":280.0642,"2016":735.1371,"2017":28.9729,"2018":36.1198,"2019":8.3774,"2020":7.1477,"2021":8.0699},"Mining":{"2001":7.301,"2002":2.7666,"2003":5.2258,"2004":11.9889,"2005":15.2172,"2006":9.1456,"2007":7.6082,"2008":34.8914,"2009":16.9072,"2010":8.9918,"2011":12.4502,"2012":29.5112,"2013":1.0759,"2014":16.8304,"2015":2.5362,"2016":1.9982,"2017":1.7676,"2018":0.7685,"2019":0.3074,"2020":0.4611,"2021":1.7676},"Settlement":{"2001":30.2802,"2002":84.4598,"2003":6.7627,"2004":5.226,"2005":1.9982,"2006":15.5239,"2007":5.3029,"2008":146.7178,"2009":9.1456,"2010":5.9944,"2011":8.2999,"2012":20.9038,"2013":6.4557,"2014":10.4519,"2015":14.0641,"2016":20.5962,"2017":9.6834,"2018":5.9946,"2019":5.6871,"2020":7.5318,"2021":7.5314},"Secondary forest":{"2001":14.8329,"2002":34.5077,"2003":10.3753,"2004":63.4026,"2005":86.5381,"2006":58.5628,"2007":81.0051,"2008":222.8806,"2009":92.1507,"2010":46.96,"2011":105.6723,"2012":258.1458,"2013":358.5935,"2014":604.2224,"2015":692.3818,"2016":1208.3837,"2017":259.4575,"2018":110.7479,"2019":151.2503,"2020":92.763,"2021":119.8204},"Agriculture":{"2001":87.6883,"2002":42.4224,"2003":18.9819,"2004":289.878,"2005":266.1325,"2006":746.3828,"2007":376.2672,"2008":177.9118,"2009":282.8805,"2010":120.1185,"2011":271.2771,"2012":638.4726,"2013":155.6217,"2014":248.7641,"2015":220.5643,"2016":382.8723,"2017":105.1299,"2018":55.5624,"2019":44.6495,"2020":56.5613,"2021":42.3446},"Swamp":{"2001":110.6023,"2002":161.6235,"2003":30.1276,"2004":349.3156,"2005":345.4651,"2006":346.3096,"2007":162.935,"2008":218.7309,"2009":146.9478,"2010":95.2199,"2011":132.4202,"2012":382.8885,"2013":159.6257,"2014":317.4138,"2015":296.5912,"2016":418.5593,"2017":115.2812,"2018":74.3201,"2019":85.1564,"2020":78.4694,"2021":128.1948},"Grassland/shrub":{"2001":4.9185,"2002":20.2891,"2003":11.7584,"2004":38.7334,"2005":22.748,"2006":135.7978,"2007":15.2937,"2008":74.7011,"2009":35.6594,"2010":20.4429,"2011":50.7993,"2012":105.518,"2013":11.4509,"2014":46.2648,"2015":55.7949,"2016":62.8662,"2017":264.4497,"2018":34.5065,"2019":9.8372,"2020":5.1492,"2021":6.9934},"Estate crop plantation":{"2001":759.8369,"2002":469.6682,"2003":221.0338,"2004":1396.0776,"2005":1569.454,"2006":2808.3496,"2007":2218.0015,"2008":2990.2754,"2009":1359.0495,"2010":854.7606,"2011":983.3553,"2012":1269.5731,"2013":1053.2509,"2014":1138.9796,"2015":466.1251,"2016":509.328,"2017":239.7129,"2018":205.5913,"2019":312.8252,"2020":676.3081,"2021":539.8723},"Body of water":{"2001":2.4593,"2002":0.0,"2003":0.538,"2004":0.7685,"2005":0.2306,"2006":2.6132,"2007":3.228,"2008":7.7625,"2009":0.2306,"2010":0.4611,"2011":3.0743,"2012":3.689,"2013":1.3834,"2014":2.7668,"2015":0.8454,"2016":5.0725,"2017":2.3057,"2018":1.9215,"2019":0.6148,"2020":0.3074,"2021":3.228}} {} {"Other Utilization Area":{"2001":712.0267,"2002":482.1867,"2003":221.5682,"2004":1414.5116,"2005":1126.5942,"2006":2837.7298,"2007":1853.8397,"2008":3013.7624,"2009":1165.5631,"2010":833.4598,"2011":1098.1437,"2012":1865.7614,"2013":971.0994,"2014":1259.078,"2015":657.4037,"2016":999.5492,"2017":622.2031,"2018":279.4429,"2019":376.9137,"2020":705.8893,"2021":595.4311},"Converted Production Forest":{"2001":151.8635,"2002":60.1778,"2003":69.0172,"2004":724.5834,"2005":1148.2139,"2006":1123.3127,"2007":1023.561,"2008":844.268,"2009":747.8878,"2010":275.2161,"2011":481.5731,"2012":804.1156,"2013":820.0067,"2014":1024.9196,"2015":1197.936,"2016":1866.668,"2017":356.367,"2018":233.3308,"2019":223.499,"2020":193.5994,"2021":241.5624},"Production Forest":{"2001":113.1434,"2002":80.4763,"2003":7.6858,"2004":26.0567,"2005":48.7316,"2006":183.5469,"2007":84.3149,"2008":147.2649,"2009":84.4729,"2010":56.57,"2011":110.1392,"2012":156.3372,"2013":49.1136,"2014":173.4782,"2015":154.1063,"2016":334.2621,"2017":35.1256,"2018":10.4532,"2019":17.4472,"2020":24.9028,"2021":17.5241},"Sanctuary Reserves/Nature Conservation Area":{"2001":42.2692,"2002":228.1732,"2003":11.3743,"2004":3.9196,"2005":1.614,"2006":15.3711,"2007":4.4576,"2008":2.8437,"2009":4.765,"2010":7.9931,"2011":10.7597,"2012":8.1466,"2013":0.1537,"2014":8.5307,"2015":18.6758,"2016":139.2616,"2017":10.7596,"2018":0.3843,"2019":0.2306,"2020":0.0,"2021":0.0769}} {"2001":85.0014,"2002":248.2325,"2003":18.829,"2004":97.8293,"2005":96.2941,"2006":176.9875,"2007":138.7928,"2008":129.4126,"2009":109.4342,"2010":65.0144,"2011":100.5959,"2012":428.132,"2013":566.3779,"2014":467.2467,"2015":304.2577,"2016":712.6515,"2017":145.3232,"2018":56.2574,"2019":82.8502,"2020":54.0272,"2021":24.2097} {} {} {} {} 76338.8266 34513.678 6014.0986 23301.5138 0.0 34530.8164 0.0 125583.7284 6614.0107 31984.9079 {} {"Other Utilization Area":81822.5991,"Converted Production Forest":28600.5448,"Production Forest":4848.8827,"Sanctuary Reserves/Nature Conservation Area":6614.0107} {"Rubber plantation":3542.3364,"Secondary forest":24896.0268,"Agriculture":2763.3729,"Oil palm plantation":24398.5485,"Swamp":29043.6031,"Settlements":851.2415,"Grassland/shrub":22752.6953,"Primary forest":8261.1709,"Water bodies":3133.0348,"Mixed tree crops":5941.6982} {"Bare land":2902.1353,"Mining":1392.3433,"Settlement":5798.0268,"Secondary forest":21966.5842,"Agriculture":9963.5593,"Swamp":7625.7847,"Grassland/shrub":2875.049,"Estate crop plantation":69353.0242,"Body of water":3707.2217} 13342.6717 false false false false true true {"2002":24579.8084,"2003":24451.4643,"2004":24189.9373,"2005":24132.0676,"2006":23677.7243,"2007":23217.4612,"2008":22247.8139,"2009":21697.0839,"2010":21235.5008,"2011":20791.3746,"2012":20560.122,"2013":20057.1275,"2014":19054.2097,"2015":18742.9578,"2016":18210.5965,"2017":17209.7962,"2018":15452.9753,"2019":15189.6774,"2020":15071.8608} {"2002":31984.9079,"2003":31984.9079,"2004":31984.9079,"2005":31984.9079,"2006":31984.9079,"2007":31984.9079,"2008":31984.9079,"2009":31984.9079,"2010":31984.9079,"2011":31984.9079,"2012":31984.9079,"2013":31984.9079,"2014":31984.9079,"2015":31984.9079,"2016":31984.9079,"2017":31984.9079,"2018":31984.9079,"2019":31984.9079,"2020":31984.9079} {"2002":6614.0107,"2003":6614.0107,"2004":6614.0107,"2005":6614.0107,"2006":6614.0107,"2007":6614.0107,"2008":6614.0107,"2009":6614.0107,"2010":6614.0107,"2011":6614.0107,"2012":6614.0107,"2013":6614.0107,"2014":6614.0107,"2015":6614.0107,"2016":6614.0107,"2017":6614.0107,"2018":6614.0107,"2019":6614.0107,"2020":6614.0107} {"2002":389.8711,"2003":319.3967,"2004":512.213,"2005":914.6063,"2006":1429.9104,"2007":1520.3773,"2008":1012.313,"2009":905.7094,"2010":675.3788,"2011":734.247,"2012":1505.9123,"2013":1314.1698,"2014":843.6132,"2015":1533.1615,"2016":2757.6213,"2017":2020.1188,"2018":381.1145,"2019":273.6768,"2020":272.6016} {"2002":13363.7925,"2003":13309.3807,"2004":13472.9171,"2005":13694.9388,"2006":14063.9863,"2007":14195.4089,"2008":13789.4768,"2009":13613.3257,"2010":13540.0855,"2011":13478.2203,"2012":13889.142,"2013":13891.8339,"2014":13604.4896,"2015":14052.9405,"2016":14710.2098,"2017":14207.349,"2018":13390.077,"2019":13385.3927,"2020":13385.8532} {"2002":222.102,"2003":200.4294,"2004":9.6067,"2005":0.4611,"2006":3.7659,"2007":3.8427,"2008":0.1537,"2009":1.2297,"2010":2.8437,"2011":2.9205,"2012":3.2279,"2013":1.9982,"2014":0.3843,"2015":13.7571,"2016":74.1656,"2017":63.0214,"2018":2.2287,"2019":0.0,"2020":0.0} {}
Loading

0 comments on commit 4f4dc1f

Please sign in to comment.