0
# Geographic Point Data
1
2
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.
3
4
## Capabilities
5
6
### Point Initialization
7
8
Create a geographic point with coordinates and optional altitude for weather data retrieval.
9
10
```python { .api }
11
class Point:
12
def __init__(self, lat: float, lon: float, alt: int = None) -> None:
13
"""
14
Initialize a geographic point for weather data access.
15
16
Parameters:
17
- lat: float, latitude in decimal degrees (-90 to 90)
18
- lon: float, longitude in decimal degrees (-180 to 180)
19
- alt: int, optional altitude in meters above sea level
20
"""
21
```
22
23
### Station Selection
24
25
Automatically select optimal weather stations for the geographic point based on proximity, altitude, and data availability.
26
27
```python { .api }
28
def get_stations(self, freq: str = None, start: datetime = None, end: datetime = None, model: bool = True) -> pd.DataFrame:
29
"""
30
Get list of nearby weather stations for the point.
31
32
Parameters:
33
- freq: str, optional data frequency ('hourly', 'daily', 'monthly')
34
- start: datetime, optional start date for data availability check
35
- end: datetime, optional end date for data availability check
36
- model: bool, whether to include model data sources
37
38
Returns:
39
pandas.DataFrame with selected stations and their metadata
40
"""
41
```
42
43
### Properties
44
45
Access point characteristics and selected weather stations.
46
47
```python { .api }
48
@property
49
def alt(self) -> int:
50
"""
51
Get the point's altitude in meters.
52
53
Returns:
54
int, altitude in meters above sea level
55
"""
56
57
@property
58
def stations(self) -> pd.Index:
59
"""
60
Get the point's selected weather station IDs.
61
62
Returns:
63
pandas.Index of station identifiers
64
"""
65
```
66
67
## Configuration Attributes
68
69
The Point class provides several configurable attributes that control station selection and interpolation behavior:
70
71
```python { .api }
72
# Interpolation method
73
method: str = "nearest" # "nearest" or "weighted"
74
75
# Station selection parameters
76
radius: int = 35000 # Maximum search radius in meters
77
alt_range: int = 350 # Maximum altitude difference in meters
78
max_count: int = 4 # Maximum number of stations to use
79
80
# Interpolation settings
81
adapt_temp: bool = True # Adjust temperature for altitude differences
82
weight_dist: float = 0.6 # Distance weighting factor (0-1)
83
weight_alt: float = 0.4 # Altitude weighting factor (0-1)
84
```
85
86
## Usage Examples
87
88
### Basic Point Creation
89
90
```python
91
from meteostat import Point
92
93
# Create point for London, UK
94
london = Point(51.5074, -0.1278, 11)
95
96
# Create point without altitude (will be estimated)
97
paris = Point(48.8566, 2.3522)
98
99
print(f"London altitude: {london.alt}m")
100
```
101
102
### Station Selection and Analysis
103
104
```python
105
from datetime import datetime
106
from meteostat import Point
107
108
# Create point for Denver, Colorado (high altitude)
109
denver = Point(39.7392, -104.9903, 1609)
110
111
# Get stations for daily data in 2020
112
start = datetime(2020, 1, 1)
113
end = datetime(2020, 12, 31)
114
115
stations = denver.get_stations('daily', start, end)
116
print(f"Selected {len(stations)} stations for Denver")
117
print(stations[['name', 'distance', 'elevation', 'score']])
118
```
119
120
### Using Point with Time Series
121
122
```python
123
from datetime import datetime
124
from meteostat import Point, Daily
125
126
# Create point and get daily data
127
location = Point(40.7128, -74.0060) # New York City
128
daily_data = Daily(location, datetime(2020, 1, 1), datetime(2020, 12, 31))
129
130
# The Point object automatically selects and weights nearby stations
131
data = daily_data.fetch()
132
print(f"Retrieved {len(data)} daily observations")
133
```
134
135
### Custom Interpolation Settings
136
137
```python
138
from meteostat import Point
139
140
# Create point with custom interpolation settings
141
point = Point(37.7749, -122.4194) # San Francisco
142
143
# Customize station selection
144
point.method = "weighted" # Use weighted interpolation
145
point.radius = 50000 # Expand search radius to 50km
146
point.max_count = 6 # Use up to 6 stations
147
point.alt_range = 500 # Allow 500m altitude difference
148
149
# Weight settings for interpolation
150
point.weight_dist = 0.7 # Prioritize distance over altitude
151
point.weight_alt = 0.3
152
point.adapt_temp = True # Adjust temperature for altitude
153
```
154
155
## Station Selection Algorithm
156
157
The Point class uses a sophisticated algorithm to select optimal weather stations:
158
159
1. **Proximity Search**: Find all stations within the specified radius
160
2. **Altitude Filtering**: Filter stations within the altitude range (if set)
161
3. **Inventory Check**: Verify data availability for the requested period (if specified)
162
4. **Scoring**: Calculate composite scores based on distance and altitude weights
163
5. **Selection**: Choose the top-scoring stations up to the maximum count
164
6. **Fallback**: If insufficient stations meet criteria, fill with best available options
165
166
The scoring formula combines normalized distance and altitude differences:
167
```
168
score = (1 - distance/radius) * weight_dist + (1 - |alt_diff|/alt_range) * weight_alt
169
```
170
171
## Interpolation Methods
172
173
### Nearest Station Method
174
175
Uses data from the single closest station with the highest composite score.
176
177
```python
178
point.method = "nearest"
179
```
180
181
### Weighted Interpolation Method
182
183
Combines data from multiple stations using inverse distance weighting and altitude adjustments.
184
185
```python
186
point.method = "weighted"
187
```
188
189
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).