geospatial-distance-analysis
Procedures for performing precise distance calculations between points and geometries using GeoPandas. Use this skill when calculating distances in kilometers, reprojecting GeoDataFrames, or finding the nearest features in a geospatial dataset.
- License 许可
- MIT
- 最近更新
- 2026-10-02
- Stars
- ★ 93
- Forks
- 8
01 前言 Front Matter
- name
- geospatial-distance-analysis
- description
- Procedures for performing precise distance calculations between points and geometries using GeoPandas. Use this skill when calculating distances in kilometers, reprojecting GeoDataFrames, or finding the nearest features in a geospatial dataset.
03 SKILL.md 正文
Geospatial Distance Analysis
This skill provides instructions for calculating distances between geospatial features accurately using GeoPandas and appropriate coordinate reference systems (CRS).
1. Projecting for Distance Calculations
Standard WGS84 (EPSG:4326) coordinates (latitude/longitude) are not suitable for direct distance calculations in meters or kilometers because degrees of longitude vary in length.
Choosing a Projection
- Equidistant Projections: Use for accurate distance measurements.
- World Equidistant Cylindrical (EPSG:4087): Good for global datasets.
- Local UTM Zones: Best for high precision in specific local areas.
- Custom Azimuthal Equidistant: Best for distances from a single point of interest.
Implementation in GeoPandas
import geopandas as gpd
# Load data in WGS84
gdf = gpd.read_file("data.json")
gdf.crs = "EPSG:4326"
# Reproject to a metric CRS (e.g., World Equidistant Cylindrical)
gdf_metric = gdf.to_crs("EPSG:4087")
2. Calculating Point-to-Geometry Distances
To find the distance from a point to the nearest part of a boundary (line or polygon):
# Assuming 'points_gdf' and 'boundary_gdf' are in the same metric CRS
# 'boundary' should be a single geometry (e.g., the union of all boundary segments)
boundary_geom = boundary_gdf.union_all()
# Calculate distance for each point
points_gdf['distance_meters'] = points_gdf.geometry.distance(boundary_geom)
points_gdf['distance_km'] = points_gdf['distance_meters'] / 1000.0
3. Handling Antimeridian Issues
When working with global data (like the Pacific Plate), geometries may cross the Antimeridian (180° longitude).
- Use
geopandas.tools.wrap_longitudeor ensure your CRS handles the wrap-around correctly. - For calculations across the Pacific, consider a CRS centered on 180° longitude if necessary, though EPSG:4087 usually handles the coordinate range -180 to 180.
4. Performance Tips
- Use
.union_all()(or.unary_unionin older versions) to combine many boundary segments into a single geometry before calculating distances. This is much faster than iterating. - For very large datasets, use spatial indexes (
gdf.sindex).
04 同仓库更多 Skills
object_counter
Count occurrences of an object in the image using computer vision algorithm.
travel-planning-workflow
Invoke this skill when performing travel planning. It defines a structured workflow for generating itineraries. Following this workflow is essential to ensure the final plan satisfies user requirements.
bundled-dataset-search-tool
invoke this skill when you need to perform database search for travel planning. This skill provides some useful pre-packaged tools to look up accommodations, attractions, cities, driving distance, flights, and restaurants from the bundled dataset.
glm-output
Output-processing guidance for GLM tasks. Especially useful after glm-basics and glm-calibration when you need verifier-matching metrics from output.nc and a final /root/metrics.json.
glm-calibration
Calibration guidance for GLM tasks. Often most effective after glm-basics has clarified the setup; glm-output is the companion skill for exact final metric computation.
glm-basics
A good starting point for GLM calibration tasks. Use to inspect glm3.nml, confirm how GLM runs, and identify the relevant files before moving on to calibration and output evaluation.