The people at FMSF v2 (fire modeling services framework version 2) are currently on break, so instead I’ve opted to figure out how to get my computer to access and change files locally, since I’m going to need to do that anyways (since the web-hosted API also needs my files passed in as arguments). Today the goal was to find a way for the computer to be able to access the .shp file that describes how barriers are placed, and modify in a way that can still work in Farsite so I can continue to pass it into the API.

The hardest part of this was to find out how to modify the file accurately, since opening it directly within a text file will show that it’s encrypted

what a .shp file looks like on notepad

what a .shp file looks like on notepad

A little digging reveals that geographic data like this can be changed and accessed with GeoPandas. Specifically, with a GeoPandas Dataset, which works just like a Pandas dataset but with many geographic info built into its metadata, such as crs, which defines its coordinate system.

More digging reveals that GeoPandas uses Shapely to create points stored inside a .shp file. Essentially, the shape file that defines the firebreaks are just shapes drawn on the screen. If you draw a line, it will prevent any flames from crossing. If you draw a polygon, and choose to fill that polygon, everything within the polygon would have essentially 0 fuel. It’s important to note that, just like in real life, although direct flames are prevented from passing, spot fires (fires that start by embers blowing) are still capable of crossing firebreaks. Thus, it is important to make the firebreaks wide enough (using filled polygons) such that fires can’t cross it easily.

image.png

image of spot fires in firefighting. Source: https://www.nwcg.gov/6mfs/weather-fire-behavior/frequent-spot-fires-across-the-line

It’s important to note that firebreaks cannot be placed as dots. I made this initial mistake when trying to place down firebreaks, before discovering dots as a whole cannot function as data for firebreaks.

The harder part is now to place firebreaks in a way that fits a machine learning model. Various machine learning models such as Deep Q networks require a discrete action space, and I figured it’ll be easier to transfer to a continuous action space from a discrete one than the other way around. (Note: there are also models that use continuous action spaces such as DDPG and TD3). To simulate this, I’m going to treat the environment as a grid, and only allow the model to place at every 10 grid or so. To simulate this, I’m going to only allow the model to place firebreaks at every 10 points in the grid, to divide the entire map into a more pixel-like map. For a test run, I simply had the model placed down large rectangular strips on the map that were easily recognizable, then convert them into polygons using Shapely.

For loop that create the rectangular strips to the polygon. Note that crf is set to gdf.crs in line 34, which was the crs created by a shapefile in Flammap. This makes it so I don’t have to define my own coordinate system, saving me a lot of work

For loop that create the rectangular strips to the polygon. Note that crf is set to gdf.crs in line 34, which was the crs created by a shapefile in Flammap. This makes it so I don’t have to define my own coordinate system, saving me a lot of work

It also turns out that the shape files stored in GeoPandas database also have 2 columns known as ENTITY and VALUE. I haven’t quite figured out what these do, only that they’re the same as the number of shape it is. This is achieved with a simple for loop.

creating and inserting 2 columns within my GeoPandas Dataframe. Will figure out what to do later.

creating and inserting 2 columns within my GeoPandas Dataframe. Will figure out what to do later.

Then the file is finally outputted and changed on my local hard drive