# search_stations()


Search for weather stations matching specified criteria.


Usage

``` python
search_stations(
    *,
    name=None,
    country=None,
    country_code=None,
    state=None,
    lat_range=None,
    lon_range=None,
    has_recent_data=False
)
```


## Parameters


`name: str | None = None`  
Search for stations with names containing this string (case-insensitive).

`country: str | None = None`  
Filter by country name (case-insensitive, partial match).

`country_code: str | None = None`  
Filter by ISO 3166-1 alpha-2 country code (e.g., `"US"`, `"GB"`, `"FR"`). For convenience, you can also use the `wv.country` shorthand: `wv.country.US`, `wv.country.GB`, `wv.country.DE`, etc.

`state: str | None = None`  
Filter by US state or territory code (exact match, e.g., `"CA"`, `"NY"`, `"TX"`). For convenience, you can also use the `wv.state` shorthand: `wv.state.CA`, `wv.state.NY`, `wv.state.TX`, etc.

`lat_range: tuple[float, float] | None = None`  
Filter by latitude range as (min_lat, max_lat).

`lon_range: tuple[float, float] | None = None`  
Filter by longitude range as (min_lon, max_lon).

`has_recent_data: bool = ``False`  
If `True`, only return stations with data in the current or previous year.


## Returns


`pl.DataFrame`  
A DataFrame of stations matching the search criteria.


## Examples

Search for stations in California using the state shorthand:


``` python
import weathervault as wv

# Using wv.state shorthand (provides autocomplete)
ca_stations = wv.search_stations(state=wv.state.CA)

ca_stations
```


shape: (499, 14)

| id | usaf | wban | name | country_code | country | state | icao | lat | lon | elev | begin_date | end_date | tz_name |
|----|----|----|----|----|----|----|----|----|----|----|----|----|----|
| str | str | str | str | str | str | str | str | f64 | f64 | f64 | date | date | str |
| "690020-93218" | "690020" | "93218" | "JOLON HUNTER LIGGETT MIL RES" | "US" | "United States" | "CA" | "KHGT" | 36.0 | -121.233 | 317.0 | 1964-07-15 | 1997-04-01 | "America/Los_Angeles" |
| "690020-99999" | "690020" | "99999" | "JOLON HUNTER LIGGETT MIL RES" | "US" | "United States" | "CA" | "KHGT" | 36.0 | -121.233 | 317.0 | 2003-07-02 | 2003-08-01 | "America/Los_Angeles" |
| "690070-93217" | "690070" | "93217" | "FRITZSCHE AAF" | "US" | "United States" | "CA" | "KOAR" | 36.683 | -121.767 | 43.0 | 1960-04-04 | 1993-08-31 | "America/Los_Angeles" |
| "690080-99999" | "690080" | "99999" | "TARIN KOWT" | "AF" | "Afghanistan" | "CA" | "KQA7" | 32.6 | 65.87 | 1380.0 | 2003-06-16 | 2003-06-24 | "Asia/Kabul" |
| "690140-93101" | "690140" | "93101" | "EL TORO MCAS" | "US" | "United States" | "CA" | "KNZJ" | 33.667 | -117.733 | 116.7 | 1989-01-01 | 1997-12-31 | "America/Los_Angeles" |
| … | … | … | … | … | … | … | … | … | … | … | … | … | … |
| "999999-93243" | "999999" | "93243" | "MERCED 23 WSW" | "US" | "United States" | "CA" | "" | 37.238 | -120.883 | 23.8 | 2004-03-25 | 2025-08-28 | "America/Los_Angeles" |
| "999999-93245" | "999999" | "93245" | "BODEGA 6 WSW" | "US" | "United States" | "CA" | "" | 38.321 | -123.075 | 19.2 | 2008-06-14 | 2025-08-28 | "America/Los_Angeles" |
| "A06854-00115" | "A06854" | "00115" | "BIG BEAR CITY AIRPORT" | "US" | "United States" | "CA" | "KL35" | 34.264 | -116.854 | 2057.1 | 2014-07-31 | 2025-08-25 | "America/Los_Angeles" |
| "A07049-00320" | "A07049" | "00320" | "PETALUMA MUNICIPAL AIRPORT" | "US" | "United States" | "CA" | "KO69" | 38.25 | -122.6 | 27.1 | 2014-07-31 | 2025-08-25 | "America/Los_Angeles" |
| "A07053-00346" | "A07053" | "00346" | "TRINITY CENTER AIRPORT" | "US" | "United States" | "CA" | "KO86" | 40.983 | -122.694 | 728.2 | 2014-07-31 | 2025-08-25 | "America/Los_Angeles" |


Search by country code using the convenient shorthand:


``` python
# Using wv.country shorthand (provides autocomplete)
de_stations = wv.search_stations(country_code=wv.country.DE)

de_stations
```


shape: (503, 14)

| id | usaf | wban | name | country_code | country | state | icao | lat | lon | elev | begin_date | end_date | tz_name |
|----|----|----|----|----|----|----|----|----|----|----|----|----|----|
| str | str | str | str | str | str | str | str | f64 | f64 | f64 | date | date | str |
| "090910-99999" | "090910" | "99999" | "ARKONA (CAPE)     &" | "DE" | "Germany" | "" | "" | 54.683 | 13.433 | 42.0 | 1975-07-01 | 2002-07-29 | "Europe/Berlin" |
| "090930-99999" | "090930" | "99999" | "BOGUS GERMAN" | "DE" | "Germany" | "" | "" | null | null | null | 1990-12-03 | 1991-10-31 | null |
| "091610-99999" | "091610" | "99999" | "BOLTENHAGEN       &" | "DE" | "Germany" | "" | "" | 54.0 | 11.2 | 15.0 | 1975-07-01 | 1991-10-31 | "Europe/Berlin" |
| "091620-99999" | "091620" | "99999" | "SCHWERIN          &" | "DE" | "Germany" | "" | "" | 53.633 | 11.417 | 59.0 | 1975-07-01 | 1992-05-17 | "Europe/Berlin" |
| "091680-99999" | "091680" | "99999" | "BOGUS GERMAN" | "DE" | "Germany" | "" | "" | null | null | null | 1990-12-03 | 1991-10-30 | null |
| … | … | … | … | … | … | … | … | … | … | … | … | … | … |
| "119060-99999" | "119060" | "99999" | "LEST" | "DE" | "Germany" | "" | "" | 48.35 | 19.317 | 720.0 | 1952-11-06 | 1953-12-31 | "Europe/Bratislava" |
| "693664-99999" | "693664" | "99999" | "COTTBUS DREWITZ" | "DE" | "Germany" | "" | "EDCD" | 51.889 | 14.532 | 83.5 | 1981-01-15 | 1990-12-14 | "Europe/Berlin" |
| "749520-99999" | "749520" | "99999" | "SOSSENHEIM" | "DE" | "Germany" | "" | "" | 50.133 | 8.583 | 130.0 | 1946-08-31 | 1947-02-14 | "Europe/Berlin" |
| "749538-99999" | "749538" | "99999" | "OBERPFAFFENHOFEN GERMANY AD" | "DE" | "Germany" | "" | "" | 48.083 | 11.266 | 580.0 | 1946-08-14 | 1949-07-31 | "Europe/Berlin" |
| "999999-34196" | "999999" | "34196" | "GABLINGEN" | "DE" | "Germany" | "" | "EDOX" | 48.45 | 10.867 | 466.0 | 1963-09-10 | 1967-12-29 | "Europe/Berlin" |


Combine state and country filters:


``` python
# Find stations in California, US
us_ca = wv.search_stations(
    country_code=wv.country.US,
    state=wv.state.CA
)

us_ca
```


shape: (495, 14)

| id | usaf | wban | name | country_code | country | state | icao | lat | lon | elev | begin_date | end_date | tz_name |
|----|----|----|----|----|----|----|----|----|----|----|----|----|----|
| str | str | str | str | str | str | str | str | f64 | f64 | f64 | date | date | str |
| "690020-93218" | "690020" | "93218" | "JOLON HUNTER LIGGETT MIL RES" | "US" | "United States" | "CA" | "KHGT" | 36.0 | -121.233 | 317.0 | 1964-07-15 | 1997-04-01 | "America/Los_Angeles" |
| "690020-99999" | "690020" | "99999" | "JOLON HUNTER LIGGETT MIL RES" | "US" | "United States" | "CA" | "KHGT" | 36.0 | -121.233 | 317.0 | 2003-07-02 | 2003-08-01 | "America/Los_Angeles" |
| "690070-93217" | "690070" | "93217" | "FRITZSCHE AAF" | "US" | "United States" | "CA" | "KOAR" | 36.683 | -121.767 | 43.0 | 1960-04-04 | 1993-08-31 | "America/Los_Angeles" |
| "690140-93101" | "690140" | "93101" | "EL TORO MCAS" | "US" | "United States" | "CA" | "KNZJ" | 33.667 | -117.733 | 116.7 | 1989-01-01 | 1997-12-31 | "America/Los_Angeles" |
| "690150-93121" | "690150" | "93121" | "TWENTY NINE PALMS" | "US" | "United States" | "CA" | "KNXP" | 34.294 | -116.147 | 610.5 | 1990-01-02 | 2025-08-25 | "America/Los_Angeles" |
| … | … | … | … | … | … | … | … | … | … | … | … | … | … |
| "999999-93243" | "999999" | "93243" | "MERCED 23 WSW" | "US" | "United States" | "CA" | "" | 37.238 | -120.883 | 23.8 | 2004-03-25 | 2025-08-28 | "America/Los_Angeles" |
| "999999-93245" | "999999" | "93245" | "BODEGA 6 WSW" | "US" | "United States" | "CA" | "" | 38.321 | -123.075 | 19.2 | 2008-06-14 | 2025-08-28 | "America/Los_Angeles" |
| "A06854-00115" | "A06854" | "00115" | "BIG BEAR CITY AIRPORT" | "US" | "United States" | "CA" | "KL35" | 34.264 | -116.854 | 2057.1 | 2014-07-31 | 2025-08-25 | "America/Los_Angeles" |
| "A07049-00320" | "A07049" | "00320" | "PETALUMA MUNICIPAL AIRPORT" | "US" | "United States" | "CA" | "KO69" | 38.25 | -122.6 | 27.1 | 2014-07-31 | 2025-08-25 | "America/Los_Angeles" |
| "A07053-00346" | "A07053" | "00346" | "TRINITY CENTER AIRPORT" | "US" | "United States" | "CA" | "KO86" | 40.983 | -122.694 | 728.2 | 2014-07-31 | 2025-08-25 | "America/Los_Angeles" |


Search for stations within a bounding box:


``` python
within = wv.search_stations(
    lat_range=(37.0, 38.0),
    lon_range=(-122.5, -121.5)
)

within
```


shape: (48, 14)

| id | usaf | wban | name | country_code | country | state | icao | lat | lon | elev | begin_date | end_date | tz_name |
|----|----|----|----|----|----|----|----|----|----|----|----|----|----|
| str | str | str | str | str | str | str | str | f64 | f64 | f64 | date | date | str |
| "724927-23285" | "724927" | "23285" | "LIVERMORE MUNICIPAL ARPT" | "US" | "United States" | "CA" | "KLVK" | 37.693 | -121.815 | 119.8 | 2000-01-01 | 2025-08-27 | "America/Los_Angeles" |
| "724927-99999" | "724927" | "99999" | "LIVERMORE MUNICIPAL" | "US" | "United States" | "CA" | "KLVK" | 37.7 | -121.817 | 121.0 | 1973-06-25 | 1997-12-31 | "America/Los_Angeles" |
| "724930-23230" | "724930" | "23230" | "METRO OAKLAND INTL AIRPORT" | "US" | "United States" | "CA" | "KOAK" | 37.718 | -122.233 | 1.5 | 1943-01-01 | 2025-08-27 | "America/Los_Angeles" |
| "724930-99999" | "724930" | "99999" | "OAKLAND/METROP. OAK" | "US" | "United States" | "CA" | "KOAK" | 37.75 | -122.217 | 4.0 | 2000-01-01 | 2003-12-31 | "America/Los_Angeles" |
| "724935-93228" | "724935" | "93228" | "HAYWARD AIR TERM" | "US" | "United States" | "CA" | "KHWD" | 37.654 | -122.115 | 14.3 | 2000-01-01 | 2010-07-31 | "America/Los_Angeles" |
| … | … | … | … | … | … | … | … | … | … | … | … | … | … |
| "999999-23254" | "999999" | "23254" | "CONCORD CONCORD-BUCHANAN FIEL" | "US" | "United States" | "CA" | "KCCR" | 37.992 | -122.055 | 18.3 | 1969-01-01 | 1970-01-01 | "America/Los_Angeles" |
| "999999-23272" | "999999" | "23272" | "DOWNTOWN" | "US" | "United States" | "CA" | "" | 37.771 | -122.427 | 45.7 | 1945-01-01 | 2025-08-25 | "America/Los_Angeles" |
| "999999-23293" | "999999" | "23293" | "SAN JOSE MUNICIPAL AP" | "US" | "United States" | "CA" | "KSJC" | 37.359 | -121.924 | 15.2 | 1951-01-01 | 1972-12-31 | "America/Los_Angeles" |
| "999999-93211" | "999999" | "93211" | "OAKLAND NAS" | "US" | "United States" | "CA" | "NBJ" | 37.733 | -122.2 | 2.1 | 1949-06-01 | 1954-10-31 | "America/Los_Angeles" |
| "999999-93228" | "999999" | "93228" | "HAYWARD EXECUTIVE AIRPORT" | "US" | "United States" | "CA" | "KHWD" | 37.659 | -122.121 | 9.6 | 1998-09-02 | 1999-12-31 | "America/Los_Angeles" |
