Token导航 LogoToken导航TokenDH.com
研究检索需要联网github未标认证来源可访问许可证需确认审计通过

pyprojpyproj 搜索

Agent Skill

pyproj 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

424

周安装

17

GitHub Stars

9

下载量

137
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:pyproj(pyproj 搜索)
来源仓库:https://github.com/tondevrel/scientific-agent-skills
仓库路径:skills/pyproj
安装命令:
npx skills add https://github.com/tondevrel/scientific-agent-skills --skill pyproj
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/tondevrel/scientific-agent-skills --skill pyproj

简介

用于查找、检索和筛选相关信息。pyproj 属于研究检索类 Skill,可作为该场景下的辅助能力补充。

  • 适合根据关键词或任务场景快速定位候选结果。
  • 通过 GitHub 安装,需结合原始 README 核验具体用法。
  • 安装前建议确认权限范围和维护状态。适用宿主包括 Codex、Claude、Cursor、Gemini CLI,接入前应确认版本、权限和运行环境要求。
  • 注意是否会触发联网、命令执行或文件读写操作。

SKILL.md

PyProj - Coordinate Projections and Geodetic Math

PyProj is essential for any spatial analysis that requires high precision. It allows you to transform coordinates between thousands of different reference systems and compute distances on the Earth's ellipsoidal surface using the most accurate formulas (Vincenty, Karney).

When to Use

  • Converting GPS coordinates (WGS84) to local projected systems (e.g., UTM, Albers, State Plane).
  • Calculating precise distances, bearings, and areas on the Earth's surface (Geodetic math).
  • Defining custom Coordinate Reference Systems (CRS).
  • Handling transformations between different vertical datums.
  • Working with "Great Circle" paths and geodesics.
  • Identifying the best UTM zone for a specific location.

Reference Documentation

Official docs: https://pyproj4.github.io/pyproj/ PROJ (Engine): https://proj.org/ EPSG Registry: https://epsg.io/ (Essential for finding CRS codes) Search patterns: pyproj.Transformer, pyproj.CRS, pyproj.Geod

Core Principles

CRS (Coordinate Reference System)

A definition of how numbers (coordinates) map to the real world. Can be defined via EPSG codes (EPSG:4326), PROJ strings, or WKT (Well-Known Text).

Transformer

An object optimized for converting many points from one CRS to another. Always use Transformer for bulk operations rather than one-off calls.

Geod

A class for performing "ellipsoid math". Use this for calculating distances on Earth without projecting to a flat map.

Quick Reference

Installation

pip install pyproj

Standard Imports

import pyproj
from pyproj import CRS, Transformer, Geod

Basic Pattern - Transformation

from pyproj import Transformer

# 1. Define the transformation (WGS84 to Web Mercator)
# always_xy=True ensures (lon, lat) order instead of PROJ default (lat, lon)
transformer = Transformer.from_crs("EPSG:4326", "EPSG:3857", always_xy=True)

# 2. Transform coordinates
lon, lat = -74.006, 40.7128 # NYC
x, y = transformer.transform(lon, lat)

print(f"Projected Meters: X={x:.2f}, Y={y:.2f}")

Critical Rules

✅ DO

  • Use always_xy=True - By default, PROJ 6+ uses the order defined by the CRS (often lat, lon). Setting always_xy=True forces the consistent longitude, latitude (X, Y) order.
  • Reuse Transformers - Creating a Transformer is expensive. Create it once and use it for all points in your dataset.
  • Use Geod for distance - If you need the distance between two GPS points, don't project them to a map; use Geod.inv() for ellipsoidal distance.
  • Check CRS Validity - Use CRS.from_user_input(code).is_valid to verify your projection strings.
  • Vectorize - Pass NumPy arrays or lists of coordinates to transformer.transform(). It is significantly faster than looping over points.

❌ DON'T

  • Project for short distances - For global analysis, don't project to a flat map to calculate distance; map projections introduce distortion (e.g., Mercator makes the poles look huge).
  • Hardcode Proj4 strings - Prefer EPSG codes (e.g., "EPSG:4326") as they are more robust and include modern datum transformations.
  • Ignore the Datum - Remember that moving between different datums (e.g., NAD27 to WGS84) requires specific transformation parameters.

Anti-Patterns (NEVER)

from pyproj import Transformer, Geod

# ❌ BAD: Creating a transformer inside a loop (Extremely slow!)
for lon, lat in coordinates:
    t = Transformer.from_crs("EPSG:4326", "EPSG:32633") # Initialization overhead
    x, y = t.transform(lon, lat)

# ✅ GOOD: Initialize once, transform in bulk
t = Transformer.from_crs("EPSG:4326", "EPSG:32633", always_xy=True)
lons, lats = zip(*coordinates)
xs, ys = t.transform(lons, lats)

# ❌ BAD: Calculating distance on a flat projection over long distances
# x1, y1 = t.transform(lon1, lat1)
# x2, y2 = t.transform(lon2, lat2)
# dist = np.sqrt((x1-x2)**2 + (y1-y2)**2) # ❌ Distorted result!

# ✅ GOOD: Use Geod for geodesic distance
g = Geod(ellps='WGS84')
az12, az21, dist = g.inv(lon1, lat1, lon2, lat2) # ✅ Accurate meters

Working with CRS (pyproj.CRS)

Inspection and Comparison

from pyproj import CRS

crs = CRS.from_epsg(4326)

# Accessing properties
print(crs.name)            # "WGS 84"
print(crs.area_of_use)     # Bounding box of applicability
print(crs.axis_info)       # Order of axes

# Check units
units = crs.axis_info[0].unit_name # 'degree' or 'metre'

# Comparing CRS
is_same = crs.equals(CRS.from_user_input("EPSG:4326"))

Transformation (pyproj.Transformer)

Handling Large Datasets

import numpy as np
from pyproj import Transformer

# Random points in NYC area
lons = -74.0 + np.random.rand(10000)
lats = 40.7 + np.random.rand(10000)

transformer = Transformer.from_crs(4326, 3857, always_xy=True)

# Transform entire arrays at once (Vectorized)
xs, ys = transformer.transform(lons, lats)

Geodetic Calculations (pyproj.Geod)

Distance, Area, and Paths

from pyproj import Geod

g = Geod(ellps='WGS84')

# 1. Inverse Transformation: Get distance and azimuth between points
# NYC to London
lon1, lat1 = -74.006, 40.7128
lon2, lat2 = -0.1278, 51.5074
az12, az21, dist = g.inv(lon1, lat1, lon2, lat2)
print(f"Distance: {dist/1000:.2f} km")

# 2. Forward Transformation: Find point given start, bearing, and distance
# Start at NYC, go 1000km East (bearing 90)
lon_new, lat_new, back_az = g.fwd(lon1, lat1, 90, 1000000)

# 3. Intermediate points (Great Circle path)
path = g.npts(lon1, lat1, lon2, lat2, npts=10) # 10 points along the path

# 4. Area of a polygon on the ellipsoid
lons = [-10, 10, 10, -10]
lats = [-10, -10, 10, 10]
area, perimeter = g.polygon_area_perimeter(lons, lats)
print(f"Area: {abs(area)/1e6:.2f} km²")

Practical Workflows

1. Identifying the UTM Zone Automatically

def get_utm_crs(lon, lat):
    """Returns the correct UTM CRS for a given lon/lat point."""
    utm_zone = int((lon + 180) / 6) + 1
    hemisphere = 'north' if lat >= 0 else 'south'
    # UTM EPSG ranges: 32601-32660 (North), 32701-32760 (South)
    base = 32600 if hemisphere == 'north' else 32700
    return CRS.from_epsg(base + utm_zone)

# Usage:
# my_crs = get_utm_crs(-74.0, 40.7) # Returns EPSG:32618 (UTM 18N)

2. Precise Point-to-Point Distance Matrix

import numpy as np
from pyproj import Geod

def calculate_distance_matrix(lons, lats):
    """Computes a symmetric distance matrix using the ellipsoid."""
    g = Geod(ellps='WGS84')
    n = len(lons)
    matrix = np.zeros((n, n))

    for i in range(n):
        for j in range(i + 1, n):
            _, _, d = g.inv(lons[i], lats[i], lons[j], lats[j])
            matrix[i, j] = matrix[j, i] = d
    return matrix

3. Converting Local Measurements to GPS

def local_to_gps(start_lon, start_lat, dx_meters, dy_meters):
    """Moves a GPS point by a local offset in meters."""
    g = Geod(ellps='WGS84')
    # Move in X (East-West)
    lon_tmp, lat_tmp, _ = g.fwd(start_lon, start_lat, 90 if dx_meters > 0 else 270, abs(dx_meters))
    # Move in Y (North-South)
    lon_final, lat_final, _ = g.fwd(lon_tmp, lat_tmp, 0 if dy_meters > 0 else 180, abs(dy_meters))
    return lon_final, lat_final

Performance Optimization

Using itransform for Iterators

If your data is coming from a generator and you don't want to load it all into memory, use itransform.

# Generator of (x, y) tuples
coords_gen = ((lon, lat) for lon, lat in my_source)

for x, y in transformer.itransform(coords_gen):
    process(x, y)

Parallel Transformation

Transformers are thread-safe. You can use them with concurrent.futures.

from concurrent.futures import ThreadPoolExecutor

with ThreadPoolExecutor() as executor:
    results = list(executor.map(lambda p: transformer.transform(*p), list_of_points))

Common Pitfalls and Solutions

The "Infinities" Problem

Projecting points outside a CRS's valid area (e.g., projecting 90° latitude in Mercator) will result in inf or nan.

# ✅ Solution: Check bounds before transforming
if not crs.area_of_use.contains(lon, lat):
    print("Point outside projection bounds!")

Lat/Lon vs Lon/Lat

Historically, GIS users say "Lat/Lon", but mathematically X=Lon, Y=Lat.

# ❌ Problem: transformer.transform(40.7, -74.0) -> Wrong result!
# ✅ Solution: Use always_xy=True and pass (Lon, Lat)
transformer = Transformer.from_crs(4326, 3857, always_xy=True)
transformer.transform(-74.0, 40.7)

Accuracy of Geodetic Formulas

By default, Geod is very accurate, but for sub-millimeter precision in complex cases:

# Use the Karney algorithm (built-in for modern pyproj)
g = Geod(ellps='WGS84') # This is already highly accurate

Best Practices

  1. Always use always_xy=True when creating Transformers to ensure consistent (lon, lat) ordering
  2. Create Transformers once and reuse them for bulk operations
  3. Use Geod for distance calculations on the ellipsoid rather than projecting to flat coordinates
  4. Prefer EPSG codes over Proj4 strings for better robustness and modern datum support
  5. Vectorize transformations by passing arrays/lists instead of looping over individual points
  6. Check CRS validity and area of use before transforming coordinates
  7. Be aware of datum transformations when converting between different reference systems
  8. Use itransform for memory-efficient processing of large datasets from generators

PyProj is the definitive tool for coordinate precision. By abstracting the complex spherical and ellipsoidal trigonometry of Earth, it allows scientists to focus on their data while ensuring their spatial calculations remain geographically valid.

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

35.3%
按下载量换算48

Claude

30.86%
按下载量换算42

Cursor

16.97%
按下载量换算23

Gemini CLI

8.6%
按下载量换算12

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills