[Python] Wildfire Current Perimeter Pulls

Discussão em 'Python' iniciado por Stack, Julho 28, 2025.

  1. Stack

    Stack Membro Participativo

    I have the following code that works great! I run it locally and no problem.

    import requests
    import os
    from datetime import datetime

    # Step 1: Define URL and parameters
    url = "https://services3.arcgis.com/T4QMspbfLg3qTGWY/arcgis/rest/services/WFIGS_Interagency_Perimeters_Current/FeatureServer/0/query"
    params = {
    "where": "1=1",
    "outFields": "*",
    "f": "geojson",
    "outSR": "4326",
    "resultRecordCount": 2000
    }

    # Step 2: Create folder to store files
    output_folder = "wildfire_polygons"
    os.makedirs(output_folder, exist_ok=True)

    # Step 3: Generate dated filename
    today_str = datetime.today().strftime("%Y-%m-%d")
    output_filename = f"fire_perimeters_{today_str}.geojson"
    output_path = os.path.join(output_folder, output_filename)

    # Step 4: Download and save only if not already downloaded
    if not os.path.exists(output_path):
    print(f" Downloading fire perimeter data for {today_str}...")
    response = requests.get(url, params=params)
    response.raise_for_status()

    with open(output_path, 'w', encoding='utf-8') as f:
    f.write(response.text)

    print(f"✅ Saved to {output_path}")
    else:
    print(f" File already exists for today: {output_path}")


    However when I run this in an EC2 I get this error: ConnectionError: ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer')) I know this is likely an ESRI blocking issue. I've seen it recommended that I switch the IP, but that's not really an option.

    What would be the best way to run this? At this point it looks like I'm going to have to manually download this (https://data-nifc.opendata.arcgis.c...4_0/explore?location=4.089341,135.040488,2.51). The ESRI source is as follows: https://services3.arcgis.com/T4QMsp..._Interagency_Perimeters_Current/FeatureServer

    Continue reading...

Compartilhe esta Página