Logo
  • Home

Tutorials

  • Overview
  • Your first query
  • Translate a filter into API parameters
  • Level 1.0 data from the "Cart_Site" for AOD daily averages

How-to guides

  • Overview
  • CLI workflows
  • Level 1.5 data from all sites with available data for all AOD points
  • Level 2.0 data from the "Cart_Site" for AOD daily averages
  • Level 2.0 data from the "Cart_Site" for SDA daily averages
    • Execute the operation
    • Visualize the results as Data Frame
    • Visualize results on Map screen
  • Geographical search
  • Stations Discovery
  • Match-Up
  • Stations Discovery + Match-Up
  • Development and documentation

Reference

  • Overview
  • CLI
  • Filters
  • Python API
  • AERONET OpenAPI

Explanation

  • Query processing
  • Software design
pygeofilter AERONET API support for CQL2
  • How-to guides
  • Level 2.0 data from the "Cart_Site" for SDA daily averages
  • Edit on Terradue/pygeofilter-aeronet

Level 2.0 data from the "Cart_Site" for SDA daily averages¶

Define a cql2-json filter for:

https://aeronet.gsfc.nasa.gov/cgi-bin/print_web_data_v3?site=Cart_Site&year=2000&month=6&day=1&year2=2000&month2=6&day2=14&SDA20=1&AVG=20

In [1]:
Copied!
from pathlib import Path
from pystac import Item

import json
import sys

out_dir: Path = Path('.')

cql2_filter = {
    "op": "and",
    "args": [
        {"op": "eq", "args": [{"property": "site"}, "Cart_Site"]},
        {"op": "eq", "args": [{"property": "data_type"}, "SDA20"]},
        {"op": "eq", "args": [{"property": "format"}, "csv"]},
        {"op": "eq", "args": [{"property": "data_format"}, "daily-average"]},
        {
            "op": "t_after",
            "args": [
                {"property": "time"},
                {"timestamp": "2000-06-01T00:00:00Z"},
            ],
        },
        {
            "op": "t_before",
            "args": [
                {"property": "time"},
                {"timestamp": "2000-06-14T23:59:59Z"},
            ],
        },
    ],
}

json.dump(cql2_filter, sys.stdout, indent=2)
from pathlib import Path from pystac import Item import json import sys out_dir: Path = Path('.') cql2_filter = { "op": "and", "args": [ {"op": "eq", "args": [{"property": "site"}, "Cart_Site"]}, {"op": "eq", "args": [{"property": "data_type"}, "SDA20"]}, {"op": "eq", "args": [{"property": "format"}, "csv"]}, {"op": "eq", "args": [{"property": "data_format"}, "daily-average"]}, { "op": "t_after", "args": [ {"property": "time"}, {"timestamp": "2000-06-01T00:00:00Z"}, ], }, { "op": "t_before", "args": [ {"property": "time"}, {"timestamp": "2000-06-14T23:59:59Z"}, ], }, ], } json.dump(cql2_filter, sys.stdout, indent=2)
{
  "op": "and",
  "args": [
    {
      "op": "eq",
      "args": [
        {
          "property": "site"
        },
        "Cart_Site"
      ]
    },
    {
      "op": "eq",
      "args": [
        {
          "property": "data_type"
        },
        "SDA20"
      ]
    },
    {
      "op": "eq",
      "args": [
        {
          "property": "format"
        },
        "csv"
      ]
    },
    {
      "op": "eq",
      "args": [
        {
          "property": "data_format"
        },
        "daily-average"
      ]
    },
    {
      "op": "t_after",
      "args": [
        {
          "property": "time"
        },
        {
          "timestamp": "2000-06-01T00:00:00Z"
        }
      ]
    },
    {
      "op": "t_before",
      "args": [
        {
          "property": "time"
        },
        {
          "timestamp": "2000-06-14T23:59:59Z"
        }
      ]
    }
  ]
}

Execute the search operation¶

In [2]:
Copied!
from pygeofilter_aeronet import aeronet_search

item: Item = aeronet_search(
    cql2_filter=cql2_filter,
    output_dir=out_dir
)

json.dump(item.to_dict(), sys.stdout, indent=2)
from pygeofilter_aeronet import aeronet_search item: Item = aeronet_search( cql2_filter=cql2_filter, output_dir=out_dir ) json.dump(item.to_dict(), sys.stdout, indent=2)
2025-11-14 18:08:13.741 | SUCCESS  | pygeofilter_aeronet:aeronet_search:231 - Query on https://aeronet.gsfc.nasa.gov successfully obtained data:
2025-11-14 18:08:13.743 | SUCCESS  | pygeofilter_aeronet:aeronet_search:239 - Data saved to to CSV file: /home/stripodi/Documents/pygeofilter/pygeofilter-aeronet/docs/samples/0d516cb3-899c-4333-bfda-3a49134c0cfc.csv
2025-11-14 18:08:13.750 | SUCCESS  | pygeofilter_aeronet:aeronet_search:270 - Data saved to GeoParquet file: /home/stripodi/Documents/pygeofilter/pygeofilter-aeronet/docs/samples/0d516cb3-899c-4333-bfda-3a49134c0cfc.parquet
{
  "type": "Feature",
  "stac_version": "1.1.0",
  "stac_extensions": [],
  "id": "urn:uuid:0d516cb3-899c-4333-bfda-3a49134c0cfc",
  "geometry": {
    "type": "Point",
    "coordinates": [
      -97.48639,
      36.60667
    ]
  },
  "bbox": [
    -97.48639,
    36.60667,
    -97.48639,
    36.60667
  ],
  "properties": {
    "datetime": "2025-11-14T18:08:13.780870Z"
  },
  "links": [
    {
      "rel": "related",
      "href": "https://aeronet.gsfc.nasa.gov/cgi-bin/print_web_data_v3?site=Cart_Site&SDA20=1&if_no_html=1&AVG=20&year=2000&month=6&day=1&hour=0&year2=2000&month2=6&day2=14&hour2=23",
      "type": "text/csv",
      "title": "AERONET Web Service search"
    }
  ],
  "assets": {
    "csv": {
      "href": "0d516cb3-899c-4333-bfda-3a49134c0cfc.csv",
      "type": "text/csv",
      "description": "Search result - CVS Format"
    },
    "geoparquet": {
      "href": "0d516cb3-899c-4333-bfda-3a49134c0cfc.parquet",
      "type": "application/vnd.apache.parquet",
      "description": "Search result - GeoParquet Format"
    }
  }
}

Visualize the results as Data Frame¶

In [3]:
Copied!
from geopandas import read_parquet
from geopandas.geodataframe import GeoDataFrame

geoparquet_file: str = item.get_assets()['geoparquet'].href
geoparquet_data: GeoDataFrame = read_parquet(geoparquet_file)

geoparquet_data
from geopandas import read_parquet from geopandas.geodataframe import GeoDataFrame geoparquet_file: str = item.get_assets()['geoparquet'].href geoparquet_data: GeoDataFrame = read_parquet(geoparquet_file) geoparquet_data
Out[3]:
AERONET_Site Date_(dd:mm:yyyy) Time_(hh:mm:ss) Day_of_Year Total_AOD_500nm[tau_a] Fine_Mode_AOD_500nm[tau_f] Coarse_Mode_AOD_500nm[tau_c] FineModeFraction_500nm[eta] 2nd_Order_Reg_Fit_Error-Total_AOD_500nm[regression_dtau_a] RMSE_Fine_Mode_AOD_500nm[Dtau_f] ... N[dAE/dln(wavelength)-Fine_Mode_500nm[alphap_f]] Data_Quality_Level AERONET_Instrument_Number AERONET_Site_Name Site_Latitude(Degrees) Site_Longitude(Degrees) Site_Elevation(m) Unnamed: 34 geometry datetime
0 Cart_Site 31:05:2000 12:00:00 152 0.110159 0.076089 0.034070 0.685081 0.006198 0.010284 ... 32 lev20 99 Cart_Site 36.60667 -97.48639 318.0 NaN POINT (-97.48639 36.60667) 2000-05-31 12:00:00
1 Cart_Site 01:06:2000 12:00:00 153 0.122092 0.074926 0.047167 0.615333 0.005520 0.009893 ... 12 lev20 99 Cart_Site 36.60667 -97.48639 318.0 NaN POINT (-97.48639 36.60667) 2000-06-01 12:00:00
2 Cart_Site 04:06:2000 12:00:00 156 0.312680 0.262406 0.050274 0.839186 0.006488 0.050660 ... 2 lev20 99 Cart_Site 36.60667 -97.48639 318.0 NaN POINT (-97.48639 36.60667) 2000-06-04 12:00:00
3 Cart_Site 05:06:2000 12:00:00 157 0.079892 0.050040 0.029852 0.627091 0.004806 0.006864 ... 55 lev20 99 Cart_Site 36.60667 -97.48639 318.0 NaN POINT (-97.48639 36.60667) 2000-06-05 12:00:00
4 Cart_Site 06:06:2000 12:00:00 158 0.169686 0.122910 0.046777 0.721316 0.006567 0.017211 ... 25 lev20 99 Cart_Site 36.60667 -97.48639 318.0 NaN POINT (-97.48639 36.60667) 2000-06-06 12:00:00
5 Cart_Site 07:06:2000 12:00:00 159 0.129509 0.091838 0.037671 0.714354 0.006138 0.011421 ... 16 lev20 99 Cart_Site 36.60667 -97.48639 318.0 NaN POINT (-97.48639 36.60667) 2000-06-07 12:00:00
6 Cart_Site 08:06:2000 12:00:00 160 0.093119 0.067934 0.025185 0.726142 0.005370 0.009316 ... 38 lev20 99 Cart_Site 36.60667 -97.48639 318.0 NaN POINT (-97.48639 36.60667) 2000-06-08 12:00:00
7 Cart_Site 09:06:2000 12:00:00 161 0.261388 0.211686 0.049702 0.805347 0.006535 0.037282 ... 7 lev20 99 Cart_Site 36.60667 -97.48639 318.0 NaN POINT (-97.48639 36.60667) 2000-06-09 12:00:00
8 Cart_Site 11:06:2000 12:00:00 163 0.083175 0.055649 0.027526 0.668308 0.005265 0.007773 ... 6 lev20 99 Cart_Site 36.60667 -97.48639 318.0 NaN POINT (-97.48639 36.60667) 2000-06-11 12:00:00
9 Cart_Site 12:06:2000 12:00:00 164 0.156430 0.084181 0.072250 0.539609 0.004594 0.012143 ... 9 lev20 99 Cart_Site 36.60667 -97.48639 318.0 NaN POINT (-97.48639 36.60667) 2000-06-12 12:00:00
10 Cart_Site 13:06:2000 12:00:00 165 0.152815 0.069873 0.082942 0.457893 0.004385 0.010806 ... 16 lev20 99 Cart_Site 36.60667 -97.48639 318.0 NaN POINT (-97.48639 36.60667) 2000-06-13 12:00:00

11 rows × 37 columns

Visualize results on Map screen¶

In [4]:
Copied!
from folium import (
    GeoJson,
    LayerControl,
    Map
)
from folium.plugins import (
    Fullscreen
)
from IPython.display import (
    display,
    HTML
)

map: Map = Map()
layer_control = LayerControl(position="topright", collapsed=True)
fullscreen = Fullscreen()
style = {"fillColor": "#00000000", "color": "#0000ff", "weight": 1}

footprints: GeoJson = GeoJson(
    geoparquet_data.dissolve(by='AERONET_Site').to_json(default=str),
    name="Stac Item footprints",
    style_function=lambda x: style,
    control=True,
)

footprints.add_to(map)
layer_control.add_to(map)
fullscreen.add_to(map)
map.fit_bounds(map.get_bounds()) # type: ignore not to important for the demo
map
from folium import ( GeoJson, LayerControl, Map ) from folium.plugins import ( Fullscreen ) from IPython.display import ( display, HTML ) map: Map = Map() layer_control = LayerControl(position="topright", collapsed=True) fullscreen = Fullscreen() style = {"fillColor": "#00000000", "color": "#0000ff", "weight": 1} footprints: GeoJson = GeoJson( geoparquet_data.dissolve(by='AERONET_Site').to_json(default=str), name="Stac Item footprints", style_function=lambda x: style, control=True, ) footprints.add_to(map) layer_control.add_to(map) fullscreen.add_to(map) map.fit_bounds(map.get_bounds()) # type: ignore not to important for the demo map
Out[4]:
Make this Notebook Trusted to load map: File -> Trust Notebook
Previous Next

Apache License, Version 2.0

Built with MkDocs using a theme provided by Read the Docs.
Terradue/pygeofilter-aeronet « Previous Next »