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

# Urban Construction Near Riparian Areas

> Analyze riparian zone urbanization gradients and quantify built-up surface density changes with distance from river systems

# Urban Construction Near Riparian Areas

<img src="https://mintcdn.com/nika/KF-c86_3b0KWdTjW/industrial-solutions/urban-construction-riparian-areas.jpeg?fit=max&auto=format&n=KF-c86_3b0KWdTjW&q=85&s=b212dfdb6ab2ddbc25756209c97cc840" alt="Urban Construction Near Riparian Areas" width="1000" height="768" data-path="industrial-solutions/urban-construction-riparian-areas.jpeg" />

## Riparian Zone Urbanization Gradients

This project performs an analysis of riparian zone urbanization gradients near the Amazon River, specifically focusing on a defined area near Manaus. It quantifies how built-up surface density changes with increasing distance from river systems, providing insights into human impact on riparian ecosystems.

## Resources Needed

### Software

* Python 3.x

### Libraries

* **earthengine-api**: For interacting with Google Earth Engine
* **pandas**: For data manipulation and analysis
* **matplotlib**: For creating static, interactive, and animated visualizations in Python
* **numpy**: For numerical operations
* **seaborn**: For statistical data visualization
* **Pillow (PIL)**: For image processing
* **requests**: For making HTTP requests (e.g., downloading images)

### Google Earth Engine Account

An active Google Earth Engine account is required to access the spatial datasets.

### Internet Connection

Essential for accessing Earth Engine data and services.

## Input Files

This project does not require explicit input files from your local machine. All necessary spatial data is accessed directly from the Google Earth Engine data catalog:

* **WWF/HydroSHEDS/v1/FreeFlowingRivers**: Global dataset of free-flowing rivers
* **JRC/GHSL/P2023A/GHS\_BUILT\_S**: Global Human Settlement Layer (GHSL) Built-up Surface dataset for 2020
* **FAO/GAUL/2015/level2** (Optional): Administrative boundaries used if the AOI is defined by an administrative name (not used in the provided code's default AOI)

## Output Files

The project generates output files within a newly created output folder:

* **riparian\_amazon\_analysis\_YYYYMMDD\_HHMMSS.png**: A high-resolution PNG image of the generated plots, visualizing the urbanization gradient and the spatial distribution of buffer zones
* **riparian\_amazon\_results\_YYYYMMDD\_HHMMSS.csv**: A CSV file containing the detailed urbanization metrics for each riparian buffer zone, including area, mean built-up percentage, and standard deviation
* **riparian\_amazon\_summary\_YYYYMMDD\_HHMMSS.txt**: A text file providing a summary report of the analysis, including key statistics, correlations, and a breakdown of built-up percentages per zone

## Step-by-Step Analysis

### 1. Initialize Earth Engine

Authenticate and initialize the Google Earth Engine API to enable data access.

### 2. Define Area of Interest (AOI)

Specify the geographical region for the analysis, in this case, a rectangle near Manaus, Amazon River.

### 3. Load Datasets

Import the HydroRIVERS dataset for river networks and the GHSL Built-up Surface dataset for urbanization data from Earth Engine.

### 4. Filter Rivers

Clip and filter the global HydroRIVERS dataset to retain only the river segments within the defined AOI.

### 5. Create Buffer Zones

Generate non-overlapping buffer rings around the filtered river segments at specified distances (e.g., 0-100m, 100-200m, etc.).

### 6. Extract Urbanization Metrics

For each buffer zone, calculate descriptive statistics (mean, standard deviation, min, max, pixel count) of the built-up surface percentage using the GHSL data.

### 7. Create Results DataFrame

Organize the extracted urbanization metrics into a pandas DataFrame, adding columns for distance ranges and midpoints for easier analysis.

### 8. Generate Buffer Map Image

Create a static thumbnail image from Earth Engine visualizing the defined buffer zones and rivers within the AOI, with distinct colors for each zone.

### 9. Visualize Gradient

Generate a multi-panel plot including a line plot of urbanization intensity vs. distance, a bar chart of built-up percentages per zone, a scatter plot of area vs. built-up, and the generated buffer map image.

### 10. Perform Statistical Analysis

Calculate key statistics, such as correlation between distance and built-up density, and the average gradient slope, to quantify the urbanization pattern.

### 11. Export Results

Save the detailed results DataFrame to a CSV file, and generate a comprehensive summary report as a text file in a dedicated output folder.

***

<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/d97e260c-17ad-46d1-93bc-e179baea1eff" 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>
