Skip to content

Scrape DNRC Fire Data #8269

Scrape DNRC Fire Data

Scrape DNRC Fire Data #8269

Workflow file for this run

name: Scrape DNRC Fire Data
on:
push:
workflow_dispatch:
schedule:
- cron: "4,24,44 * * * *"
jobs:
scheduled:
runs-on: ubuntu-latest
steps:
- name: Check out this repo
uses: actions/checkout@v3
- name: Fetch latest data
run: |-
# Fires
curl "https://services9.arcgis.com/RHVPKKiFTONKtxq3/arcgis/rest/services/USA_Wildfires_v1/FeatureServer/0/query?f=json&cacheHint=true&resultOffset=0&resultRecordCount=1000&where=((POOState%20%3D%20%27US-MT%27)%20AND%20(IncidentTypeCategory%20NOT%20IN%20(%27RX%27)))&orderByFields=DailyAcres%20DESC&outFields=*&resultType=standard&returnGeometry=true&spatialRel=esriSpatialRelIntersects" | jq '.' > dnrc-fires.json
# Fetch Remington Fire data
curl "https://services9.arcgis.com/RHVPKKiFTONKtxq3/arcgis/rest/services/USA_Wildfires_v1/FeatureServer/0/query?f=json&cacheHint=true&resultOffset=0&resultRecordCount=1000&where=((POOState%20%3D%20%27US-WY%27)%20AND%20(IncidentTypeCategory%20NOT%20IN%20(%27RX%27)))&orderByFields=DailyAcres%20DESC&outFields=*&resultType=standard&returnGeometry=true&spatialRel=esriSpatialRelIntersects" | jq '[.features[] | select(.attributes.IncidentName == "Remington" or .attributes.IncidentName == "Short Draw")]' > remingtonfire.js
# Check if remingtonfire.js has data
if [ -s remingtonfire.js ]; then
cp remingtonfire.js remingtonfirepermanent.js
else
# If no new data, keep the old data in remingtonfirepermanent.js
if [ ! -s remingtonfirepermanent.js ]; then
echo "[]" > remingtonfirepermanent.js
fi
fi
# Restrictions
curl "https://services2.arcgis.com/DRQySz3VhPgOv7Bo/arcgis/rest/services/Fire_Restrictions_by_Jurisdiction_Update_-_Read_Only_view/FeatureServer/3/query?returnGeometry=false&f=json&where=1%3D1&orderByFields=OBJECTID&outFields=*&defaultSR=4978" | jq '.' > dnrc-restrictions.json
- name: Commit and push if changed
run: |-
git config user.name "Automated"
git config user.email "[email protected]"
git add -A
timestamp=$(date -u)
git commit -m "Latest data: ${timestamp}" || exit 0
git push