|----------|-----------|
| Vector | Shapefile, GeoJSON, GeoPackage | GeoPandas, Fiona, GDAL |
| Raster | GeoTIFF, NetCDF, COG | Rasterio, Xarray, GDAL |
| Point Cloud | LAS, LAZ | Laspy, PDAL, Open3D |
Coordinate Systems
- EPSG:4326 (WGS 84) - Geographic, lat/lon, use for storage
- EPSG:3857 (Web Mercator) - Web maps only (don't use for area/distance!)
- EPSG:326xx/327xx (UTM) - Metric calculations, <1% distortion per zone
- Use
gdf.estimate_utm_crs() for automatic UTM detection
# Always check CRS before operations
assert gdf1.crs == gdf2.crs, "CRS mismatch!"
# For area/distance calculations, use projected CRS
gdf_metric = gdf.to_crs(gdf.estimate_utm_crs())
area_sqm = gdf_metric.geometry.area
OGC Standards
- WMS: Web Map Service - raster maps
- WFS: Web Feature Service - vector data
- WCS: Web Coverage Service - raster coverage
- STAC: Spatiotemporal Asset Catalog - modern metadata
Common Operations
Spectral Indices
def calculate_indices(image_path):
"""NDVI, EVI, SAVI, NDWI from Sentinel-2."""
with rasterio.open(image_path) as src:
B02, B03, B04, B08, B11 = [src.read(i).astype(float) for i in [1,2,3,4,5]]
ndvi = (B08 - B04) / (B08 + B04 + 1e-8)
evi = 2.5 * (B08 - B04) / (B08 + 6*B04 - 7.5*B02 + 1)
savi = ((B08 - B04) / (B08 + B04 + 0.5)) * 1.5
ndwi = (B03 - B08) / (B03 + B08 + 1e-8)
return {'NDVI': ndvi, 'EVI': evi, 'SAVI': savi, 'NDWI': ndwi}
Vector Operations
# Buffer (use projected CRS!)
gdf_proj = gdf.to_crs(gdf.estimate_utm_crs())
gdf['buffer_1km'] = gdf_proj.geometry.buffer(1000)
# Spatial relationships
intersects = gdf[gdf.geometry.intersects(other_geometry)]
contains = gdf[gdf.geometry.contains(point_geometry)]
# Geometric operations
gdf['centroid'] = gdf.geometry.centroid
gdf['simplified'] = gdf.geometry.simplify(tolerance=0.001)
# Overlay operations
intersection = gpd.overlay(gdf1, gdf2, how='intersection')
union = gpd.overlay(gdf1, gdf2, how='union')
Terrain Analysis
def terrain_metrics(dem_path):
"""Calculate slope, aspect, hillshade from DEM."""
with rasterio.open(dem_path) as src:
dem = src.read(1)
dy, dx = np.gradient(dem)
slope = np.arctan(np.sqrt(dx**2 + dy**2)) * 180 / np.pi
aspect = (90 - np.arctan2(-dy, dx) * 180 / np.pi) % 360
# Hillshade
az_rad, alt_rad = np.radians(315), np.radians(45)
hillshade = (np.sin(alt_rad) * np.sin(np.radians(slope)) +
np.cos(alt_rad) * np.cos(np.radians(slope)) *
np.cos(np.radians(aspect) - az_rad))
return slope, aspect, hillshade
Network Analysis
import osmnx as ox
import networkx as nx
# Download and analyze street network
G = ox.graph_from_place('San Francisco, CA', network_type='drive')
G = ox.add_edge_speeds(G).add_edge_travel_times(G)
# Shortest path
orig = ox.distance.nearest_nodes(G, -122.4, 37.7)
dest = ox.distance.nearest_nodes(G, -122.3, 37.8)
route = nx.shortest_path(G, orig, dest, weight='travel_time')
Image Classification
from sklearn.ensemble import RandomForestClassifier
import rasterio
from rasterio.features import rasterize
def classify_imagery(raster_path, training_gdf, output_path):
"""Train RF and classify imagery."""
with rasterio.open(raster_path) as src:
image = src.read()
profile = src.profile
transform = src.transform
# Extract training data
X_train, y_train = [], []
for _, row in training_gdf.iterrows():
mask = rasterize([(row.geometry, 1)],
out_shape=(profile['height'], profile['width']),
transform=transform, fill=0, dtype=np.uint8)
pixels = image[:, mask > 0].T
X_train.extend(pixels)
y_train.extend([row['class_id']] * len(pixels))
# Train and predict
rf = RandomForestClassifier(n_estimators=100, max_depth=20, n_jobs=-1)
rf.fit(X_train, y_train)
prediction = rf.predict(image.reshape(image.shape[0], -1).T)
prediction = prediction.reshape(profile['height'], profile['width'])
profile.update(dtype=rasterio.uint8, count=1)
with rasterio.open(output_path, 'w', **profile) as dst:
dst.write(prediction.astype(rasterio.uint8), 1)
return rf
Modern Cloud-Native Workflows
STAC + Planetary Computer
import pystac_client
import planetary_computer
import odc.stac
# Search Sentinel-2 via STAC
catalog = pystac_client.Client.open(
"https://planetarycomputer.microsoft.com/api/stac/v1",
modifier=planetary_computer.sign_inplace,
)
search = catalog.search(
collections=["sentinel-2-l2a"],
bbox=[-122.5, 37.7, -122.3, 37.9],
datetime="2023-01-01/2023-12-31",
query={"eo:cloud_cover": {"lt": 20}},
)
# Load as xarray (cloud-native!)
data = odc.stac.load(
list(search.get_items())[:5],
bands=["B02", "B03", "B04", "B08"],
crs="EPSG:32610",
resolution=10,
)
# Calculate NDVI on xarray
ndvi = (data.B08 - data.B04) / (data.B08 + data.B04)
Cloud-Optimized GeoTIFF (COG)
import rasterio
from rasterio.session import AWSSession
# Read COG directly from cloud (partial reads)
session = AWSSession(aws_access_key_id=..., aws_secret_access_key=...)
with rasterio.open('s3://bucket/path.tif', session=session) as src:
# Read only window of interest
window = ((1000, 2000), (1000, 2000))
subset = src.read(1, window=window)
# Write COG
with rasterio.open('output.tif', 'w', **profile,
tiled=True, blockxsize=256, blockysize=256,
compress='DEFLATE', predictor=2) as dst:
dst.write(data)
# Validate COG
from rio_cogeo.cogeo import cog_validate
cog_validate('output.tif')
Performance Tips
# 1. Spatial indexing (10-100x faster queries)
gdf.sindex # Auto-created by GeoPandas
# 2. Chunk large rasters
with rasterio.open('large.tif') as src:
for i, window in src.block_windows(1):
block = src.read(1, window=window)
# 3. Dask for big data
import dask.array as da
dask_array = da.from_rasterio('large.tif', chunks=(1, 1024, 1024))
# 4. Use Arrow for I/O
gdf.to_file('output.gpkg', use_arrow=True)
# 5. GDAL caching
from osgeo import gdal
gdal.SetCacheMax(2**30) # 1GB cache
# 6. Parallel processing
rf = RandomForestClassifier(n_jobs=-1) # All cores
Best Practices
- Always check CRS before spatial operations
- Use projected CRS for area/distance calculations
- Validate geometries:
gdf = gdf[gdf.is_valid]
- Handle missing data:
gdf['geometry'] = gdf['geometry'].fillna(None)
- Use efficient formats: GeoPackage > Shapefile, Parquet for large data
- Apply cloud masking to optical imagery
- Preserve lineage for reproducible research
- Use appropriate resolution for your analysis scale
Detailed Documentation
- Coordinate Systems - CRS fundamentals, UTM, transformations
- Core Libraries - GDAL, Rasterio, GeoPandas, Shapely
- Remote Sensing - Satellite missions, spectral indices, SAR
- Machine Learning - Deep learning, CNNs, GNNs for RS
- GIS Software - QGIS, ArcGIS, GRASS integration
- Scientific Domains - Marine, hydrology, agriculture, forestry
- Advanced GIS - 3D GIS, spatiotemporal, topology
- Big Data - Distributed processing, GPU acceleration
- Industry Applications - Urban planning, disaster management
- Programming Languages - Python, R, Julia, JS, C++, Java, Go, Rust
- Data Sources - Satellite catalogs, APIs
- Troubleshooting - Common issues, debugging, error reference
- Code Examples - 500+ examples
GeoMaster covers everything from basic GIS operations to advanced remote sensing and machine learning.
1---2name: geomaster3description: Comprehensive geospatial science skill covering remote sensing, GIS, spatial analysis, machine learning for earth observation, and 30+ scientific domains. Supports satellite imagery processing (Sentinel, Landsat, MODIS, SAR, hyperspectral), vector and raster data operations, spatial statistics, point cloud processing, network analysis, cloud-native workflows (STAC, COG, Planetary Computer), and 8 programming languages (Python, R, Julia, JavaScript, C++, Java, Go, Rust) with 500+ code examples. Use for remote sensing workflows, GIS analysis, spatial ML, Earth observation data processing, terrain analysis, hydrological modeling, marine spatial analysis, atmospheric science, and any geospatial computation task.4license: MIT License5---6|----------|-----------|7| Vector | Shapefile, GeoJSON, GeoPackage | GeoPandas, Fiona, GDAL |8| Raster | GeoTIFF, NetCDF, COG | Rasterio, Xarray, GDAL |9| Point Cloud | LAS, LAZ | Laspy, PDAL, Open3D |1011### Coordinate Systems1213- **EPSG:4326** (WGS 84) - Geographic, lat/lon, use for storage14- **EPSG:3857** (Web Mercator) - Web maps only (don't use for area/distance!)15- **EPSG:326xx/327xx** (UTM) - Metric calculations, <1% distortion per zone16- Use `gdf.estimate_utm_crs()` for automatic UTM detection1718```python19# Always check CRS before operations20assert gdf1.crs == gdf2.crs, "CRS mismatch!"2122# For area/distance calculations, use projected CRS23gdf_metric = gdf.to_crs(gdf.estimate_utm_crs())24area_sqm = gdf_metric.geometry.area25```2627### OGC Standards2829- **WMS**: Web Map Service - raster maps30- **WFS**: Web Feature Service - vector data31- **WCS**: Web Coverage Service - raster coverage32- **STAC**: Spatiotemporal Asset Catalog - modern metadata3334## Common Operations3536### Spectral Indices3738```python39def calculate_indices(image_path):40 """NDVI, EVI, SAVI, NDWI from Sentinel-2."""41 with rasterio.open(image_path) as src:42 B02, B03, B04, B08, B11 = [src.read(i).astype(float) for i in [1,2,3,4,5]]4344 ndvi = (B08 - B04) / (B08 + B04 + 1e-8)45 evi = 2.5 * (B08 - B04) / (B08 + 6*B04 - 7.5*B02 + 1)46 savi = ((B08 - B04) / (B08 + B04 + 0.5)) * 1.547 ndwi = (B03 - B08) / (B03 + B08 + 1e-8)4849 return {'NDVI': ndvi, 'EVI': evi, 'SAVI': savi, 'NDWI': ndwi}50```5152### Vector Operations5354```python55# Buffer (use projected CRS!)56gdf_proj = gdf.to_crs(gdf.estimate_utm_crs())57gdf['buffer_1km'] = gdf_proj.geometry.buffer(1000)5859# Spatial relationships60intersects = gdf[gdf.geometry.intersects(other_geometry)]61contains = gdf[gdf.geometry.contains(point_geometry)]6263# Geometric operations64gdf['centroid'] = gdf.geometry.centroid65gdf['simplified'] = gdf.geometry.simplify(tolerance=0.001)6667# Overlay operations68intersection = gpd.overlay(gdf1, gdf2, how='intersection')69union = gpd.overlay(gdf1, gdf2, how='union')70```7172### Terrain Analysis7374```python75def terrain_metrics(dem_path):76 """Calculate slope, aspect, hillshade from DEM."""77 with rasterio.open(dem_path) as src:78 dem = src.read(1)7980 dy, dx = np.gradient(dem)81 slope = np.arctan(np.sqrt(dx**2 + dy**2)) * 180 / np.pi82 aspect = (90 - np.arctan2(-dy, dx) * 180 / np.pi) % 3608384 # Hillshade85 az_rad, alt_rad = np.radians(315), np.radians(45)86 hillshade = (np.sin(alt_rad) * np.sin(np.radians(slope)) +87 np.cos(alt_rad) * np.cos(np.radians(slope)) *88 np.cos(np.radians(aspect) - az_rad))8990 return slope, aspect, hillshade91```9293### Network Analysis9495```python96import osmnx as ox97import networkx as nx9899# Download and analyze street network100G = ox.graph_from_place('San Francisco, CA', network_type='drive')101G = ox.add_edge_speeds(G).add_edge_travel_times(G)102103# Shortest path104orig = ox.distance.nearest_nodes(G, -122.4, 37.7)105dest = ox.distance.nearest_nodes(G, -122.3, 37.8)106route = nx.shortest_path(G, orig, dest, weight='travel_time')107```108109## Image Classification110111```python112from sklearn.ensemble import RandomForestClassifier113import rasterio114from rasterio.features import rasterize115116def classify_imagery(raster_path, training_gdf, output_path):117 """Train RF and classify imagery."""118 with rasterio.open(raster_path) as src:119 image = src.read()120 profile = src.profile121 transform = src.transform122123 # Extract training data124 X_train, y_train = [], []125 for _, row in training_gdf.iterrows():126 mask = rasterize([(row.geometry, 1)],127 out_shape=(profile['height'], profile['width']),128 transform=transform, fill=0, dtype=np.uint8)129 pixels = image[:, mask > 0].T130 X_train.extend(pixels)131 y_train.extend([row['class_id']] * len(pixels))132133 # Train and predict134 rf = RandomForestClassifier(n_estimators=100, max_depth=20, n_jobs=-1)135 rf.fit(X_train, y_train)136137 prediction = rf.predict(image.reshape(image.shape[0], -1).T)138 prediction = prediction.reshape(profile['height'], profile['width'])139140 profile.update(dtype=rasterio.uint8, count=1)141 with rasterio.open(output_path, 'w', **profile) as dst:142 dst.write(prediction.astype(rasterio.uint8), 1)143144 return rf145```146147## Modern Cloud-Native Workflows148149### STAC + Planetary Computer150151```python152import pystac_client153import planetary_computer154import odc.stac155156# Search Sentinel-2 via STAC157catalog = pystac_client.Client.open(158 "https://planetarycomputer.microsoft.com/api/stac/v1",159 modifier=planetary_computer.sign_inplace,160)161162search = catalog.search(163 collections=["sentinel-2-l2a"],164 bbox=[-122.5, 37.7, -122.3, 37.9],165 datetime="2023-01-01/2023-12-31",166 query={"eo:cloud_cover": {"lt": 20}},167)168169# Load as xarray (cloud-native!)170data = odc.stac.load(171 list(search.get_items())[:5],172 bands=["B02", "B03", "B04", "B08"],173 crs="EPSG:32610",174 resolution=10,175)176177# Calculate NDVI on xarray178ndvi = (data.B08 - data.B04) / (data.B08 + data.B04)179```180181### Cloud-Optimized GeoTIFF (COG)182183```python184import rasterio185from rasterio.session import AWSSession186187# Read COG directly from cloud (partial reads)188session = AWSSession(aws_access_key_id=..., aws_secret_access_key=...)189with rasterio.open('s3://bucket/path.tif', session=session) as src:190 # Read only window of interest191 window = ((1000, 2000), (1000, 2000))192 subset = src.read(1, window=window)193194# Write COG195with rasterio.open('output.tif', 'w', **profile,196 tiled=True, blockxsize=256, blockysize=256,197 compress='DEFLATE', predictor=2) as dst:198 dst.write(data)199200# Validate COG201from rio_cogeo.cogeo import cog_validate202cog_validate('output.tif')203```204205## Performance Tips206207```python208# 1. Spatial indexing (10-100x faster queries)209gdf.sindex # Auto-created by GeoPandas210211# 2. Chunk large rasters212with rasterio.open('large.tif') as src:213 for i, window in src.block_windows(1):214 block = src.read(1, window=window)215216# 3. Dask for big data217import dask.array as da218dask_array = da.from_rasterio('large.tif', chunks=(1, 1024, 1024))219220# 4. Use Arrow for I/O221gdf.to_file('output.gpkg', use_arrow=True)222223# 5. GDAL caching224from osgeo import gdal225gdal.SetCacheMax(2**30) # 1GB cache226227# 6. Parallel processing228rf = RandomForestClassifier(n_jobs=-1) # All cores229```230231## Best Practices2322331. **Always check CRS** before spatial operations2342. **Use projected CRS** for area/distance calculations2353. **Validate geometries**: `gdf = gdf[gdf.is_valid]`2364. **Handle missing data**: `gdf['geometry'] = gdf['geometry'].fillna(None)`2375. **Use efficient formats**: GeoPackage > Shapefile, Parquet for large data2386. **Apply cloud masking** to optical imagery2397. **Preserve lineage** for reproducible research2408. **Use appropriate resolution** for your analysis scale241242## Detailed Documentation243244- **[Coordinate Systems](references/coordinate-systems.md)** - CRS fundamentals, UTM, transformations245- **[Core Libraries](references/core-libraries.md)** - GDAL, Rasterio, GeoPandas, Shapely246- **[Remote Sensing](references/remote-sensing.md)** - Satellite missions, spectral indices, SAR247- **[Machine Learning](references/machine-learning.md)** - Deep learning, CNNs, GNNs for RS248- **[GIS Software](references/gis-software.md)** - QGIS, ArcGIS, GRASS integration249- **[Scientific Domains](references/scientific-domains.md)** - Marine, hydrology, agriculture, forestry250- **[Advanced GIS](references/advanced-gis.md)** - 3D GIS, spatiotemporal, topology251- **[Big Data](references/big-data.md)** - Distributed processing, GPU acceleration252- **[Industry Applications](references/industry-applications.md)** - Urban planning, disaster management253- **[Programming Languages](references/programming-languages.md)** - Python, R, Julia, JS, C++, Java, Go, Rust254- **[Data Sources](references/data-sources.md)** - Satellite catalogs, APIs255- **[Troubleshooting](references/troubleshooting.md)** - Common issues, debugging, error reference256- **[Code Examples](references/code-examples.md)** - 500+ examples257258---259260**GeoMaster covers everything from basic GIS operations to advanced remote sensing and machine learning.**