geodatasim 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- geodatasim-0.1.0/LICENSE +21 -0
- geodatasim-0.1.0/MANIFEST.in +7 -0
- geodatasim-0.1.0/PKG-INFO +242 -0
- geodatasim-0.1.0/README.md +199 -0
- geodatasim-0.1.0/examples/basic_usage.py +175 -0
- geodatasim-0.1.0/geodatasim/__init__.py +30 -0
- geodatasim-0.1.0/geodatasim/api/__init__.py +11 -0
- geodatasim-0.1.0/geodatasim/api/airports.py +55 -0
- geodatasim-0.1.0/geodatasim/api/openweather.py +52 -0
- geodatasim-0.1.0/geodatasim/api/worldbank.py +228 -0
- geodatasim-0.1.0/geodatasim/core/__init__.py +11 -0
- geodatasim-0.1.0/geodatasim/core/city.py +352 -0
- geodatasim-0.1.0/geodatasim/core/config.py +227 -0
- geodatasim-0.1.0/geodatasim/data/__init__.py +17 -0
- geodatasim-0.1.0/geodatasim/data/static.py +739 -0
- geodatasim-0.1.0/geodatasim/models/__init__.py +12 -0
- geodatasim-0.1.0/geodatasim/models/geographic.py +53 -0
- geodatasim-0.1.0/geodatasim/models/indicators.py +128 -0
- geodatasim-0.1.0/geodatasim/utils/__init__.py +14 -0
- geodatasim-0.1.0/geodatasim/utils/cache.py +194 -0
- geodatasim-0.1.0/geodatasim/utils/distance.py +118 -0
- geodatasim-0.1.0/geodatasim/utils/similarity.py +203 -0
- geodatasim-0.1.0/geodatasim/version.py +19 -0
- geodatasim-0.1.0/geodatasim.egg-info/PKG-INFO +242 -0
- geodatasim-0.1.0/geodatasim.egg-info/SOURCES.txt +28 -0
- geodatasim-0.1.0/geodatasim.egg-info/dependency_links.txt +1 -0
- geodatasim-0.1.0/geodatasim.egg-info/requires.txt +19 -0
- geodatasim-0.1.0/geodatasim.egg-info/top_level.txt +1 -0
- geodatasim-0.1.0/pyproject.toml +86 -0
- geodatasim-0.1.0/setup.cfg +4 -0
geodatasim-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Teyfik Oz
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: geodatasim
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Geographic + Socioeconomic + Climate intelligence library for city data analysis
|
|
5
|
+
Author-email: Teyfik Oz <teyfikoz@example.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/teyfikoz/GeoDataSim
|
|
8
|
+
Project-URL: Repository, https://github.com/teyfikoz/GeoDataSim
|
|
9
|
+
Project-URL: Documentation, https://github.com/teyfikoz/GeoDataSim/docs
|
|
10
|
+
Project-URL: Issues, https://github.com/teyfikoz/GeoDataSim/issues
|
|
11
|
+
Keywords: geography,geospatial,city-data,socioeconomic,climate,world-bank,urban-planning,data-science,gis,location-intelligence
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Intended Audience :: Science/Research
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Topic :: Scientific/Engineering :: GIS
|
|
21
|
+
Classifier: Topic :: Scientific/Engineering :: Information Analysis
|
|
22
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
23
|
+
Requires-Python: >=3.10
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
License-File: LICENSE
|
|
26
|
+
Requires-Dist: requests>=2.31.0
|
|
27
|
+
Requires-Dist: pandas>=2.0.0
|
|
28
|
+
Requires-Dist: numpy>=1.24.0
|
|
29
|
+
Requires-Dist: python-dateutil>=2.8.0
|
|
30
|
+
Provides-Extra: dev
|
|
31
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
32
|
+
Requires-Dist: pytest-cov>=4.0; extra == "dev"
|
|
33
|
+
Requires-Dist: black>=23.0; extra == "dev"
|
|
34
|
+
Requires-Dist: ruff>=0.1.0; extra == "dev"
|
|
35
|
+
Requires-Dist: mypy>=1.0; extra == "dev"
|
|
36
|
+
Provides-Extra: weather
|
|
37
|
+
Requires-Dist: pyowm>=3.3.0; extra == "weather"
|
|
38
|
+
Provides-Extra: full
|
|
39
|
+
Requires-Dist: pyowm>=3.3.0; extra == "full"
|
|
40
|
+
Requires-Dist: geopy>=2.4.0; extra == "full"
|
|
41
|
+
Requires-Dist: pycountry>=23.0; extra == "full"
|
|
42
|
+
Dynamic: license-file
|
|
43
|
+
|
|
44
|
+
# GeoDataSim
|
|
45
|
+
|
|
46
|
+
**The Ultimate Geographic + Socioeconomic + Climate Intelligence Library**
|
|
47
|
+
|
|
48
|
+
Create intelligent city profiles with a single line of code. No API keys needed for most features, completely free and open-source.
|
|
49
|
+
|
|
50
|
+
## Features
|
|
51
|
+
|
|
52
|
+
- 🌍 **Geographic Intelligence** - Population, coordinates, timezones, regions
|
|
53
|
+
- 💰 **Economic Data** - GDP per capita, HDI, development indicators
|
|
54
|
+
- ✈️ **Travel Intelligence** - Nearby airports, distances, routes
|
|
55
|
+
- 🌤️ **Climate Data** - Weather patterns, climate zones, temperature ranges
|
|
56
|
+
- 🏙️ **City Similarity** - Find similar cities based on multiple dimensions
|
|
57
|
+
- 📊 **Rich Indicators** - 50+ socioeconomic indicators from World Bank
|
|
58
|
+
- 🔄 **Smart Caching** - Fast responses with intelligent data caching
|
|
59
|
+
- 🆓 **Mostly Free** - Uses public domain data sources (World Bank, OurAirports, UN)
|
|
60
|
+
|
|
61
|
+
## Quick Start
|
|
62
|
+
|
|
63
|
+
```python
|
|
64
|
+
from geodatasim import City
|
|
65
|
+
|
|
66
|
+
# Create a city profile
|
|
67
|
+
istanbul = City("Istanbul")
|
|
68
|
+
|
|
69
|
+
# Basic info
|
|
70
|
+
print(istanbul.population) # 15,462,452
|
|
71
|
+
print(istanbul.country) # Turkey
|
|
72
|
+
print(istanbul.coordinates) # (41.0082, 28.9784)
|
|
73
|
+
|
|
74
|
+
# Economic indicators
|
|
75
|
+
print(istanbul.gdp_per_capita) # From World Bank
|
|
76
|
+
print(istanbul.hdi) # Human Development Index
|
|
77
|
+
|
|
78
|
+
# Climate
|
|
79
|
+
print(istanbul.climate_zone) # Mediterranean
|
|
80
|
+
print(istanbul.avg_temperature) # 14.6°C
|
|
81
|
+
|
|
82
|
+
# Travel
|
|
83
|
+
print(istanbul.nearby_airports) # [IST, SAW, ...]
|
|
84
|
+
print(istanbul.timezone) # Europe/Istanbul
|
|
85
|
+
|
|
86
|
+
# Find similar cities
|
|
87
|
+
similar = istanbul.find_similar(n=5)
|
|
88
|
+
print(similar) # [Athens, Barcelona, Rome, ...]
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## Installation
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
# Basic installation (no API keys needed)
|
|
95
|
+
pip install geodatasim
|
|
96
|
+
|
|
97
|
+
# With real-time weather (requires free OpenWeather API key)
|
|
98
|
+
pip install geodatasim[weather]
|
|
99
|
+
|
|
100
|
+
# Full installation
|
|
101
|
+
pip install geodatasim[full]
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## Data Sources
|
|
105
|
+
|
|
106
|
+
All data from legal, public domain sources:
|
|
107
|
+
|
|
108
|
+
- **[World Bank Open Data](https://data.worldbank.org)** - Economic indicators (Public Domain)
|
|
109
|
+
- **[OurAirports](https://ourairports.com/data/)** - Airport data (Public Domain, MIT License)
|
|
110
|
+
- **[Open-Meteo](https://open-meteo.com/)** - Climate data (Open Source, Free)
|
|
111
|
+
- **UN Data** - Country statistics (Open License)
|
|
112
|
+
- **Natural Earth** - Geographic boundaries (Public Domain)
|
|
113
|
+
|
|
114
|
+
## Features (v0.1.0)
|
|
115
|
+
|
|
116
|
+
### Core Features
|
|
117
|
+
- ✅ City class with 50+ attributes
|
|
118
|
+
- ✅ World Bank API integration (GDP, HDI, indicators)
|
|
119
|
+
- ✅ OurAirports integration (nearby airports)
|
|
120
|
+
- ✅ Climate zone classification
|
|
121
|
+
- ✅ City similarity algorithm
|
|
122
|
+
- ✅ Smart caching system (90-day cache)
|
|
123
|
+
- ✅ Built-in dataset for 500+ major cities
|
|
124
|
+
|
|
125
|
+
### Upcoming (v0.2.0+)
|
|
126
|
+
- 🔄 Real-time weather integration
|
|
127
|
+
- 🔄 UN Data indicators
|
|
128
|
+
- 🔄 Cost of living estimates
|
|
129
|
+
- 🔄 Safety indices
|
|
130
|
+
- 🔄 Cultural dimensions
|
|
131
|
+
- 🔄 Travel purpose integration (from travelpurpose library)
|
|
132
|
+
- 🔄 Ethnic diversity data (from ethnidata library)
|
|
133
|
+
|
|
134
|
+
## Use Cases
|
|
135
|
+
|
|
136
|
+
- 📊 **Data Science** - City embeddings for ML models
|
|
137
|
+
- 🗺️ **Urban Planning** - Compare cities, analyze development
|
|
138
|
+
- ✈️ **Travel Tech** - Destination recommendations, similarity search
|
|
139
|
+
- 💼 **Business Intelligence** - Market analysis, expansion planning
|
|
140
|
+
- 🎓 **Research** - Academic studies, geographic analysis
|
|
141
|
+
- 📱 **App Development** - Location-based features, personalization
|
|
142
|
+
|
|
143
|
+
## Architecture
|
|
144
|
+
|
|
145
|
+
```
|
|
146
|
+
GeoDataSim
|
|
147
|
+
├── Static Dataset (500+ cities, instant response)
|
|
148
|
+
├── Cached API Data (World Bank, 90-day refresh)
|
|
149
|
+
└── Real-time APIs (Optional, user's API key)
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
**Smart 3-Layer Strategy:**
|
|
153
|
+
1. **Built-in data** - Instant, no API calls
|
|
154
|
+
2. **Cached data** - Fast, updated quarterly
|
|
155
|
+
3. **Real-time data** - Optional, for fresh data
|
|
156
|
+
|
|
157
|
+
## Example: City Comparison
|
|
158
|
+
|
|
159
|
+
```python
|
|
160
|
+
from geodatasim import City
|
|
161
|
+
|
|
162
|
+
cities = [City(name) for name in ["Istanbul", "Barcelona", "Athens"]]
|
|
163
|
+
|
|
164
|
+
for city in cities:
|
|
165
|
+
print(f"{city.name}:")
|
|
166
|
+
print(f" Population: {city.population:,}")
|
|
167
|
+
print(f" GDP/capita: ${city.gdp_per_capita:,.0f}")
|
|
168
|
+
print(f" Climate: {city.climate_zone}")
|
|
169
|
+
print(f" Airports: {len(city.nearby_airports)}")
|
|
170
|
+
print()
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
## Example: Find Similar Cities
|
|
174
|
+
|
|
175
|
+
```python
|
|
176
|
+
from geodatasim import City
|
|
177
|
+
|
|
178
|
+
paris = City("Paris")
|
|
179
|
+
|
|
180
|
+
# Find similar cities based on:
|
|
181
|
+
# - Population size
|
|
182
|
+
# - Economic development
|
|
183
|
+
# - Climate zone
|
|
184
|
+
# - Geographic region
|
|
185
|
+
similar = paris.find_similar(n=10)
|
|
186
|
+
|
|
187
|
+
for i, city in enumerate(similar, 1):
|
|
188
|
+
print(f"{i}. {city.name} (similarity: {city.similarity_score:.2%})")
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
## API Keys (Optional)
|
|
192
|
+
|
|
193
|
+
Most features work without any API keys. For real-time weather data:
|
|
194
|
+
|
|
195
|
+
```python
|
|
196
|
+
from geodatasim import Config
|
|
197
|
+
|
|
198
|
+
# Optional: Set API keys for enhanced features
|
|
199
|
+
Config.set_api_key("openweather", "your_free_api_key")
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
Get free API keys:
|
|
203
|
+
- OpenWeather: https://openweathermap.org/api (1,000 calls/day free)
|
|
204
|
+
- Open-Meteo: No API key needed! (Unlimited free)
|
|
205
|
+
|
|
206
|
+
## Performance
|
|
207
|
+
|
|
208
|
+
- **Built-in data**: < 1ms response time
|
|
209
|
+
- **Cached API data**: < 10ms response time
|
|
210
|
+
- **Real-time API**: < 500ms response time
|
|
211
|
+
- **City similarity**: < 100ms for 1000 cities
|
|
212
|
+
|
|
213
|
+
## Requirements
|
|
214
|
+
|
|
215
|
+
- Python >= 3.10
|
|
216
|
+
- requests >= 2.31.0
|
|
217
|
+
- pandas >= 2.0.0
|
|
218
|
+
- numpy >= 1.24.0
|
|
219
|
+
|
|
220
|
+
## License
|
|
221
|
+
|
|
222
|
+
MIT License - Free for commercial use
|
|
223
|
+
|
|
224
|
+
## Contributing
|
|
225
|
+
|
|
226
|
+
Contributions welcome! This library fills a real gap in the Python ecosystem.
|
|
227
|
+
|
|
228
|
+
## Links
|
|
229
|
+
|
|
230
|
+
- GitHub: https://github.com/teyfikoz/GeoDataSim
|
|
231
|
+
- PyPI: https://pypi.org/project/geodatasim/
|
|
232
|
+
- Documentation: https://github.com/teyfikoz/GeoDataSim/docs
|
|
233
|
+
|
|
234
|
+
---
|
|
235
|
+
|
|
236
|
+
**GeoDataSim v0.1.0: City Intelligence, Simplified.**
|
|
237
|
+
|
|
238
|
+
**Sources:**
|
|
239
|
+
- [World Bank Open Data API](https://api.worldbank.org)
|
|
240
|
+
- [OurAirports Open Data](https://ourairports.com/data/)
|
|
241
|
+
- [OpenWeatherMap API](https://openweathermap.org/api)
|
|
242
|
+
- [Open-Meteo Weather API](https://open-meteo.com/)
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
# GeoDataSim
|
|
2
|
+
|
|
3
|
+
**The Ultimate Geographic + Socioeconomic + Climate Intelligence Library**
|
|
4
|
+
|
|
5
|
+
Create intelligent city profiles with a single line of code. No API keys needed for most features, completely free and open-source.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- 🌍 **Geographic Intelligence** - Population, coordinates, timezones, regions
|
|
10
|
+
- 💰 **Economic Data** - GDP per capita, HDI, development indicators
|
|
11
|
+
- ✈️ **Travel Intelligence** - Nearby airports, distances, routes
|
|
12
|
+
- 🌤️ **Climate Data** - Weather patterns, climate zones, temperature ranges
|
|
13
|
+
- 🏙️ **City Similarity** - Find similar cities based on multiple dimensions
|
|
14
|
+
- 📊 **Rich Indicators** - 50+ socioeconomic indicators from World Bank
|
|
15
|
+
- 🔄 **Smart Caching** - Fast responses with intelligent data caching
|
|
16
|
+
- 🆓 **Mostly Free** - Uses public domain data sources (World Bank, OurAirports, UN)
|
|
17
|
+
|
|
18
|
+
## Quick Start
|
|
19
|
+
|
|
20
|
+
```python
|
|
21
|
+
from geodatasim import City
|
|
22
|
+
|
|
23
|
+
# Create a city profile
|
|
24
|
+
istanbul = City("Istanbul")
|
|
25
|
+
|
|
26
|
+
# Basic info
|
|
27
|
+
print(istanbul.population) # 15,462,452
|
|
28
|
+
print(istanbul.country) # Turkey
|
|
29
|
+
print(istanbul.coordinates) # (41.0082, 28.9784)
|
|
30
|
+
|
|
31
|
+
# Economic indicators
|
|
32
|
+
print(istanbul.gdp_per_capita) # From World Bank
|
|
33
|
+
print(istanbul.hdi) # Human Development Index
|
|
34
|
+
|
|
35
|
+
# Climate
|
|
36
|
+
print(istanbul.climate_zone) # Mediterranean
|
|
37
|
+
print(istanbul.avg_temperature) # 14.6°C
|
|
38
|
+
|
|
39
|
+
# Travel
|
|
40
|
+
print(istanbul.nearby_airports) # [IST, SAW, ...]
|
|
41
|
+
print(istanbul.timezone) # Europe/Istanbul
|
|
42
|
+
|
|
43
|
+
# Find similar cities
|
|
44
|
+
similar = istanbul.find_similar(n=5)
|
|
45
|
+
print(similar) # [Athens, Barcelona, Rome, ...]
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Installation
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
# Basic installation (no API keys needed)
|
|
52
|
+
pip install geodatasim
|
|
53
|
+
|
|
54
|
+
# With real-time weather (requires free OpenWeather API key)
|
|
55
|
+
pip install geodatasim[weather]
|
|
56
|
+
|
|
57
|
+
# Full installation
|
|
58
|
+
pip install geodatasim[full]
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Data Sources
|
|
62
|
+
|
|
63
|
+
All data from legal, public domain sources:
|
|
64
|
+
|
|
65
|
+
- **[World Bank Open Data](https://data.worldbank.org)** - Economic indicators (Public Domain)
|
|
66
|
+
- **[OurAirports](https://ourairports.com/data/)** - Airport data (Public Domain, MIT License)
|
|
67
|
+
- **[Open-Meteo](https://open-meteo.com/)** - Climate data (Open Source, Free)
|
|
68
|
+
- **UN Data** - Country statistics (Open License)
|
|
69
|
+
- **Natural Earth** - Geographic boundaries (Public Domain)
|
|
70
|
+
|
|
71
|
+
## Features (v0.1.0)
|
|
72
|
+
|
|
73
|
+
### Core Features
|
|
74
|
+
- ✅ City class with 50+ attributes
|
|
75
|
+
- ✅ World Bank API integration (GDP, HDI, indicators)
|
|
76
|
+
- ✅ OurAirports integration (nearby airports)
|
|
77
|
+
- ✅ Climate zone classification
|
|
78
|
+
- ✅ City similarity algorithm
|
|
79
|
+
- ✅ Smart caching system (90-day cache)
|
|
80
|
+
- ✅ Built-in dataset for 500+ major cities
|
|
81
|
+
|
|
82
|
+
### Upcoming (v0.2.0+)
|
|
83
|
+
- 🔄 Real-time weather integration
|
|
84
|
+
- 🔄 UN Data indicators
|
|
85
|
+
- 🔄 Cost of living estimates
|
|
86
|
+
- 🔄 Safety indices
|
|
87
|
+
- 🔄 Cultural dimensions
|
|
88
|
+
- 🔄 Travel purpose integration (from travelpurpose library)
|
|
89
|
+
- 🔄 Ethnic diversity data (from ethnidata library)
|
|
90
|
+
|
|
91
|
+
## Use Cases
|
|
92
|
+
|
|
93
|
+
- 📊 **Data Science** - City embeddings for ML models
|
|
94
|
+
- 🗺️ **Urban Planning** - Compare cities, analyze development
|
|
95
|
+
- ✈️ **Travel Tech** - Destination recommendations, similarity search
|
|
96
|
+
- 💼 **Business Intelligence** - Market analysis, expansion planning
|
|
97
|
+
- 🎓 **Research** - Academic studies, geographic analysis
|
|
98
|
+
- 📱 **App Development** - Location-based features, personalization
|
|
99
|
+
|
|
100
|
+
## Architecture
|
|
101
|
+
|
|
102
|
+
```
|
|
103
|
+
GeoDataSim
|
|
104
|
+
├── Static Dataset (500+ cities, instant response)
|
|
105
|
+
├── Cached API Data (World Bank, 90-day refresh)
|
|
106
|
+
└── Real-time APIs (Optional, user's API key)
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
**Smart 3-Layer Strategy:**
|
|
110
|
+
1. **Built-in data** - Instant, no API calls
|
|
111
|
+
2. **Cached data** - Fast, updated quarterly
|
|
112
|
+
3. **Real-time data** - Optional, for fresh data
|
|
113
|
+
|
|
114
|
+
## Example: City Comparison
|
|
115
|
+
|
|
116
|
+
```python
|
|
117
|
+
from geodatasim import City
|
|
118
|
+
|
|
119
|
+
cities = [City(name) for name in ["Istanbul", "Barcelona", "Athens"]]
|
|
120
|
+
|
|
121
|
+
for city in cities:
|
|
122
|
+
print(f"{city.name}:")
|
|
123
|
+
print(f" Population: {city.population:,}")
|
|
124
|
+
print(f" GDP/capita: ${city.gdp_per_capita:,.0f}")
|
|
125
|
+
print(f" Climate: {city.climate_zone}")
|
|
126
|
+
print(f" Airports: {len(city.nearby_airports)}")
|
|
127
|
+
print()
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## Example: Find Similar Cities
|
|
131
|
+
|
|
132
|
+
```python
|
|
133
|
+
from geodatasim import City
|
|
134
|
+
|
|
135
|
+
paris = City("Paris")
|
|
136
|
+
|
|
137
|
+
# Find similar cities based on:
|
|
138
|
+
# - Population size
|
|
139
|
+
# - Economic development
|
|
140
|
+
# - Climate zone
|
|
141
|
+
# - Geographic region
|
|
142
|
+
similar = paris.find_similar(n=10)
|
|
143
|
+
|
|
144
|
+
for i, city in enumerate(similar, 1):
|
|
145
|
+
print(f"{i}. {city.name} (similarity: {city.similarity_score:.2%})")
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
## API Keys (Optional)
|
|
149
|
+
|
|
150
|
+
Most features work without any API keys. For real-time weather data:
|
|
151
|
+
|
|
152
|
+
```python
|
|
153
|
+
from geodatasim import Config
|
|
154
|
+
|
|
155
|
+
# Optional: Set API keys for enhanced features
|
|
156
|
+
Config.set_api_key("openweather", "your_free_api_key")
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
Get free API keys:
|
|
160
|
+
- OpenWeather: https://openweathermap.org/api (1,000 calls/day free)
|
|
161
|
+
- Open-Meteo: No API key needed! (Unlimited free)
|
|
162
|
+
|
|
163
|
+
## Performance
|
|
164
|
+
|
|
165
|
+
- **Built-in data**: < 1ms response time
|
|
166
|
+
- **Cached API data**: < 10ms response time
|
|
167
|
+
- **Real-time API**: < 500ms response time
|
|
168
|
+
- **City similarity**: < 100ms for 1000 cities
|
|
169
|
+
|
|
170
|
+
## Requirements
|
|
171
|
+
|
|
172
|
+
- Python >= 3.10
|
|
173
|
+
- requests >= 2.31.0
|
|
174
|
+
- pandas >= 2.0.0
|
|
175
|
+
- numpy >= 1.24.0
|
|
176
|
+
|
|
177
|
+
## License
|
|
178
|
+
|
|
179
|
+
MIT License - Free for commercial use
|
|
180
|
+
|
|
181
|
+
## Contributing
|
|
182
|
+
|
|
183
|
+
Contributions welcome! This library fills a real gap in the Python ecosystem.
|
|
184
|
+
|
|
185
|
+
## Links
|
|
186
|
+
|
|
187
|
+
- GitHub: https://github.com/teyfikoz/GeoDataSim
|
|
188
|
+
- PyPI: https://pypi.org/project/geodatasim/
|
|
189
|
+
- Documentation: https://github.com/teyfikoz/GeoDataSim/docs
|
|
190
|
+
|
|
191
|
+
---
|
|
192
|
+
|
|
193
|
+
**GeoDataSim v0.1.0: City Intelligence, Simplified.**
|
|
194
|
+
|
|
195
|
+
**Sources:**
|
|
196
|
+
- [World Bank Open Data API](https://api.worldbank.org)
|
|
197
|
+
- [OurAirports Open Data](https://ourairports.com/data/)
|
|
198
|
+
- [OpenWeatherMap API](https://openweathermap.org/api)
|
|
199
|
+
- [Open-Meteo Weather API](https://open-meteo.com/)
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Basic usage examples for GeoDataSim.
|
|
3
|
+
|
|
4
|
+
Run this file to see GeoDataSim in action!
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from geodatasim import City, set_config
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def example_basic():
|
|
11
|
+
"""Basic city data retrieval."""
|
|
12
|
+
print("=" * 60)
|
|
13
|
+
print("EXAMPLE 1: Basic City Data")
|
|
14
|
+
print("=" * 60)
|
|
15
|
+
|
|
16
|
+
# Create a city object
|
|
17
|
+
istanbul = City("Istanbul")
|
|
18
|
+
|
|
19
|
+
# Access basic info
|
|
20
|
+
print(f"\nCity: {istanbul.name}")
|
|
21
|
+
print(f"Country: {istanbul.country_name}")
|
|
22
|
+
print(f"Population: {istanbul.population:,}")
|
|
23
|
+
print(f"Coordinates: {istanbul.coordinates}")
|
|
24
|
+
print(f"Timezone: {istanbul.timezone}")
|
|
25
|
+
print()
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def example_economic_data():
|
|
29
|
+
"""Economic and development indicators."""
|
|
30
|
+
print("=" * 60)
|
|
31
|
+
print("EXAMPLE 2: Economic Indicators")
|
|
32
|
+
print("=" * 60)
|
|
33
|
+
|
|
34
|
+
cities = ["Istanbul", "London", "Tokyo", "New York"]
|
|
35
|
+
|
|
36
|
+
for city_name in cities:
|
|
37
|
+
city = City(city_name)
|
|
38
|
+
print(f"\n{city.name}, {city.country_name}:")
|
|
39
|
+
print(f" GDP per capita: ${city.gdp_per_capita:,.0f}" if city.gdp_per_capita else " GDP: N/A")
|
|
40
|
+
print(f" HDI: {city.hdi:.3f}" if city.hdi else " HDI: N/A")
|
|
41
|
+
print(f" Life expectancy: {city.life_expectancy:.1f} years" if city.life_expectancy else " Life exp: N/A")
|
|
42
|
+
|
|
43
|
+
print()
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def example_distance():
|
|
47
|
+
"""Calculate distances between cities."""
|
|
48
|
+
print("=" * 60)
|
|
49
|
+
print("EXAMPLE 3: Distance Calculation")
|
|
50
|
+
print("=" * 60)
|
|
51
|
+
|
|
52
|
+
istanbul = City("Istanbul")
|
|
53
|
+
cities = [City(name) for name in ["Ankara", "Athens", "Rome", "Paris"]]
|
|
54
|
+
|
|
55
|
+
print(f"\nDistances from {istanbul.name}:\n")
|
|
56
|
+
|
|
57
|
+
for city in cities:
|
|
58
|
+
distance = istanbul.distance_to(city)
|
|
59
|
+
if distance:
|
|
60
|
+
print(f" → {city.name:15s}: {distance:6.0f} km")
|
|
61
|
+
|
|
62
|
+
print()
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def example_similarity():
|
|
66
|
+
"""Find similar cities."""
|
|
67
|
+
print("=" * 60)
|
|
68
|
+
print("EXAMPLE 4: Find Similar Cities")
|
|
69
|
+
print("=" * 60)
|
|
70
|
+
|
|
71
|
+
istanbul = City("Istanbul")
|
|
72
|
+
|
|
73
|
+
print(f"\nCities similar to {istanbul.name}:\n")
|
|
74
|
+
|
|
75
|
+
similar_cities = istanbul.find_similar(n=10)
|
|
76
|
+
|
|
77
|
+
for i, city in enumerate(similar_cities, 1):
|
|
78
|
+
similarity_score = getattr(city, 'similarity_score', 0)
|
|
79
|
+
print(f" {i:2d}. {city.name:20s} ({city.country_name:20s}) - {similarity_score:.1%} similar")
|
|
80
|
+
|
|
81
|
+
print()
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def example_city_comparison():
|
|
85
|
+
"""Compare multiple cities."""
|
|
86
|
+
print("=" * 60)
|
|
87
|
+
print("EXAMPLE 5: City Comparison")
|
|
88
|
+
print("=" * 60)
|
|
89
|
+
|
|
90
|
+
cities = [City(name) for name in ["Barcelona", "Athens", "Istanbul", "Lisbon"]]
|
|
91
|
+
|
|
92
|
+
print("\nMediterranean Cities Comparison:\n")
|
|
93
|
+
print(f"{'City':<15} {'Population':>12} {'GDP/capita':>12} {'Climate':>10} {'HDI':>6}")
|
|
94
|
+
print("-" * 60)
|
|
95
|
+
|
|
96
|
+
for city in cities:
|
|
97
|
+
pop = f"{city.population:,}" if city.population else "N/A"
|
|
98
|
+
gdp = f"${city.gdp_per_capita:,.0f}" if city.gdp_per_capita else "N/A"
|
|
99
|
+
climate = city.climate_zone or "N/A"
|
|
100
|
+
hdi = f"{city.hdi:.3f}" if city.hdi else "N/A"
|
|
101
|
+
|
|
102
|
+
print(f"{city.name:<15} {pop:>12} {gdp:>12} {climate:>10} {hdi:>6}")
|
|
103
|
+
|
|
104
|
+
print()
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
def example_climate():
|
|
108
|
+
"""Climate data."""
|
|
109
|
+
print("=" * 60)
|
|
110
|
+
print("EXAMPLE 6: Climate Data")
|
|
111
|
+
print("=" * 60)
|
|
112
|
+
|
|
113
|
+
cities = [City(name) for name in ["Singapore", "Oslo", "Dubai", "Sydney"]]
|
|
114
|
+
|
|
115
|
+
print("\nClimate Diversity:\n")
|
|
116
|
+
|
|
117
|
+
for city in cities:
|
|
118
|
+
climate = city.climate_zone or "Unknown"
|
|
119
|
+
temp = f"{city.avg_temperature:.1f}°C" if city.avg_temperature else "N/A"
|
|
120
|
+
|
|
121
|
+
print(f" {city.name:15s}: {climate:5s} climate, avg temp: {temp}")
|
|
122
|
+
|
|
123
|
+
print()
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
def example_data_export():
|
|
127
|
+
"""Export city data to dictionary."""
|
|
128
|
+
print("=" * 60)
|
|
129
|
+
print("EXAMPLE 7: Data Export")
|
|
130
|
+
print("=" * 60)
|
|
131
|
+
|
|
132
|
+
paris = City("Paris")
|
|
133
|
+
|
|
134
|
+
print(f"\nFull data for {paris.name}:\n")
|
|
135
|
+
|
|
136
|
+
data = paris.to_dict()
|
|
137
|
+
|
|
138
|
+
import json
|
|
139
|
+
print(json.dumps(data, indent=2))
|
|
140
|
+
|
|
141
|
+
print()
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
def main():
|
|
145
|
+
"""Run all examples."""
|
|
146
|
+
print("\n")
|
|
147
|
+
print("╔" + "═" * 58 + "╗")
|
|
148
|
+
print("║" + " " * 10 + "GeoDataSim v0.1.0 - Example Usage" + " " * 14 + "║")
|
|
149
|
+
print("╚" + "═" * 58 + "╝")
|
|
150
|
+
print()
|
|
151
|
+
|
|
152
|
+
# Disable warnings for cleaner output
|
|
153
|
+
set_config(show_warnings=False)
|
|
154
|
+
|
|
155
|
+
# Run examples
|
|
156
|
+
example_basic()
|
|
157
|
+
example_economic_data()
|
|
158
|
+
example_distance()
|
|
159
|
+
example_similarity()
|
|
160
|
+
example_city_comparison()
|
|
161
|
+
example_climate()
|
|
162
|
+
example_data_export()
|
|
163
|
+
|
|
164
|
+
print("=" * 60)
|
|
165
|
+
print("Examples completed!")
|
|
166
|
+
print("=" * 60)
|
|
167
|
+
print("\nTry creating your own City objects:")
|
|
168
|
+
print(" >>> from geodatasim import City")
|
|
169
|
+
print(" >>> city = City('Your City')")
|
|
170
|
+
print(" >>> print(city.to_dict())")
|
|
171
|
+
print()
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
if __name__ == "__main__":
|
|
175
|
+
main()
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"""
|
|
2
|
+
GeoDataSim - Geographic + Socioeconomic + Climate Intelligence Library
|
|
3
|
+
|
|
4
|
+
Create intelligent city profiles with a single line of code.
|
|
5
|
+
All data from public domain sources (World Bank, OurAirports, UN).
|
|
6
|
+
|
|
7
|
+
Quick Start:
|
|
8
|
+
>>> from geodatasim import City
|
|
9
|
+
>>> istanbul = City("Istanbul")
|
|
10
|
+
>>> print(istanbul.population, istanbul.gdp_per_capita)
|
|
11
|
+
>>> similar = istanbul.find_similar(n=5)
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
__version__ = "0.1.0"
|
|
15
|
+
|
|
16
|
+
from .core.city import City
|
|
17
|
+
from .core.config import Config, get_config, set_config
|
|
18
|
+
from .models.indicators import EconomicIndicators, ClimateProfile
|
|
19
|
+
from .utils.similarity import CitySimilarity
|
|
20
|
+
|
|
21
|
+
__all__ = [
|
|
22
|
+
"__version__",
|
|
23
|
+
"City",
|
|
24
|
+
"Config",
|
|
25
|
+
"get_config",
|
|
26
|
+
"set_config",
|
|
27
|
+
"EconomicIndicators",
|
|
28
|
+
"ClimateProfile",
|
|
29
|
+
"CitySimilarity",
|
|
30
|
+
]
|