Skip to content

Repository files navigation

Swiss Zoning API

A comprehensive API for Swiss zoning information, building regulations, and cadastral data. Get detailed information about parcels, zoning codes, building parameters, and public-law restrictions (ÖREB) across Switzerland.

Features

  • Address Geocoding - Convert Swiss addresses to coordinates and parcel information
  • Parcel Data - Retrieve EGRID, parcel numbers, and area from multiple authoritative sources
  • Zoning Information - Get zone codes, categories, and descriptions
  • Building Parameters - Access max height, floors, FAR, coverage limits, and setbacks
  • ÖREB Integration - Fetch public-law restrictions from official cadastre
  • Building Potential - Calculate development potential based on zoning rules
  • Multi-Source Aggregation - Combines data from federal, cantonal, and municipal sources
  • Zurich Optimization - Enhanced accuracy for Zurich addresses with WFS data

Tech Stack

  • Next.js 16 - React framework with App Router
  • TypeScript - Full type safety
  • Tailwind CSS - Styling
  • Leaflet - Interactive maps
  • Swiss APIs - geo.admin.ch, ÖREB, cantonal WFS services

Installation

# Clone repository
git clone <repository-url>
cd swiss-zoning-api

# Install dependencies
npm install
# or
pnpm install

# Run development server
npm run dev

Open http://localhost:3000 to view the application.

API Endpoints

GET /api/geocode

Search for Swiss locations, addresses, and parcels.

Parameters:

  • q (required) - Search query (address, place name)
  • limit (optional) - Maximum results (default: 10)
  • lat, lng (optional) - Reverse geocode coordinates

Response:

{
  "success": true,
  "query": "Bahnhofstrasse 1, Zürich",
  "results": [
    {
      "id": "123",
      "label": "Bahnhofstrasse 1, 8001 Zürich",
      "type": "address",
      "coordinates": {
        "lat": 47.3769,
        "lng": 8.5417,
        "swissEasting": 2683141,
        "swissNorthing": 1247825
      },
      "egrid": "CH139977917088",
      "municipality": "Zürich"
    }
  ]
}

GET /api/zoning

Get comprehensive zoning information for a Swiss address or parcel.

Parameters:

  • address (required*) - Full Swiss address
  • egrid (required*) - Swiss parcel identifier (EGRID)

*One of address or egrid is required.

Response:

{
  "success": true,
  "address": "Bahnhofstrasse 1, 8001 Zürich",
  "parcel": {
    "egrid": "CH139977917088",
    "number": "AA5662",
    "area": 513,
    "municipality": "Zürich",
    "canton": "ZH",
    "coordinates": {...},
    "areaSources": [
      {
        "value": 513,
        "source": "Zurich Map Viewer",
        "confidence": "high"
      }
    ]
  },
  "zone": {
    "code": "K",
    "name": "Kernzone",
    "category": "mixed",
    "description": "Central zone with mixed uses"
  },
  "buildingParameters": {
    "maxHeight": 25,
    "maxFloors": 6,
    "maxFloorAreaRatio": 4.0,
    "maxBuildingCoverage": 0.8
  },
  "buildingPotential": {
    "maxGrossFloorArea": 2052,
    "maxBuildingFootprint": 410,
    "estimatedUnits": 25,
    "developmentAssessment": "high"
  },
  "restrictions": [...],
  "allowedUses": ["Residential", "Commercial", "Office"],
  "prohibitedUses": ["Heavy Industry"],
  "legalReferences": [...],
  "sources": [...],
  "orebExtractPdfUrl": "https://...",
  "dataSourcesUsed": {
    "parcel": ["Zurich Map Viewer"],
    "zone": ["Zurich WFS"],
    "buildingParams": ["Zurich ÖREB WFS"],
    "restrictions": ["ÖREB"]
  }
}

Testing

# Run comprehensive test suite
npm test

# Test API endpoints
npm run test:apis

# Test Zurich addresses
npm run test:zurich

# Test building potential calculations
npm run test:potential

Key Implementation Details

Parcel Selection Algorithm

When multiple parcels overlap at a location (common in dense urban areas), the API uses a sophisticated selection algorithm:

  1. Identifies all parcels whose bounding boxes contain the query point
  2. Calculates the distance from the query point to each parcel's center
  3. Selects the parcel with the closest center to the query point

This ensures accurate parcel identification even in complex cadastral scenarios.

Example: Loorenstrasse 62, Zürich

  • Correct parcel: WI3988 (11,156 m², center 12.8m from query point)
  • Rejected: WI1743 (2,072 m², center 92.6m from query point)

Data Sources

The API aggregates data from multiple authoritative sources:

Federal:

  • Swiss Cadastral Survey (geo.admin.ch)
  • ÖREB Cadastre (cadastre.ch)
  • Swiss Coordinate Systems (LV95/WGS84)

Cantonal (Zurich):

  • Zurich ÖREB WFS (maps.zh.ch)
  • Zurich Cadastral WFS (maps.zh.ch/wfs/OGDZHWFS)
  • City of Zurich Zoning Maps (GIS-ZH)

Municipal:

  • Building regulations (BZO)
  • Zoning ordinances
  • Local restrictions

Multi-Source Area Calculation

Parcel area is fetched from multiple sources for accuracy:

  1. EGRID-based lookup (highest priority)
  2. Zurich Map Viewer API (for Zurich)
  3. Zurich WFS services
  4. geo.admin.ch identify service
  5. Building registry (GWR)

The API returns all sources with confidence levels for transparency.

Project Structure

swiss-zoning-api/
├── app/
│   ├── api/
│   │   ├── geocode/route.ts       # Geocoding endpoint
│   │   ├── zoning/route.ts        # Main zoning endpoint
│   │   └── oereb-pdf/route.ts     # ÖREB PDF proxy
│   ├── components/                 # React components
│   ├── page.tsx                    # Homepage
│   └── layout.tsx                  # Root layout
├── lib/
│   ├── services/                   # API services
│   │   ├── geo-admin.ts           # Swiss federal APIs
│   │   ├── oereb.tsx              # ÖREB services
│   │   ├── zurich-zoning.tsx      # Zurich-specific
│   │   ├── zurich-oereb-map.ts    # Zurich cadastre
│   │   ├── parcel-data.ts         # Multi-source parcel
│   │   └── building-potential.ts   # Calculations
│   ├── types/
│   │   └── zoning.ts              # TypeScript types
│   └── utils/                      # Utilities
├── test-*.ts                       # Test scripts
└── package.json

Configuration

Environment Variables

No environment variables required - all APIs are public.

TypeScript

The project uses strict TypeScript configuration with full type safety across all API integrations.

Development

Adding a New Canton

  1. Add canton configuration to lib/constants/cantons.ts
  2. Implement WFS parser in lib/services/[canton]-zoning.ts
  3. Add canton detection to lib/services/geo-admin.ts
  4. Update zoning route to handle new canton

Adding New Data Sources

  1. Create service in lib/services/
  2. Add type definitions to lib/types/zoning.ts
  3. Integrate in lib/services/parcel-data.ts for aggregation
  4. Update dataSourcesUsed tracking in api/zoning/route.ts

API Limits & Considerations

  • Rate Limits: Respects geo.admin.ch rate limits (no authentication required)
  • ÖREB Availability: Some cantons may have limited ÖREB data
  • Accuracy: Parcel areas are approximate; consult official documents for legal matters
  • Coverage: Best coverage for Zurich; other cantons use federal data

Legal Disclaimer

This API provides informational data from public Swiss government sources. For official building permits and legal decisions, always consult:

  • Your local building authority (Bauamt)
  • Official ÖREB extracts
  • Licensed surveyors and architects

Data sources:

  • Swiss Federal Office of Topography (swisstopo)
  • Swiss ÖREB Cadastre
  • Cantonal and municipal authorities

License

Private - Not yet open source

Support

For questions or issues, please contact the project maintainer.


Built with Next.js • TypeScript • Swiss Data

About

API for Swiss zoning codes, building regulations, and cadastral data with interactive maps and ÖREB integration

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages