I am trying to extract data about the DIST Alerts using the following script:
import requests
API_KEY = ''
API_BASE = "https://data-api.globalforestwatch.org"
DATASET = "umd_glad_dist_alerts"
OUTPUT_FILE = r''
sql = """
SELECT
longitude,
latitude,
umd_glad_landsat_alerts__date,
umd_glad_landsat_alerts__confidence,
umd_glad_dist_alerts__intensity,
sbtn_natural_forests_map__class,
FROM results
"""
geometry = {
"type": "Polygon",
"coordinates": [
[
[
23.542324962767566,
44.23260333862039
],
[
23.542324962767566,
44.09887485132083
],
[
24.472431463393548,
44.09887485132083
],
[
24.472431463393548,
44.23260333862039
],
[
23.542324962767566,
44.23260333862039
]
]
]
}
url = f"{API_BASE}/dataset/{DATASET}/latest/query/csv"
headers = {"Content-Type": "application/json"}
if API_KEY:
headers["x-api-key"] = API_KEY
body = {
"sql": sql,
"geometry": geometry
}
print("Requesting data from GFW API...")
resp = requests.post(url, headers=headers, json=body, stream=True)
if resp.status_code == 200:
with open(OUTPUT_FILE, "wb") as f:
for chunk in resp.iter_content(chunk_size=1024*1024):
if chunk:
f.write(chunk)
print(f"Saved results to {OUTPUT_FILE}")
else:
print("Error:", resp.status_code, resp.text[:500])
resp.raise_for_status()
Every time I select my ROI somewhere in Europe, I get
umd_glad_landsat_alerts__date = '2014-12-31'
even though, in the viewer (https://www.globalforestwatch.org/map/?map=eyJjZW50ZXIiOnsibGF0Ijo0Ny42MzMwODU4MjEyNDgwNywibG5nIjo3LjkwMDMxMDk5ODI0ODA3NX0sInpvb20iOjMuOTMxNTMyMzExMjQ1NjU2NiwiZGF0YXNldHMiOlt7ImRhdGFzZXQiOiJESVNUX2FsZXJ0cyIsIm9wYWNpdHkiOjEsInZpc2liaWxpdHkiOnRydWUsImxheWVycyI6WyJESVNUX2FsZXJ0c19hbGwiXX0seyJkYXRhc2V0IjoicG9saXRpY2FsLWJvdW5kYXJpZXMiLCJsYXllcnMiOlsiZGlzcHV0ZWQtcG9saXRpY2FsLWJvdW5kYXJpZXMiLCJwb2xpdGljYWwtYm91bmRhcmllcyJdLCJvcGFjaXR5IjoxLCJ2aXNpYmlsaXR5Ijp0cnVlfV19&mapMenu=eyJtZW51U2VjdGlvbiI6ImRhdGFzZXRzIiwiZGF0YXNldENhdGVnb3J5IjoiZm9yZXN0Q2hhbmdlIn0%3D) for the same region, there are alert signals from the current week.
Does anyone know why this happens?
I also checked a few polygons in Brazil and India, and there the date range varied as expected.