-
Notifications
You must be signed in to change notification settings - Fork 0
41 lines (37 loc) · 2.23 KB
/
scrape-fires.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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