> ## Documentation Index
> Fetch the complete documentation index at: https://docs.nikaplanet.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Singapore MRT Yearly Visualisation

> Process Singapore MRT rail network GeoJSON and split into separate files organized by year and rail line for historical development analysis

# Singapore MRT Yearly Visualisation

<img src="https://mintcdn.com/nika/KF-c86_3b0KWdTjW/industrial-solutions/singapore-mrt-yearly-visualisation.jpeg?fit=max&auto=format&n=KF-c86_3b0KWdTjW&q=85&s=1561c12f16524a5bd0ea257f764a662f" alt="Singapore MRT Yearly Visualisation" width="999" height="767" data-path="industrial-solutions/singapore-mrt-yearly-visualisation.jpeg" />

## Singapore MRT Rail Network GeoJSON Year-wise Line Splitter

### Description

This Python script processes a comprehensive Singapore MRT (Mass Rapid Transit) rail network GeoJSON file and splits it into separate files organized by year and rail line. It normalizes line names, assigns feature numbers, and creates individual GeoJSON files for each line's opening year, making it easier to analyze the historical development of Singapore's rail transit system.

## Data Sources

### Primary Input

**sg-rail\_with\_years\_patched.geojson** - A comprehensive GeoJSON file containing Singapore's entire rail network with temporal data

### Input Directory

`/data/singapore_mrt/main_source_folder/`

## Input Data Structure

### Geometry Types Processed

* **LineString/MultiLineString** (rail lines)
* **Point** (stations/stops)
* **Polygon/MultiPolygon** (areas/zones)

### Required Properties

* **year**: Opening year of the rail segment
* **name**: Name/identifier of the rail line

## Rail Lines Covered

* **North South Line (NSL)**
* **East West Line (EWL)**
* **North East Line (NEL)**
* **Circle Line (CCL)**
* **Downtown Line (DTL)**
* **Thomson-East Coast Line (TEL)**
* **Bukit Panjang LRT (BPLRT)**
* **Sengkang LRT with East/West loops (SKLRT)**
* **Punggol LRT with East/West loops (PGLRT)**

## Output

### Generated Files

**Year-Line Specific Files**: Numbered GeoJSON files for each line-year combination

**Format**: `XX_singapore_[LINE_CODE]_[YEAR].geojson`

**Example**: `01_singapore_NSL_1987.geojson`

### Aggregated Files

* **singapore\_all\_points.geojson** - All station/point features
* **singapore\_all\_polygons.geojson** - All polygon/area features

### Output Directory

`/data/singapore_mrt/year_wise_geojsons_new/`

## Output Enhancements

### Feature Numbering

Each feature gets a sequential number property

### Normalized Codes

Standardized line codes (NSL, EWL, etc.)

### Chronological Organization

Files sorted by opening years (1987-2020)

## Libraries Used

### Core Python Libraries

* **os**: File system operations and directory management
* **json**: JSON file reading, writing, and manipulation
* **collections.defaultdict**: Efficient nested dictionary creation for grouping features

### Geospatial Libraries

* **shapely.geometry**:
  * **shape**: Converting GeoJSON geometry to Shapely objects
  * **mapping**: Converting Shapely objects back to GeoJSON format
  * Used for potential geometric operations (imported but not actively used in current implementation)

***

<div className="solution-cta">
  <div className="solution-cta-content">
    <h3>🚀 Ready to implement this solution?</h3>
    <p>Access the complete code, step-by-step instructions, and interactive notebook in Nika Hub.</p>

    <a href="https://planet.nika.eco/en/hub/solutions/08279572-a80e-4cca-a8d2-79c54817d35c" target="_blank" className="solution-button">
      View Full Solution →
    </a>
  </div>
</div>

<style jsx>
  {`
    .solution-cta {
      background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
      border-radius: 12px;
      padding: 2rem;
      margin: 2rem 0;
      color: white;
      text-align: center;
      box-shadow: 0 8px 32px rgba(102, 126, 234, 0.3);
    }

    .solution-cta-content h3 {
      margin: 0 0 0.5rem 0;
      font-size: 1.5rem;
      font-weight: 600;
    }

    .solution-cta-content p {
      margin: 0 0 1.5rem 0;
      opacity: 0.9;
      font-size: 1.1rem;
    }

    .solution-button {
      display: inline-block;
      background: rgba(255, 255, 255, 0.2);
      color: white;
      padding: 12px 24px;
      border-radius: 8px;
      text-decoration: none;
      font-weight: 600;
      font-size: 1.1rem;
      border: 2px solid rgba(255, 255, 255, 0.3);
      transition: all 0.3s ease;
      backdrop-filter: blur(10px);
    }

    .solution-button:hover {
      background: rgba(255, 255, 255, 0.3);
      border-color: rgba(255, 255, 255, 0.5);
      transform: translateY(-2px);
      box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    }
    `}
</style>
