CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-meteostat

Access and analyze historical weather and climate data with Python.

Pending
Overview
Eval results
Files

geographic-points.mddocs/

Geographic Point Data

The Point class enables automatic weather station selection and data interpolation for any geographic location. It intelligently selects nearby stations and can interpolate data spatially using distance and altitude weighting algorithms.

Capabilities

Point Initialization

Create a geographic point with coordinates and optional altitude for weather data retrieval.

class Point:
    def __init__(self, lat: float, lon: float, alt: int = None) -> None:
        """
        Initialize a geographic point for weather data access.
        
        Parameters:
        - lat: float, latitude in decimal degrees (-90 to 90)
        - lon: float, longitude in decimal degrees (-180 to 180)
        - alt: int, optional altitude in meters above sea level
        """

Station Selection

Automatically select optimal weather stations for the geographic point based on proximity, altitude, and data availability.

def get_stations(self, freq: str = None, start: datetime = None, end: datetime = None, model: bool = True) -> pd.DataFrame:
    """
    Get list of nearby weather stations for the point.
    
    Parameters:
    - freq: str, optional data frequency ('hourly', 'daily', 'monthly')
    - start: datetime, optional start date for data availability check
    - end: datetime, optional end date for data availability check  
    - model: bool, whether to include model data sources
    
    Returns:
    pandas.DataFrame with selected stations and their metadata
    """

Properties

Access point characteristics and selected weather stations.

@property
def alt(self) -> int:
    """
    Get the point's altitude in meters.
    
    Returns:
    int, altitude in meters above sea level
    """

@property  
def stations(self) -> pd.Index:
    """
    Get the point's selected weather station IDs.
    
    Returns:
    pandas.Index of station identifiers
    """

Configuration Attributes

The Point class provides several configurable attributes that control station selection and interpolation behavior:

# Interpolation method
method: str = "nearest"          # "nearest" or "weighted"

# Station selection parameters
radius: int = 35000              # Maximum search radius in meters
alt_range: int = 350             # Maximum altitude difference in meters  
max_count: int = 4               # Maximum number of stations to use

# Interpolation settings
adapt_temp: bool = True          # Adjust temperature for altitude differences
weight_dist: float = 0.6         # Distance weighting factor (0-1)
weight_alt: float = 0.4          # Altitude weighting factor (0-1)

Usage Examples

Basic Point Creation

from meteostat import Point

# Create point for London, UK
london = Point(51.5074, -0.1278, 11)

# Create point without altitude (will be estimated)
paris = Point(48.8566, 2.3522)

print(f"London altitude: {london.alt}m")

Station Selection and Analysis

from datetime import datetime
from meteostat import Point

# Create point for Denver, Colorado (high altitude)
denver = Point(39.7392, -104.9903, 1609)

# Get stations for daily data in 2020
start = datetime(2020, 1, 1)
end = datetime(2020, 12, 31)

stations = denver.get_stations('daily', start, end)
print(f"Selected {len(stations)} stations for Denver")
print(stations[['name', 'distance', 'elevation', 'score']])

Using Point with Time Series

from datetime import datetime
from meteostat import Point, Daily

# Create point and get daily data
location = Point(40.7128, -74.0060)  # New York City
daily_data = Daily(location, datetime(2020, 1, 1), datetime(2020, 12, 31))

# The Point object automatically selects and weights nearby stations
data = daily_data.fetch()
print(f"Retrieved {len(data)} daily observations")

Custom Interpolation Settings

from meteostat import Point

# Create point with custom interpolation settings
point = Point(37.7749, -122.4194)  # San Francisco

# Customize station selection
point.method = "weighted"           # Use weighted interpolation
point.radius = 50000               # Expand search radius to 50km
point.max_count = 6                # Use up to 6 stations
point.alt_range = 500              # Allow 500m altitude difference

# Weight settings for interpolation
point.weight_dist = 0.7            # Prioritize distance over altitude
point.weight_alt = 0.3
point.adapt_temp = True            # Adjust temperature for altitude

Station Selection Algorithm

The Point class uses a sophisticated algorithm to select optimal weather stations:

  1. Proximity Search: Find all stations within the specified radius
  2. Altitude Filtering: Filter stations within the altitude range (if set)
  3. Inventory Check: Verify data availability for the requested period (if specified)
  4. Scoring: Calculate composite scores based on distance and altitude weights
  5. Selection: Choose the top-scoring stations up to the maximum count
  6. Fallback: If insufficient stations meet criteria, fill with best available options

The scoring formula combines normalized distance and altitude differences:

score = (1 - distance/radius) * weight_dist + (1 - |alt_diff|/alt_range) * weight_alt

Interpolation Methods

Nearest Station Method

Uses data from the single closest station with the highest composite score.

point.method = "nearest"

Weighted Interpolation Method

Combines data from multiple stations using inverse distance weighting and altitude adjustments.

point.method = "weighted"

When using weighted interpolation with altitude adaptation, temperature values are adjusted based on the standard atmospheric lapse rate (6.5°C per 1000m elevation difference).

Install with Tessl CLI

npx tessl i tessl/pypi-meteostat

docs

climate-normals.md

daily-data.md

data-processing.md

geographic-points.md

hourly-data.md

index.md

monthly-data.md

unit-conversions.md

weather-stations.md

tile.json