Skip to content

Commit

Permalink
Set up 2024 archive
Browse files Browse the repository at this point in the history
Currently points to 2021 archival data
  • Loading branch information
katamartin committed Jan 8, 2025
1 parent f6bbfa9 commit e447710
Show file tree
Hide file tree
Showing 6 changed files with 165 additions and 6 deletions.
2 changes: 1 addition & 1 deletion components/mobile.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ const Mobile = ({ data, locations, tiles, showFires, archive }) => {
)}
{section === 'methods' && (
<FadeIn>
{showFires && archive && <ArchiveMethodsContent />}
{showFires && archive && <ArchiveMethodsContent archive={archive} />}
{showFires && !archive && <FireMethodsContent />}
{!showFires && <CreditingMethodsContent />}
</FadeIn>
Expand Down
2 changes: 1 addition & 1 deletion components/projects/about.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ const About = ({ showFires, archive }) => {
<Wrapper title='Fires and forest offsets'>
This is a public monitor of forest fires affecting improved forest
management carbon offset projects in California's cap-and-trade program.{' '}
<Colors.Red>Archival version for 2021.</Colors.Red>
<Colors.Red>Archival version for {archive}.</Colors.Red>
</Wrapper>
)
}
Expand Down
2 changes: 1 addition & 1 deletion components/projects/methods/archive.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ import { Box } from 'theme-ui'

## Summary

This website provides an archival map from our analysis in 2021 of wildfires impacting improved forest management (IFM) forest offset projects. For general details on our analysis of forest offset crediting, please visit our [crediting map](/research/forest-offsets-crediting). For an up-to-date map tracking the effect of wildfires on projects for the 2025 fire season, please visit our current [fire map](/research/forest-offsets-fires).
This website provides an archival map from our analysis in {props.archive} of wildfires impacting improved forest management (IFM) forest offset projects. For general details on our analysis of forest offset crediting, please visit our [crediting map](/research/forest-offsets-crediting). For an up-to-date map tracking the effect of wildfires on projects for the 2025 fire season, please visit our current [fire map](/research/forest-offsets-fires).

export default ({ children }) => <Box>{children}</Box>
2 changes: 1 addition & 1 deletion components/projects/methods/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function Methods({ showMethods, toggleMethods, showFires, archive }) {
pb: [3, 3, 3, 4],
}}
>
{showFires && archive && <ArchiveMethodsContent />}
{showFires && archive && <ArchiveMethodsContent archive={archive} />}
{showFires && !archive && <FireMethodsContent />}
{!showFires && <CreditingMethodsContent />}
</Box>
Expand Down
4 changes: 2 additions & 2 deletions pages/research/forest-offsets-fires-2021.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ const Index = ({ fireMetadata, fireProjects }) => {
locations={locations}
tiles={tiles}
showFires={true}
archive={true}
archive={2021}
/>
<Box
sx={{
Expand Down Expand Up @@ -131,7 +131,7 @@ const Index = ({ fireMetadata, fireProjects }) => {
locations={locations}
tiles={tiles}
showFires={true}
archive={true}
archive={2021}
/>
</Layout>
</Box>
Expand Down
159 changes: 159 additions & 0 deletions pages/research/forest-offsets-fires-2024.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
import { useBreakpointIndex } from '@theme-ui/match-media'
import { Box } from 'theme-ui'
import { Layout, Guide, Dimmer } from '@carbonplan/components'
import Desktop from '../../components/desktop'
import Mobile from '../../components/mobile'
import projects from '../../data/projects-crediting'

const Index = ({ fireMetadata, fireProjects }) => {
const { fires } = fireMetadata
const { projects: projectsWithFires } = fireProjects

const uniqueOverlapping = [
...new Set(
Object.keys(projectsWithFires)
.map((d) => projectsWithFires[d].overlapping_fires)
.flat()
),
]

const projectLocations = {
type: 'FeatureCollection',
features: projects.map((d) => {
return {
type: 'Feature',
properties: {
id: d.id,
fire: projectsWithFires[d.id],
},
geometry: {
type: 'Point',
coordinates: d.shape_centroid,
},
}
}),
}

const fireLocations = {
type: 'FeatureCollection',
features: Object.keys(fires)
.filter((d) => uniqueOverlapping.includes(d))
.map((d) => {
return {
type: 'Feature',
properties: {
id: d,
name: fires[d] ? fires[d].name : null,
},
geometry: {
type: 'Point',
coordinates: [fires[d].centroid[0], fires[d].centroid[1]],
},
}
}),
}

const locations = { fires: fireLocations, projects: projectLocations }

const merged = projects.map((d) => {
const el = projectsWithFires[d.id]
if (el && Object.keys(fires).length > 0) {
d.fire = {
overlappingFires: el.overlapping_fires.map((id) => {
if (fires[id]) return { name: fires[id].name, href: fires[id].url }
}),
burnedFraction: el.burned_frac,
lastUpdated: fireMetadata.created_datetime,
}
}
return d
})

const index = useBreakpointIndex()

const tiles = {
projects: `https://carbonplan-forest-offsets.s3.us-west-1.amazonaws.com/web/tiles/archive/2021/projects/{z}/{x}/{y}.pbf`,
fires: `https://storage.googleapis.com/carbonplan-research/offset-fires/tiles/fires/fires/{z}/{x}/{y}.pbf`,
}

return (
<>
{index > 0 && (
<Layout
description={
'Monitor of forest fires affecting improved forest management carbon offset projects.'
}
title='Fires and forest offsets – CarbonPlan'
card='https://images.carbonplan.org/social/forest-offsets-fires.png'
nav={'research'}
header={false}
dimmer={false}
footer={false}
metadata={false}
>
<Desktop
data={projects}
locations={locations}
tiles={tiles}
showFires={true}
archive={2024}
/>
<Box
sx={{
position: ['fixed'],
right: [13],
bottom: [17, 17, 15, 15],
zIndex: 5000,
}}
>
<Dimmer />
</Box>
</Layout>
)}
{index === 0 && (
<Box sx={{ display: ['initial', 'none', 'none', 'none'] }}>
<Layout
description={
'Monitor of forest fires affecting improved forest management carbon offset projects.'
}
title='Fires and forest offsets – CarbonPlan'
card='https://images.carbonplan.org/social/forest-offsets-fires.png'
header={true}
nav={'research'}
dimmer={false}
footer={false}
metadata={false}
>
<Guide />
<Mobile
data={projects}
locations={locations}
tiles={tiles}
showFires={true}
archive={2024}
/>
</Layout>
</Box>
)}
</>
)
}

export async function getServerSideProps() {
const prefix =
'https://storage.googleapis.com/carbonplan-research/offset-fires'
try {
const res = await fetch(`${prefix}/fire_meta_combined.json`)
const data = await res.json()
const fireMetadata = data.fire_meta
const fireProjects = data.projects_with_fires

return { props: { fireMetadata, fireProjects } }
} catch {
return {
props: { fireMetadata: { fires: {} }, fireProjects: { projects: {} } },
}
}
}

export default Index

0 comments on commit e447710

Please sign in to comment.