make sf green again
overview of my ai x geo hackathon project
Last weekend, I attended an AI x Geoengineering 8-hour-long hackathon run by one of my best friends. One of my former hackathon teammates was also attending. While my experience with Geoengineering was limited, their combined enthusiasm and passion for social impact lured me to this hackathon. By the end of this hackathon, I had gained a better sense of AI tooling available, ecological challenges facing cities, and improved my ability to build a CRUD app.
Concept: Urban Forest
Ultimately, we were most excited about building a City Forest Visualizer, ForestVisionSF (FVS). FVC depicts a projection of what San Francisco would look like with more trees. The platform allows you to configure tree density, land usage, and species distribution. Based on this fields, the UI shows the maintenance cost and total CO2 reduction over 5 years.
We arrived at this idea based on our realization that San Francisco wastes a lot land usage on parking lots. It turns out that 20% of the city is parking lots is just parking lots and what's worse is that cars are parked 95% of the time. With the adoption of electric rideshares, notably Waymos, we argue that parking lots will eventually be obsolete.
In addition, SF has a mandate to be carbon neutral by 2040, which seems like a ambitious goal, but this vision becomes much more achievable if the city focuses their efforts on leveraging high impact efforts.
Technologies
Data
We retrieved all of our data from sfgov.org, loaded with a ton of publicly available datasets. The data from sfgov.org was surprisingly easy to prune, given that we had a lot of difficulty scraping the bills on the same website.
This dataset included latitude/longitude points.
This dataset was the easiest to parse, but provided the least accuracy.
This dataset also came in the form of points.
While parking lots were our target case, this dataset was quite small, having around 40 parking lots. It seemed to missing a lot more parking lots that I have seen in the city and I am not sure why those were not captured.
To represent a “street”, each row of data contained two points.
For the hackathon, we assumed average width and length values based on parking type and then estimated the total area available for trees.
Backend
We built a simple python server using the FastAPI. We opted for the FastAPI over a standard Flask app, since FastAPI is much faster, asynchronous by default, and uses Pydantic for type validation.
I was new to Pydantic, a python library that coerces types (instead of merely hinting at types), has built-in serialization and deserialization support for nested models. In this example below, we define a nested Pydantic model and initialize the model directly from JSON:
class AddressModel(BaseModel):
street: str
city: str
class PersonModel(BaseModel):
name: str
age: int
address: AddressModel # Nested model
data = {
"name": "Alice",
"age": 25,
"address": {"street": "123 Main St", "city": "NYC"}
}
p = PersonModel(**data) Our backend’s primary purpose was to serve locations for where each of the trees were planted. After estimating the “area” around each parking coordinate, we used the selected density to generate random positions to fill in that area.
This resulted in an interactive projection of SF with a reforested urban landscape:
Extension: AI Tree Overlay
We also had the idea of creating realistic tree overlays. For example, you would put on your VR glasses, look at the skyline, and see trees overlayed on top of it. I explored tAI image generators: Midjourney and Stable Diffusion.
Midjourney is a cloud-based generator with limited customization options is simple to get started with.
Stable Diffusion runs locally and is much more configurable.
Since a standard Mac GPU isn’t powerful enough to host Stable Diffusion, I faced numerous setup issues and ultimately settled on using Midjourney. However, Midjourney’s results were more "inspired" than realistic, so we cut this component from our project. Given more time, I would have explored other AI touchup image editors that would results that fit our use case.
Frontend
We used DeckGL as our UI layer. DeckGL is a designed to efficiently render massive datasets. It integrates seamlessly with interactive map frameworks, particularly Mapbox.
Mapbox is a platform for building interactive maps. While I did not develop the frontend for this project, I have had prior experience with Mapbox. I would strongly recommend it over other mapping tools, including Google Maps, since it is highly configurable and has beautiful rendering capabilities.
Takeaways
Urban Reforestation is a critical opportunity for SF! The importance is emphasized by the fact that other people actively tackling it! For example, Friends of Urban Forest is actively planting trees in parts of SF that are primarily urban.
Social sectors are generally underserved, even moreso in AI. Our project reinforced the opportunity to leverage AI for education and influence.
This hackathon was also a great opportunity to rapidly prototype with both AI tooling and the latest technologies.
If you are interested in updates on our work, follow us on Twitter @ForestVisionSF and checkout our Github.


