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

# Buffer

> Expand or contracts the boundaries of a polygon or line

export const gemName_0 = "Buffer"

export const execution_engine_0 = "the SQL warehouse"

<Info>This gem runs in {execution_engine_0}.</Info>

## Overview

Use the Buffer gem to take any polygon or line and expand or contract its boundaries. This can be useful for spatial analysis tasks like creating safety zones around hazardous areas, expanding service coverage areas, and analyzing proximity impacts.

<Tip>
  The {gemName_0} gem has a corresponding interactive gem example. See [Interactive gem
  examples](/data-analysis/gems/gems#interactive-gem-examples) to learn how to run sample pipelines
  for this and other gems.
</Tip>

## Prerequisites

* Add `ProphecyDatabricksSqlSpatial` version 0.0.3 or higher to your project.
* Run Databricks Runtime 17.1 or higher. (This requirement is due to the use of Databricks' [ST geospatial functions](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-st-geospatial-functions).)

  Other SQL warehouse providers are not supported for this gem.

## Input and Output

The Buffer gem accepts the following inputs and output.

| Port    | Description                                                                                                               |
| ------- | ------------------------------------------------------------------------------------------------------------------------- |
| **in0** | Input dataset containing the source points in WKT format for which you want to find the nearest points.                   |
| **out** | Output dataset that contains two columns: `input` with the original geometry, and `output` with the transformed geometry. |

<Tip>
  Input geometries must be in Well-known Text
  ([WKT](https://en.wikipedia.org/wiki/Well-known_text_representation_of_geometry)) geometric
  format. Use the [PolyBuild](/data-analysis/gems/spatial/polybuild) gem to create lines and
  polygons in this format from latitude and longitude coordinates.
</Tip>

## Parameters

Configure the Buffer gem using the following parameters.

| Parameter       | Description                                                                                                                     |
| --------------- | ------------------------------------------------------------------------------------------------------------------------------- |
| Geometry column | Column containing the polygon or line you want to expand or contract.                                                           |
| Distance        | Amount of distance to expand or contract each geometry. Use negative distances to create inward buffers (shrinking geometries). |
| Units           | Unit of measurement for the distance you defined.                                                                               |

## Example

Let's say you're working with a transportation dataset and need to create safety corridors around major highways. You have highway routes as polylines and want to create 3 mile buffer zones on both sides of each road for noise impact analysis.

1. Add a Buffer gem to your pipeline canvas.
2. Attach an input that includes the highway routes as polylines in a `routes` column.
3. Open the gem configuration interface.
4. For **Geometry column**, select the `routes` column from the input table.
5. For **Distance**, input `3`.
6. For **Units**, select **Miles**.
7. Save and run the gem.

### Result

The output will contain both the original routes and your transformed highway routes.
