Methane Landfill Visualization & Anaylsis

Amrutha GujjarAmrutha Gujjarβ€’β€’3 min read

Category: Community


We're thrilled to feature Yashika in this edition of the Preswald Community Showcase! πŸŽ‰ Yashika has built an impressive Preswald app that analyzes and visualizes methane emissions from landfills using interactive charts and tables.

🌟 Project Overview

πŸ“Š Preswald and Analytics

This blog explores how Preswald utilizes analytics to examine methane emissions, providing insights into landfill gas production, environmental impact, and mitigation strategies through dynamic visualizations.

Project Name: Methane Emission Landfill Explorer
Built by: Yashika Kuckian
Dataset: Methane emissions dataset

Check out the project on GitHub

πŸ“Š Description

Yashika's project provides an interactive dashboard for exploring methane emissions from landfills. The app allows users to:

  • Filter emissions data by location, landfill type, and emission levels.
  • Visualize trends using Plotly charts to analyze methane release over time.
  • Compare landfill emissions dynamically in an interactive table.
  • Gain insights into environmental impact and strategies for reducing methane emissions.

With Preswald, Yashika has created a seamless user experience, where users can dynamically adjust inputs and get instant updates without writing frontend code.

img


πŸš€ Code Snippets

Here’s a sneak peek at how Yashika's project is structured:

Loading the Data

from preswald import connect, get_df, text

connect()  # Establish connection to data

# Load methane emissions dataset
methane_df = get_df("methane_emissions")

Creating an Interactive Emission Trend Chart

from preswald import plotly
import plotly.express as px

fig = px.line(methane_df, x='date', y='emission_level', color='landfill_site',
             title='Methane Emission Trends Over Time')
plotly(fig)

Displaying Methane Emission Data in a Table

from preswald import table

table(methane_df[['landfill_site', 'date', 'emission_level', 'region']])

With just a few lines of Python, Yashika has built a fully interactive data app powered by Preswald! πŸš€

What is Preswald?

Preswald is an open-source framework for building data apps, dashboards, and internal tools with just Python. It provides pre-built UI components like tables, charts, and forms, so you don't have to write frontend code. Users can interact with your app, changing inputs, running queries, and updating visualizations, without you needing to manage the UI manually.

Preswald tracks state and dependencies, making computations efficient by updating only when necessary. It uses a workflow DAG to manage execution order, ensuring performance and predictability. Preswald allows you to turn Python scripts into shareable, production-ready applications easily.

Key Features

  • Add UI components to Python scripts: user-interactive buttons, text inputs, tables, and charts.
  • Stateful execution with automatic state tracking and updates.
  • Structured computation using a DAG-based execution model.
  • Deploy with a single command.
  • Query and display live data from various sources.
  • Build interactive reports and dashboards.
  • Easy local or cloud hosting.
  • Shareable via a simple link.

πŸš€ Getting Started

Installation

First, install Preswald via pip: https://pypi.org/project/preswald/

pip install preswald

πŸ‘©β€πŸ’» Quick Start

1. Initialize a New Project

To start using Preswald, initialize a new project:

preswald init my_project
cd my_project

This creates a folder my_project with essential files:

  • hello.py: Your first Preswald app.
  • preswald.toml: Settings for your app.
  • secrets.toml: Secure sensitive information.
  • .gitignore: Keep secrets.toml safe from version control.

2. Write Your First App

Open hello.py and write:

from preswald import text, plotly, connect, get_df, table
import pandas as pd
import plotly.express as px

text("# Welcome to Preswald!")
text("This is your first app. πŸŽ‰")

# Load CSV data
connect() # loads default sample CSV
df = get_df('sample_csv')

# Create a scatter plot
fig = px.scatter(df, x='quantity', y='value', text='item',
                 title='Quantity vs. Value')
fig.update_traces(textposition='top center')
fig.update_layout(template='plotly_white')

# Show plot and data
table(df)

3. Run Your App

Launch the app with:

preswald run

4. Deploy Your App to the Cloud

Deploy your app using:

preswald deploy --target structured

Your app will be built and accessible online.


Huge Thanks to Yashika!

A big thank you to Yashika for sharing their work and inspiring the Preswald community! Want to see more of their work? Check them out on GitHubΒ orΒ LinkedIn.

Want to Contribute?

Got a cool idea for a Preswald app? We'd love to see it! Get started here: https://github.com/StructuredLabs/preswald and get featured in our next Community Showcase.

Happy building! πŸš€