Skip to content
Skills Library
Data & analytics · Analysis

geospatial-distance-analysis

/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.

Licence
MIT
Last repository change
02.10.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
1
Scripts
0
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 02.10.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What it does and when to use it

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.

Original author 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.

How it works

  1. 1. Projecting for Distance Calculations
  2. 2. Calculating Point-to-Geometry Distances
  3. 3. Handling Antimeridian Issues
  4. 4. Performance Tips
Original SKILL.md headings · 52 lines, 294 words
SKILL.md preview
---
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.
---

# 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
```python
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):

```python
# 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_longitude` or 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_union` in 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`).

Versions

The database has no other skills named geospatial-distance-analysis.

Database snapshot: 13.11.2026 · package version 44cc83c02143 (SHA-256 digest of the entire package)

Downloads in the last 30 days: 1 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 95geospatial-analysis
    How to perform geospatial analysis using GeoPandas. Use this skill whenever the user mentions maps, coordinates, geospatial distance, plate boundaries, earthquakes, or spatial data, even if they don't explicitly ask for it.
  • 100geospatial-analysis
    Analyze geospatial data using geopandas with proper coordinate projections. Use when calculating distances between geographic features, performing spatial filtering, or working with plate boundaries and earthquake data.
  • 100earthquake-distance-calc
    Calculate geodesic distances between earthquake points and plate boundaries using GeoPandas projections. Use this skill when computing distances in kilometers between geographic points and linestring/polygon boundaries, especially for finding the earthquake furthest from a plate…
  • 100geopandas-geospatial
    Geospatial vector analysis extending pandas. Read/write spatial formats (Shapefile, GeoJSON, GeoPackage, Parquet, PostGIS), CRS handling, geometric ops (buffer, simplify, centroid, affine), spatial analysis (joins, overlays, dissolve, clipping, distance), visualization…
  • 100alterlab-geopandas
    Reads, writes, and analyzes geospatial vector data with the GeoPandas Python library (shapefiles, GeoJSON, GeoPackage), with PostGIS support and integration with matplotlib, folium, and cartopy. Use for spatial analysis and geometric operations — buffer analysis, spatial joins…
  • 100geopandas
    Python library for working with geospatial vector data including shapefiles, GeoJSON, and GeoPackage files. Use when working with geographic data for spatial analysis, geometric operations, coordinate transformations, spatial joins, overlay operations, choropleth mapping, or any…

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.