geoai-py 0.1.6__tar.gz → 0.2.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.
- {geoai_py-0.1.6 → geoai_py-0.2.0}/.github/workflows/docs-build.yml +1 -0
- {geoai_py-0.1.6 → geoai_py-0.2.0}/.github/workflows/docs.yml +1 -0
- {geoai_py-0.1.6 → geoai_py-0.2.0}/.gitignore +2 -0
- geoai_py-0.2.0/PKG-INFO +130 -0
- geoai_py-0.2.0/README.md +86 -0
- geoai_py-0.2.0/docs/download.md +3 -0
- geoai_py-0.2.0/docs/examples/data_visualization.ipynb +385 -0
- geoai_py-0.2.0/docs/examples/download_data.ipynb +199 -0
- geoai_py-0.2.0/docs/examples/jupytext.toml +1 -0
- geoai_py-0.2.0/docs/extract.md +3 -0
- geoai_py-0.2.0/docs/index.md +86 -0
- geoai_py-0.2.0/docs/installation.md +119 -0
- geoai_py-0.2.0/docs/preprocess.md +3 -0
- geoai_py-0.2.0/geoai/__init__.py +33 -0
- {geoai_py-0.1.6 → geoai_py-0.2.0}/geoai/common.py +158 -1
- geoai_py-0.2.0/geoai/download.py +395 -0
- geoai_py-0.2.0/geoai/extract.py +832 -0
- geoai_py-0.2.0/geoai/preprocess.py +2008 -0
- geoai_py-0.2.0/geoai_py.egg-info/PKG-INFO +130 -0
- {geoai_py-0.1.6 → geoai_py-0.2.0}/geoai_py.egg-info/SOURCES.txt +9 -0
- geoai_py-0.2.0/geoai_py.egg-info/requires.txt +26 -0
- {geoai_py-0.1.6 → geoai_py-0.2.0}/mkdocs.yml +8 -3
- {geoai_py-0.1.6 → geoai_py-0.2.0}/pyproject.toml +7 -2
- {geoai_py-0.1.6 → geoai_py-0.2.0}/requirements.txt +8 -0
- geoai_py-0.1.6/PKG-INFO +0 -44
- geoai_py-0.1.6/README.md +0 -15
- geoai_py-0.1.6/docs/index.md +0 -15
- geoai_py-0.1.6/docs/installation.md +0 -21
- geoai_py-0.1.6/geoai/__init__.py +0 -8
- geoai_py-0.1.6/geoai_py.egg-info/PKG-INFO +0 -44
- geoai_py-0.1.6/geoai_py.egg-info/requires.txt +0 -9
- {geoai_py-0.1.6 → geoai_py-0.2.0}/.editorconfig +0 -0
- {geoai_py-0.1.6 → geoai_py-0.2.0}/.github/ISSUE_TEMPLATE/bug_report.md +0 -0
- {geoai_py-0.1.6 → geoai_py-0.2.0}/.github/ISSUE_TEMPLATE/config.yml +0 -0
- {geoai_py-0.1.6 → geoai_py-0.2.0}/.github/ISSUE_TEMPLATE/feature_request.md +0 -0
- {geoai_py-0.1.6 → geoai_py-0.2.0}/.github/dependabot.yml +0 -0
- {geoai_py-0.1.6 → geoai_py-0.2.0}/.github/workflows/macos.yml +0 -0
- {geoai_py-0.1.6 → geoai_py-0.2.0}/.github/workflows/pypi.yml +0 -0
- {geoai_py-0.1.6 → geoai_py-0.2.0}/.github/workflows/ubuntu.yml +0 -0
- {geoai_py-0.1.6 → geoai_py-0.2.0}/.github/workflows/windows.yml +0 -0
- {geoai_py-0.1.6 → geoai_py-0.2.0}/.pre-commit-config.yaml +0 -0
- {geoai_py-0.1.6 → geoai_py-0.2.0}/LICENSE +0 -0
- {geoai_py-0.1.6 → geoai_py-0.2.0}/MANIFEST.in +0 -0
- {geoai_py-0.1.6 → geoai_py-0.2.0}/docs/CNAME +0 -0
- {geoai_py-0.1.6 → geoai_py-0.2.0}/docs/changelog.md +0 -0
- {geoai_py-0.1.6 → geoai_py-0.2.0}/docs/common.md +0 -0
- {geoai_py-0.1.6 → geoai_py-0.2.0}/docs/contributing.md +0 -0
- {geoai_py-0.1.6 → geoai_py-0.2.0}/docs/examples/dataviz/lidar_viz.ipynb +0 -0
- {geoai_py-0.1.6 → geoai_py-0.2.0}/docs/examples/dataviz/raster_viz.ipynb +0 -0
- {geoai_py-0.1.6 → geoai_py-0.2.0}/docs/examples/dataviz/vector_viz.ipynb +0 -0
- {geoai_py-0.1.6 → geoai_py-0.2.0}/docs/examples/rastervision/semantic_segmentation.ipynb +0 -0
- {geoai_py-0.1.6 → geoai_py-0.2.0}/docs/examples/samgeo/arcgis.ipynb +0 -0
- {geoai_py-0.1.6 → geoai_py-0.2.0}/docs/examples/samgeo/automatic_mask_generator.ipynb +0 -0
- {geoai_py-0.1.6 → geoai_py-0.2.0}/docs/examples/samgeo/automatic_mask_generator_hq.ipynb +0 -0
- {geoai_py-0.1.6 → geoai_py-0.2.0}/docs/examples/samgeo/box_prompts.ipynb +0 -0
- {geoai_py-0.1.6 → geoai_py-0.2.0}/docs/examples/samgeo/fast_sam.ipynb +0 -0
- {geoai_py-0.1.6 → geoai_py-0.2.0}/docs/examples/samgeo/input_prompts.ipynb +0 -0
- {geoai_py-0.1.6 → geoai_py-0.2.0}/docs/examples/samgeo/input_prompts_hq.ipynb +0 -0
- {geoai_py-0.1.6 → geoai_py-0.2.0}/docs/examples/samgeo/maxar_open_data.ipynb +0 -0
- {geoai_py-0.1.6 → geoai_py-0.2.0}/docs/examples/samgeo/satellite-predictor.ipynb +0 -0
- {geoai_py-0.1.6 → geoai_py-0.2.0}/docs/examples/samgeo/satellite.ipynb +0 -0
- {geoai_py-0.1.6 → geoai_py-0.2.0}/docs/examples/samgeo/swimming_pools.ipynb +0 -0
- {geoai_py-0.1.6 → geoai_py-0.2.0}/docs/examples/samgeo/text_prompts.ipynb +0 -0
- {geoai_py-0.1.6 → geoai_py-0.2.0}/docs/examples/samgeo/text_prompts_batch.ipynb +0 -0
- {geoai_py-0.1.6 → geoai_py-0.2.0}/docs/faq.md +0 -0
- {geoai_py-0.1.6 → geoai_py-0.2.0}/docs/geoai.md +0 -0
- {geoai_py-0.1.6 → geoai_py-0.2.0}/docs/overrides/main.html +0 -0
- {geoai_py-0.1.6 → geoai_py-0.2.0}/docs/segmentation.md +0 -0
- {geoai_py-0.1.6 → geoai_py-0.2.0}/docs/usage.md +0 -0
- {geoai_py-0.1.6 → geoai_py-0.2.0}/geoai/geoai.py +0 -0
- {geoai_py-0.1.6 → geoai_py-0.2.0}/geoai/segmentation.py +0 -0
- {geoai_py-0.1.6 → geoai_py-0.2.0}/geoai_py.egg-info/dependency_links.txt +0 -0
- {geoai_py-0.1.6 → geoai_py-0.2.0}/geoai_py.egg-info/entry_points.txt +0 -0
- {geoai_py-0.1.6 → geoai_py-0.2.0}/geoai_py.egg-info/top_level.txt +0 -0
- {geoai_py-0.1.6 → geoai_py-0.2.0}/requirements_docs.txt +0 -0
- {geoai_py-0.1.6 → geoai_py-0.2.0}/setup.cfg +0 -0
- {geoai_py-0.1.6 → geoai_py-0.2.0}/tests/__init__.py +0 -0
- {geoai_py-0.1.6 → geoai_py-0.2.0}/tests/test_geoai.py +0 -0
geoai_py-0.2.0/PKG-INFO
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
|
+
Name: geoai-py
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: A Python package for using Artificial Intelligence (AI) with geospatial data
|
|
5
|
+
Author-email: Qiusheng Wu <giswqs@gmail.com>
|
|
6
|
+
License: MIT License
|
|
7
|
+
Project-URL: Homepage, https://github.com/opengeos/geoai
|
|
8
|
+
Keywords: geoai
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
+
Classifier: Natural Language :: English
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
17
|
+
Requires-Python: >=3.9
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
License-File: LICENSE
|
|
20
|
+
Requires-Dist: albumentations
|
|
21
|
+
Requires-Dist: geopandas
|
|
22
|
+
Requires-Dist: huggingface_hub
|
|
23
|
+
Requires-Dist: jupyter-server-proxy
|
|
24
|
+
Requires-Dist: leafmap
|
|
25
|
+
Requires-Dist: localtileserver
|
|
26
|
+
Requires-Dist: overturemaps
|
|
27
|
+
Requires-Dist: planetary_computer
|
|
28
|
+
Requires-Dist: pystac_client
|
|
29
|
+
Requires-Dist: rasterio
|
|
30
|
+
Requires-Dist: rioxarray
|
|
31
|
+
Requires-Dist: scikit-learn
|
|
32
|
+
Requires-Dist: segment-geospatial
|
|
33
|
+
Requires-Dist: torch
|
|
34
|
+
Requires-Dist: torchgeo
|
|
35
|
+
Requires-Dist: tqdm
|
|
36
|
+
Requires-Dist: transformers
|
|
37
|
+
Provides-Extra: download
|
|
38
|
+
Requires-Dist: pystac_client; extra == "download"
|
|
39
|
+
Requires-Dist: planetary_computer; extra == "download"
|
|
40
|
+
Requires-Dist: tqdm; extra == "download"
|
|
41
|
+
Requires-Dist: overturemaps; extra == "download"
|
|
42
|
+
Provides-Extra: all
|
|
43
|
+
Requires-Dist: geoai[download]; extra == "all"
|
|
44
|
+
|
|
45
|
+
# GeoAI: Artificial Intelligence for Geospatial Data
|
|
46
|
+
|
|
47
|
+
[](https://pypi.python.org/pypi/geoai-py)
|
|
48
|
+
[](https://pepy.tech/project/geoai-py)
|
|
49
|
+
[](https://anaconda.org/conda-forge/geoai)
|
|
50
|
+
[](https://anaconda.org/conda-forge/geoai)
|
|
51
|
+
[](https://github.com/conda-forge/geoai-py-feedstock)
|
|
52
|
+
[](https://opensource.org/licenses/MIT)
|
|
53
|
+
[](https://youtube.com/@giswqs)
|
|
54
|
+
|
|
55
|
+
**A powerful Python package for integrating Artificial Intelligence with geospatial data analysis and visualization**
|
|
56
|
+
|
|
57
|
+
GeoAI bridges the gap between AI and geospatial analysis, providing tools for processing, analyzing, and visualizing geospatial data using advanced machine learning techniques. Whether you're working with satellite imagery, LiDAR point clouds, or vector data, GeoAI offers intuitive interfaces to apply cutting-edge AI models.
|
|
58
|
+
|
|
59
|
+
- 📖 **Documentation:** [https://geoai.gishub.org](https://geoai.gishub.org)
|
|
60
|
+
- 💬 **Community:** [GitHub Discussions](https://github.com/opengeos/geoai/discussions)
|
|
61
|
+
- 🐛 **Issue Tracker:** [GitHub Issues](https://github.com/opengeos/geoai/issues)
|
|
62
|
+
|
|
63
|
+
## 🚀 Key Features
|
|
64
|
+
|
|
65
|
+
### 📊 Advanced Geospatial Data Visualization
|
|
66
|
+
|
|
67
|
+
- Interactive multi-layer visualization of vector, raster, and point cloud data
|
|
68
|
+
- Customizable styling and symbology
|
|
69
|
+
- Time-series data visualization capabilities
|
|
70
|
+
|
|
71
|
+
### 🛠️ Data Preparation & Processing
|
|
72
|
+
|
|
73
|
+
- Streamlined access to satellite and aerial imagery from providers like Sentinel, Landsat, NAIP, and other open datasets
|
|
74
|
+
- Tools for downloading, mosaicking, and preprocessing remote sensing data
|
|
75
|
+
- Automated generation of training datasets with image chips and corresponding labels
|
|
76
|
+
- Vector-to-raster and raster-to-vector conversion utilities optimized for AI workflows
|
|
77
|
+
- Data augmentation techniques specific to geospatial data
|
|
78
|
+
- Support for integrating Overture Maps data and other open datasets for training and validation
|
|
79
|
+
|
|
80
|
+
### 🖼️ Image Segmentation
|
|
81
|
+
|
|
82
|
+
- Integration with Meta's Segment Anything Model (SAM) for automatic feature extraction
|
|
83
|
+
- Specialized segmentation algorithms optimized for satellite and aerial imagery
|
|
84
|
+
- Streamlined workflows for segmenting buildings, roads, vegetation, and water bodies
|
|
85
|
+
- Export capabilities to standard geospatial formats (GeoJSON, Shapefile, GeoPackage)
|
|
86
|
+
|
|
87
|
+
### 🔍 Image Classification
|
|
88
|
+
|
|
89
|
+
- Pre-trained models for land cover and land use classification
|
|
90
|
+
- Transfer learning utilities for fine-tuning models with your own data
|
|
91
|
+
- Multi-temporal classification support for change detection
|
|
92
|
+
- Accuracy assessment and validation tools
|
|
93
|
+
|
|
94
|
+
### 🌍 Additional Capabilities
|
|
95
|
+
|
|
96
|
+
- Terrain analysis with AI-enhanced feature extraction
|
|
97
|
+
- Point cloud classification and segmentation
|
|
98
|
+
- Object detection in aerial and satellite imagery
|
|
99
|
+
- Georeferencing utilities for AI model outputs
|
|
100
|
+
|
|
101
|
+
## 📦 Installation
|
|
102
|
+
|
|
103
|
+
### Using pip
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
pip install geoai-py
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### Using conda
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
conda install -c conda-forge geoai
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## 📋 Documentation
|
|
116
|
+
|
|
117
|
+
Comprehensive documentation is available at [https://geoai.gishub.org](https://geoai.gishub.org), including:
|
|
118
|
+
|
|
119
|
+
- Detailed API reference
|
|
120
|
+
- Tutorials and example notebooks
|
|
121
|
+
- Explanation of algorithms and models
|
|
122
|
+
- Best practices for geospatial AI
|
|
123
|
+
|
|
124
|
+
## 🤝 Contributing
|
|
125
|
+
|
|
126
|
+
We welcome contributions of all kinds! See our [contributing guide](https://geoai.gishub.org/contributing) for ways to get started.
|
|
127
|
+
|
|
128
|
+
## 📄 License
|
|
129
|
+
|
|
130
|
+
GeoAI is free and open source software, licensed under the MIT License.
|
geoai_py-0.2.0/README.md
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# GeoAI: Artificial Intelligence for Geospatial Data
|
|
2
|
+
|
|
3
|
+
[](https://pypi.python.org/pypi/geoai-py)
|
|
4
|
+
[](https://pepy.tech/project/geoai-py)
|
|
5
|
+
[](https://anaconda.org/conda-forge/geoai)
|
|
6
|
+
[](https://anaconda.org/conda-forge/geoai)
|
|
7
|
+
[](https://github.com/conda-forge/geoai-py-feedstock)
|
|
8
|
+
[](https://opensource.org/licenses/MIT)
|
|
9
|
+
[](https://youtube.com/@giswqs)
|
|
10
|
+
|
|
11
|
+
**A powerful Python package for integrating Artificial Intelligence with geospatial data analysis and visualization**
|
|
12
|
+
|
|
13
|
+
GeoAI bridges the gap between AI and geospatial analysis, providing tools for processing, analyzing, and visualizing geospatial data using advanced machine learning techniques. Whether you're working with satellite imagery, LiDAR point clouds, or vector data, GeoAI offers intuitive interfaces to apply cutting-edge AI models.
|
|
14
|
+
|
|
15
|
+
- 📖 **Documentation:** [https://geoai.gishub.org](https://geoai.gishub.org)
|
|
16
|
+
- 💬 **Community:** [GitHub Discussions](https://github.com/opengeos/geoai/discussions)
|
|
17
|
+
- 🐛 **Issue Tracker:** [GitHub Issues](https://github.com/opengeos/geoai/issues)
|
|
18
|
+
|
|
19
|
+
## 🚀 Key Features
|
|
20
|
+
|
|
21
|
+
### 📊 Advanced Geospatial Data Visualization
|
|
22
|
+
|
|
23
|
+
- Interactive multi-layer visualization of vector, raster, and point cloud data
|
|
24
|
+
- Customizable styling and symbology
|
|
25
|
+
- Time-series data visualization capabilities
|
|
26
|
+
|
|
27
|
+
### 🛠️ Data Preparation & Processing
|
|
28
|
+
|
|
29
|
+
- Streamlined access to satellite and aerial imagery from providers like Sentinel, Landsat, NAIP, and other open datasets
|
|
30
|
+
- Tools for downloading, mosaicking, and preprocessing remote sensing data
|
|
31
|
+
- Automated generation of training datasets with image chips and corresponding labels
|
|
32
|
+
- Vector-to-raster and raster-to-vector conversion utilities optimized for AI workflows
|
|
33
|
+
- Data augmentation techniques specific to geospatial data
|
|
34
|
+
- Support for integrating Overture Maps data and other open datasets for training and validation
|
|
35
|
+
|
|
36
|
+
### 🖼️ Image Segmentation
|
|
37
|
+
|
|
38
|
+
- Integration with Meta's Segment Anything Model (SAM) for automatic feature extraction
|
|
39
|
+
- Specialized segmentation algorithms optimized for satellite and aerial imagery
|
|
40
|
+
- Streamlined workflows for segmenting buildings, roads, vegetation, and water bodies
|
|
41
|
+
- Export capabilities to standard geospatial formats (GeoJSON, Shapefile, GeoPackage)
|
|
42
|
+
|
|
43
|
+
### 🔍 Image Classification
|
|
44
|
+
|
|
45
|
+
- Pre-trained models for land cover and land use classification
|
|
46
|
+
- Transfer learning utilities for fine-tuning models with your own data
|
|
47
|
+
- Multi-temporal classification support for change detection
|
|
48
|
+
- Accuracy assessment and validation tools
|
|
49
|
+
|
|
50
|
+
### 🌍 Additional Capabilities
|
|
51
|
+
|
|
52
|
+
- Terrain analysis with AI-enhanced feature extraction
|
|
53
|
+
- Point cloud classification and segmentation
|
|
54
|
+
- Object detection in aerial and satellite imagery
|
|
55
|
+
- Georeferencing utilities for AI model outputs
|
|
56
|
+
|
|
57
|
+
## 📦 Installation
|
|
58
|
+
|
|
59
|
+
### Using pip
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
pip install geoai-py
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### Using conda
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
conda install -c conda-forge geoai
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## 📋 Documentation
|
|
72
|
+
|
|
73
|
+
Comprehensive documentation is available at [https://geoai.gishub.org](https://geoai.gishub.org), including:
|
|
74
|
+
|
|
75
|
+
- Detailed API reference
|
|
76
|
+
- Tutorials and example notebooks
|
|
77
|
+
- Explanation of algorithms and models
|
|
78
|
+
- Best practices for geospatial AI
|
|
79
|
+
|
|
80
|
+
## 🤝 Contributing
|
|
81
|
+
|
|
82
|
+
We welcome contributions of all kinds! See our [contributing guide](https://geoai.gishub.org/contributing) for ways to get started.
|
|
83
|
+
|
|
84
|
+
## 📄 License
|
|
85
|
+
|
|
86
|
+
GeoAI is free and open source software, licensed under the MIT License.
|
|
@@ -0,0 +1,385 @@
|
|
|
1
|
+
{
|
|
2
|
+
"cells": [
|
|
3
|
+
{
|
|
4
|
+
"cell_type": "markdown",
|
|
5
|
+
"metadata": {},
|
|
6
|
+
"source": [
|
|
7
|
+
"# Data visualization\n",
|
|
8
|
+
"\n",
|
|
9
|
+
"[](https://colab.research.google.com/github/opengeos/geoai/blob/main/docs/examples/data_viz.ipynb)\n",
|
|
10
|
+
"\n",
|
|
11
|
+
"This notebook demonstrates how to work with geospatial imagery data using TorchGeo and GeoAI. We'll explore how to load data, sample it using different strategies, and visualize the results.\n",
|
|
12
|
+
"\n",
|
|
13
|
+
"## Install Package\n",
|
|
14
|
+
"To use the `geoai-py` package, ensure it is installed in your environment. Uncomment the command below if needed."
|
|
15
|
+
]
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"cell_type": "code",
|
|
19
|
+
"execution_count": null,
|
|
20
|
+
"metadata": {},
|
|
21
|
+
"outputs": [],
|
|
22
|
+
"source": [
|
|
23
|
+
"# %pip install geoai-py"
|
|
24
|
+
]
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"cell_type": "markdown",
|
|
28
|
+
"metadata": {},
|
|
29
|
+
"source": [
|
|
30
|
+
"## Importing Required Libraries\n",
|
|
31
|
+
"\n",
|
|
32
|
+
"First, we import the necessary libraries for our geospatial data visualization workflow:"
|
|
33
|
+
]
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"cell_type": "code",
|
|
37
|
+
"execution_count": null,
|
|
38
|
+
"metadata": {},
|
|
39
|
+
"outputs": [],
|
|
40
|
+
"source": [
|
|
41
|
+
"from torchgeo.datasets import NAIP\n",
|
|
42
|
+
"from torchgeo.samplers import RandomGeoSampler, GridGeoSampler\n",
|
|
43
|
+
"from geoai.common import viz_image, viz_raster, dict_to_image\n",
|
|
44
|
+
"from geoai.download import download_naip"
|
|
45
|
+
]
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"cell_type": "markdown",
|
|
49
|
+
"metadata": {},
|
|
50
|
+
"source": [
|
|
51
|
+
"## Download NAIP imagery"
|
|
52
|
+
]
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
"cell_type": "code",
|
|
56
|
+
"execution_count": null,
|
|
57
|
+
"metadata": {},
|
|
58
|
+
"outputs": [],
|
|
59
|
+
"source": [
|
|
60
|
+
"root = \"naip_data\""
|
|
61
|
+
]
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
"cell_type": "code",
|
|
65
|
+
"execution_count": null,
|
|
66
|
+
"metadata": {},
|
|
67
|
+
"outputs": [],
|
|
68
|
+
"source": [
|
|
69
|
+
"bbox = (-117.6029, 47.65, -117.5936, 47.6563)\n",
|
|
70
|
+
"downloaded_files = download_naip(\n",
|
|
71
|
+
" bbox=bbox,\n",
|
|
72
|
+
" output_dir=root,\n",
|
|
73
|
+
" max_items=1,\n",
|
|
74
|
+
")"
|
|
75
|
+
]
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
"cell_type": "markdown",
|
|
79
|
+
"metadata": {},
|
|
80
|
+
"source": [
|
|
81
|
+
"- **torchgeo.datasets.NAIP**: Provides access to the National Agriculture Imagery Program (NAIP) dataset, which offers high-resolution aerial imagery across the United States.\n",
|
|
82
|
+
"- **torchgeo.samplers**: Contains sampling strategies for geospatial data:\n",
|
|
83
|
+
" - **RandomGeoSampler**: Samples random patches from the dataset\n",
|
|
84
|
+
" - **GridGeoSampler**: Samples patches in a grid pattern with specified stride\n",
|
|
85
|
+
"- **geoai.common**: Custom utility functions for visualization:\n",
|
|
86
|
+
" - **viz_image**: Visualizes tensor images\n",
|
|
87
|
+
" - **viz_raster**: Displays georeferenced data on an interactive map\n",
|
|
88
|
+
" - **dict_to_image**: Converts dictionary representation to image format\n",
|
|
89
|
+
"\n",
|
|
90
|
+
"## Setting Up the Dataset"
|
|
91
|
+
]
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
"cell_type": "markdown",
|
|
95
|
+
"metadata": {},
|
|
96
|
+
"source": [
|
|
97
|
+
"Load the NAIP dataset from the specified root directory:"
|
|
98
|
+
]
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
"cell_type": "code",
|
|
102
|
+
"execution_count": null,
|
|
103
|
+
"metadata": {},
|
|
104
|
+
"outputs": [],
|
|
105
|
+
"source": [
|
|
106
|
+
"dataset = NAIP(root)"
|
|
107
|
+
]
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
"cell_type": "markdown",
|
|
111
|
+
"metadata": {},
|
|
112
|
+
"source": [
|
|
113
|
+
"Examine the dataset object to understand its properties:"
|
|
114
|
+
]
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
"cell_type": "code",
|
|
118
|
+
"execution_count": null,
|
|
119
|
+
"metadata": {},
|
|
120
|
+
"outputs": [],
|
|
121
|
+
"source": [
|
|
122
|
+
"dataset"
|
|
123
|
+
]
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
"cell_type": "markdown",
|
|
127
|
+
"metadata": {},
|
|
128
|
+
"source": [
|
|
129
|
+
"This will display information about the NAIP dataset including available imagery dates, coverage area, and other metadata.\n",
|
|
130
|
+
"\n",
|
|
131
|
+
"Check the Coordinate Reference System (CRS) used by the dataset:"
|
|
132
|
+
]
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
"cell_type": "code",
|
|
136
|
+
"execution_count": null,
|
|
137
|
+
"metadata": {},
|
|
138
|
+
"outputs": [],
|
|
139
|
+
"source": [
|
|
140
|
+
"dataset.crs"
|
|
141
|
+
]
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
"cell_type": "markdown",
|
|
145
|
+
"metadata": {},
|
|
146
|
+
"source": [
|
|
147
|
+
"The CRS defines how the geospatial data is projected onto a coordinate system, which is essential for accurate visualization and analysis.\n",
|
|
148
|
+
"\n",
|
|
149
|
+
"## Random Sampling of Geospatial Data\n",
|
|
150
|
+
"\n",
|
|
151
|
+
"Create a random sampler to extract patches from the dataset:"
|
|
152
|
+
]
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
"cell_type": "code",
|
|
156
|
+
"execution_count": null,
|
|
157
|
+
"metadata": {},
|
|
158
|
+
"outputs": [],
|
|
159
|
+
"source": [
|
|
160
|
+
"train_sampler = RandomGeoSampler(dataset, size=256, length=1000)"
|
|
161
|
+
]
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
"cell_type": "markdown",
|
|
165
|
+
"metadata": {},
|
|
166
|
+
"source": [
|
|
167
|
+
"This creates a sampler that will randomly select 1000 patches, each 256x256 pixels in size. This sampling strategy is commonly used for training machine learning models where you need a diverse set of examples.\n",
|
|
168
|
+
"\n",
|
|
169
|
+
"Extract a bounding box from the random sampler:"
|
|
170
|
+
]
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
"cell_type": "code",
|
|
174
|
+
"execution_count": null,
|
|
175
|
+
"metadata": {},
|
|
176
|
+
"outputs": [],
|
|
177
|
+
"source": [
|
|
178
|
+
"train_bbox = next(iter(train_sampler))\n",
|
|
179
|
+
"train_bbox"
|
|
180
|
+
]
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
"cell_type": "markdown",
|
|
184
|
+
"metadata": {},
|
|
185
|
+
"source": [
|
|
186
|
+
"The bounding box contains the coordinates defining the spatial extent of our randomly sampled patch.\n",
|
|
187
|
+
"\n",
|
|
188
|
+
"Load the actual image data corresponding to the randomly selected bounding box:"
|
|
189
|
+
]
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
"cell_type": "code",
|
|
193
|
+
"execution_count": null,
|
|
194
|
+
"metadata": {},
|
|
195
|
+
"outputs": [],
|
|
196
|
+
"source": [
|
|
197
|
+
"train_image = dataset[next(iter(train_sampler))][\"image\"]"
|
|
198
|
+
]
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
"cell_type": "markdown",
|
|
202
|
+
"metadata": {},
|
|
203
|
+
"source": [
|
|
204
|
+
"Examine the complete data dictionary returned for a sample, which includes both the image and metadata:"
|
|
205
|
+
]
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
"cell_type": "code",
|
|
209
|
+
"execution_count": null,
|
|
210
|
+
"metadata": {},
|
|
211
|
+
"outputs": [],
|
|
212
|
+
"source": [
|
|
213
|
+
"dataset[next(iter(train_sampler))]"
|
|
214
|
+
]
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
"cell_type": "markdown",
|
|
218
|
+
"metadata": {},
|
|
219
|
+
"source": [
|
|
220
|
+
"This returns a dictionary containing the image tensor and associated metadata such as the bounding box, CRS, and other properties.\n",
|
|
221
|
+
"\n",
|
|
222
|
+
"## Visualizing Randomly Sampled Data\n",
|
|
223
|
+
"\n",
|
|
224
|
+
"Display the randomly sampled image:"
|
|
225
|
+
]
|
|
226
|
+
},
|
|
227
|
+
{
|
|
228
|
+
"cell_type": "code",
|
|
229
|
+
"execution_count": null,
|
|
230
|
+
"metadata": {},
|
|
231
|
+
"outputs": [],
|
|
232
|
+
"source": [
|
|
233
|
+
"viz_image(\n",
|
|
234
|
+
" train_image, transpose=True, scale_factor=(1 / 250), title=\"Random GeoSampler\"\n",
|
|
235
|
+
")"
|
|
236
|
+
]
|
|
237
|
+
},
|
|
238
|
+
{
|
|
239
|
+
"cell_type": "markdown",
|
|
240
|
+
"metadata": {},
|
|
241
|
+
"source": [
|
|
242
|
+
"- **transpose=True**: Rearranges the dimensions for proper display (from [C,H,W] to [H,W,C])\n",
|
|
243
|
+
"- **scale_factor=(1/250)**: Scales the pixel values for better visualization\n",
|
|
244
|
+
"- **title=\"Random GeoSampler\"**: Adds a descriptive title to the plot\n",
|
|
245
|
+
"\n",
|
|
246
|
+
"## Grid Sampling of Geospatial Data\n",
|
|
247
|
+
"\n",
|
|
248
|
+
"Create a grid sampler to extract patches in a systematic pattern:"
|
|
249
|
+
]
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
"cell_type": "code",
|
|
253
|
+
"execution_count": null,
|
|
254
|
+
"metadata": {},
|
|
255
|
+
"outputs": [],
|
|
256
|
+
"source": [
|
|
257
|
+
"test_sampler = GridGeoSampler(dataset, size=256, stride=128)"
|
|
258
|
+
]
|
|
259
|
+
},
|
|
260
|
+
{
|
|
261
|
+
"cell_type": "markdown",
|
|
262
|
+
"metadata": {},
|
|
263
|
+
"source": [
|
|
264
|
+
"This sampler extracts 256x256 pixel patches in a grid pattern with a stride of 128 pixels, meaning patches will overlap by 128 pixels. Grid sampling is typically used for inference or testing, where systematic coverage of the area is important.\n",
|
|
265
|
+
"\n",
|
|
266
|
+
"Extract a bounding box from the grid sampler:"
|
|
267
|
+
]
|
|
268
|
+
},
|
|
269
|
+
{
|
|
270
|
+
"cell_type": "code",
|
|
271
|
+
"execution_count": null,
|
|
272
|
+
"metadata": {},
|
|
273
|
+
"outputs": [],
|
|
274
|
+
"source": [
|
|
275
|
+
"test_bbox = next(iter(test_sampler))\n",
|
|
276
|
+
"test_bbox"
|
|
277
|
+
]
|
|
278
|
+
},
|
|
279
|
+
{
|
|
280
|
+
"cell_type": "markdown",
|
|
281
|
+
"metadata": {},
|
|
282
|
+
"source": [
|
|
283
|
+
"Load the image data for a patch selected by the grid sampler:"
|
|
284
|
+
]
|
|
285
|
+
},
|
|
286
|
+
{
|
|
287
|
+
"cell_type": "code",
|
|
288
|
+
"execution_count": null,
|
|
289
|
+
"metadata": {},
|
|
290
|
+
"outputs": [],
|
|
291
|
+
"source": [
|
|
292
|
+
"test_image = dataset[next(iter(test_sampler))][\"image\"]"
|
|
293
|
+
]
|
|
294
|
+
},
|
|
295
|
+
{
|
|
296
|
+
"cell_type": "markdown",
|
|
297
|
+
"metadata": {},
|
|
298
|
+
"source": [
|
|
299
|
+
"## Visualizing Grid Sampled Data\n",
|
|
300
|
+
"\n",
|
|
301
|
+
"Display the image from the grid sampler:"
|
|
302
|
+
]
|
|
303
|
+
},
|
|
304
|
+
{
|
|
305
|
+
"cell_type": "code",
|
|
306
|
+
"execution_count": null,
|
|
307
|
+
"metadata": {},
|
|
308
|
+
"outputs": [],
|
|
309
|
+
"source": [
|
|
310
|
+
"viz_image(test_image, transpose=True, scale_factor=(1 / 250), title=\"Grid GeoSampler\")"
|
|
311
|
+
]
|
|
312
|
+
},
|
|
313
|
+
{
|
|
314
|
+
"cell_type": "markdown",
|
|
315
|
+
"metadata": {},
|
|
316
|
+
"source": [
|
|
317
|
+
"The visualization shows a systematically sampled patch from the dataset.\n",
|
|
318
|
+
"\n",
|
|
319
|
+
"## Advanced Visualization with Geospatial Context\n",
|
|
320
|
+
"\n",
|
|
321
|
+
"Load a complete data sample including all metadata:"
|
|
322
|
+
]
|
|
323
|
+
},
|
|
324
|
+
{
|
|
325
|
+
"cell_type": "code",
|
|
326
|
+
"execution_count": null,
|
|
327
|
+
"metadata": {},
|
|
328
|
+
"outputs": [],
|
|
329
|
+
"source": [
|
|
330
|
+
"data = dataset[next(iter(test_sampler))]"
|
|
331
|
+
]
|
|
332
|
+
},
|
|
333
|
+
{
|
|
334
|
+
"cell_type": "markdown",
|
|
335
|
+
"metadata": {},
|
|
336
|
+
"source": [
|
|
337
|
+
"Visualize the raster data on an interactive map with Google Satellite imagery as the background:"
|
|
338
|
+
]
|
|
339
|
+
},
|
|
340
|
+
{
|
|
341
|
+
"cell_type": "code",
|
|
342
|
+
"execution_count": null,
|
|
343
|
+
"metadata": {},
|
|
344
|
+
"outputs": [],
|
|
345
|
+
"source": [
|
|
346
|
+
"viz_raster(data, basemap=\"Google Satellite\")"
|
|
347
|
+
]
|
|
348
|
+
},
|
|
349
|
+
{
|
|
350
|
+
"cell_type": "markdown",
|
|
351
|
+
"metadata": {},
|
|
352
|
+
"source": [
|
|
353
|
+
"This interactive visualization places the sampled data in its real-world geographic context, allowing you to see how it aligns with the Google Satellite imagery.\n",
|
|
354
|
+
"\n",
|
|
355
|
+
"## Key Takeaways\n",
|
|
356
|
+
"\n",
|
|
357
|
+
"1. **TorchGeo** provides a flexible framework for working with geospatial datasets like NAIP.\n",
|
|
358
|
+
"2. Different sampling strategies (random vs. grid) serve different purposes in geospatial machine learning workflows.\n",
|
|
359
|
+
"3. Visualization tools help understand the data in both pixel space (viz_image) and geographic space (viz_raster).\n",
|
|
360
|
+
"4. Working with geospatial data requires attention to coordinate reference systems (CRS) and proper handling of georeferenced data."
|
|
361
|
+
]
|
|
362
|
+
}
|
|
363
|
+
],
|
|
364
|
+
"metadata": {
|
|
365
|
+
"kernelspec": {
|
|
366
|
+
"display_name": "Python 3 (ipykernel)",
|
|
367
|
+
"language": "python",
|
|
368
|
+
"name": "python3"
|
|
369
|
+
},
|
|
370
|
+
"language_info": {
|
|
371
|
+
"codemirror_mode": {
|
|
372
|
+
"name": "ipython",
|
|
373
|
+
"version": 3
|
|
374
|
+
},
|
|
375
|
+
"file_extension": ".py",
|
|
376
|
+
"mimetype": "text/x-python",
|
|
377
|
+
"name": "python",
|
|
378
|
+
"nbconvert_exporter": "python",
|
|
379
|
+
"pygments_lexer": "ipython3",
|
|
380
|
+
"version": "3.11.8"
|
|
381
|
+
}
|
|
382
|
+
},
|
|
383
|
+
"nbformat": 4,
|
|
384
|
+
"nbformat_minor": 4
|
|
385
|
+
}
|