timescale avatar

Design Postgis Tables

This is a well-structured reference for designing spatial tables in PostGIS. It walks you through the geometry versus geography decision (projected versus spherical calculations), explains when to use each geometry type (point, linestring, polygon), and covers SRID selection with practical examples. The five opening questions about scope, query patterns, and scale help you make the right choices upfront. What stands out is the clear guidance on spatial indexing with GiST and the comparison tables that cut through the complexity. If you're building anything location-based, from store locators to regional GIS systems, this gives you the patterns to avoid common mistakes like mixing coordinate systems or choosing the wrong index type. The SQL injection reminder is a good touch for production code.

skills.sh installs
370
GitHub stars
1.9K
last updated
Aug 21, 2026

Install

$ npx -y skills add timescale/pg-aiguide --skill design-postgis-tables --agent claude-code

Installs into .claude/skills of the current project.

Files

PostGIS Spatial Table Design

Before You Start (5 Questions)

  1. What is the geographic scope (single city/region vs global)?
  2. What are your primary query patterns (within-radius, bbox, intersects, nearest-neighbor)?
  3. What units do you need for distance/area (meters vs CRS units), and how accurate must they be?
  4. What is the expected scale (rows, write rate), and is the data mostly append-only?
  5. Do you need 3D (Z) or measures (M), or is 2D enough?

SQL injection note: When turning these patterns into application code, use parameterized queries for user-provided values (WKT/WKB, coordinates, IDs, radii). Avoid string-concatenating untrusted input into SQL; for dynamic identifiers, use safe identifier quoting/whitelisting.

Core Rules

Sponsors

Details

Repository
github.com/timescale/pg-aiguide
Categories
Debugging, Design & UI/UX
License
Apache-2.0
First seen
Jun 3, 2026

More from timescale/pg-aiguide

All 8

Recommended

More Debugging
1timescale avatarmigrate-postgres-tables-to-hypertablestimescale/pg-aiguideUse this skill to migrate identified PostgreSQL tables to Timescale/TimescaleDB hypertables with optimal configuration and validation. **Trigger when user asks 368skills.sh installs
2syncfusion avatarsyncfusion-blazor-speech-to-textsyncfusion/blazor-ui-components-skillsImplement speech-to-text voice input in Blazor applications using Syncfusion SpeechToText component. ALWAYS use this when users need voice input, speech recogni367skills.sh installs
3octagonai avatarfinancial-metrics-analysisoctagonai/skillsAnalyze year-over-year growth in income statement items and financial metrics using Octagon MCP. Use when retrieving YoY Revenue Growth, Cost of Revenue Growth,366skills.sh installs
4jezweb avatarfirebase-authjezweb/claude-skillsBuild with Firebase Authentication - email/password, OAuth providers, phone auth, and custom tokens. Use when: setting up auth flows, implementing sign-in/sign-363skills.sh installs
5jezweb avatarneon-vercel-postgresjezweb/claude-skillsSet up serverless Postgres with Neon or Vercel Postgres for Cloudflare Workers/Edge. Includes connection pooling, git-like branching, and Drizzle ORM integratio363skills.sh installs
6pedronauck avatarvercel-react-best-practicespedronauck/skillsReact and Next.js performance optimization guidelines from Vercel Engineering. This skill should be used when writing, reviewing, or refactoring React/Next.js c360skills.sh installs