> For the complete documentation index, see [llms.txt](https://help.felt.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.felt.com/layers/spatial-analysis.md).

# Spatial analysis

Analyze layers with Felt's spatial analysis tools.

{% embed url="<https://www.youtube.com/watch?v=MudknS9d-y0>" %}

Manipulate and analyze geographic data to extract meaningful insights. Combine layers, identify patterns, and discover spatial relationships to make informed decisions.

## Using spatial analysis

To perform analysis on layers, click on the ![](https://217108486-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmRfGitkyjOEMvVsEyGWN%2Fuploads%2FFXhPP6A5qGrl52o8O5IM%2Ftransformations.svg?alt=media\&token=ebf46d3c-a17f-48fb-acb5-393e90c8e663) **Analysis** tool in the toolbar, or use the **Command/Control + K** keyboard shortcut and type **Analysis** or the name of any specific analysis, like **Buffer**.

## Available methods

{% hint style="warning" %}
Processing large layers could take time. Consider clipping large layers to your area of interest before running other operations.
{% endhint %}

### Single layer

| Name                      | Description                                                                      | Example use case                                                                                        | Input             | Output   |
| ------------------------- | -------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- | ----------------- | -------- |
| [**Buffer**](#buffer)     | For each feature, generate a polygon covering an area within a distance          | To identify specific locations that are within a certain radius of features like roads, hospitals, etc. | Any               | Polygons |
| [**Bounds**](#bounds)     | For each feature, generate a rectangular polygon completely covering the feature | To simplify features to broad coverage areas                                                            | Lines or polygons | Polygons |
| [**Centroid**](#centroid) | For each feature, generate a point at the center of it                           | To simplify a polygon layer to a point layer, like metro areas to just cities                           | Lines or polygons | Points   |
| [**Dissolve**](#dissolve) | Create a single new polygon covering all features                                | To simplify overlapping or contiguous polygons, like buffers                                            | Polygons          | Polygons |

### Multi layer

| Name                                | Description                                                                              | Example use case                                                                         | Input                     | Output                                              |
| ----------------------------------- | ---------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | ------------------------- | --------------------------------------------------- |
| [**Clip**](#clip)                   | Keep only the parts of each feature inside polygons from another layer                   | To reduce a global or countrywide layer to just an area of interest                      | Any and polygons          | Any (same as input)                                 |
| [**Count points**](#count-points)   | Add the total number of points covered by each polygon to each feature                   | Count the number of airports in each US state                                            | Points and polygon layers | Polygon layer with number of points as an attribute |
| [**Intersect**](#intersect)         | Keep only the features in layer A that intersect layer B                                 | To identify features that overlap another layer, like roads inside national parks        | Any and polygons          | Any (same as input)                                 |
| [**Subtract**](#subtract)           | Keep only the parts of each feature outside the polygons from another layer              | Remove flood zones from candidate areas for development projects                         | Any and polygons          | Any (same as input)                                 |
| [**Join**](#join)                   | For each feature, generate a new one that includes the columns from both input layers    | To add non-geographic data to a geographic layer, like GDP per year to a countries layer | Any and any               | Any (same as input)                                 |
| [**Sample raster**](#sample-raster) | For each feature, add statistics from a raster layer, or the raster's pixel value itself | To find the average elevation within each parcel from a digital elevation model          | Any and a raster layer    | Any (same as input)                                 |

{% hint style="info" %}
When using the Join tool always choose the layer with the target output geometry as the first layer in the dropdown menus of the analysis tool. When working with a non-spatial (tabular) layer, make sure to configure that table as the *second layer* in the menu.
{% endhint %}

### Buffer

**Buffer** creates a polygon around each feature of a point, line, or polygon layer, covering every location within a chosen distance, for example a half-mile buffer around each hospital. Enter a **Distance** and choose a unit (feet, meters, kilometers, miles, and more).

### Bounds

**Bounds** draws a rectangular box around each line or polygon feature, simplifying it to its bounding extent. Use it to reduce detailed shapes to broad coverage areas.

### Centroid

**Centroid** replaces each line or polygon feature with a single point at its geometric center, turning a line or polygon layer into a point layer while keeping the feature's other attributes.

### Clip

**Clip** trims each feature of the input layer down to only the parts that fall inside the overlay layer's polygons, keeping the input layer's original columns. Use it to cut a global or countrywide layer down to an area of interest.

### Count points

**Count points** adds a column to each polygon in the input layer with the number of points from the overlay layer that fall inside it, like counting the airports within each US state.

### Dissolve

**Dissolve** merges the polygon features of a layer together into fewer shapes. Choose whether to combine **All features** into a single polygon, or only **Overlapping features** into their own merged groups. Use it to simplify overlapping or contiguous polygons, like buffers.

### Intersect

**Intersect** creates a new feature everywhere an input layer feature overlaps an overlay layer polygon, trimmed to the overlapping area and carrying the columns from both layers. Use it to find features that overlap another layer, like roads inside national parks.

### Subtract

**Subtract** removes the parts of each input layer feature that fall inside the overlay layer's polygons, keeping only what's left outside them, for example removing flood zones from candidate areas for a development project.

### Join

**Join** combines the columns of two layers into one, matching rows using a **Join key** column you choose from each layer. By default the result keeps unmatched rows from both layers (a full outer join); use the checkboxes under the layer names to keep unmatched rows from only one layer, or neither.

### Sample raster

<figure><img src="https://217108486-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmRfGitkyjOEMvVsEyGWN%2Fuploads%2FSBaqDXXX73cf4tsREPJp%2Fblog-raster-sampling.png?alt=media&amp;token=bee1ab8c-c0a2-4b68-b81b-a525faddb9cb" alt=""><figcaption></figcaption></figure>

**Sample raster** reads a raster layer's values into a point, line, or polygon layer and writes them out as new columns. Raster layers have no attributes to click or join against, so this is how raster data gets into filters, styles, charts, and popups.

What gets read depends on the geometry you're sampling into:

* **Polygons** summarize every pixel inside the shape. A polygon smaller than a single pixel falls back to the one pixel containing its center, so small shapes still get a value.
* **Lines** are sampled at even intervals along the path, roughly one sample per pixel the line crosses, and the statistics summarize those samples.
* **Points** take the value of the single pixel they land on.

Choose the vector layer to calculate statistics for and a raster layer to read from, then set the following options:

* **Bands**: which of the raster's bands to read. Single-band rasters skip this control; multiband rasters list every band, all selected to start.
  * Styled bands are listed alongside the raw ones. A raster styled with **Raster algebra** adds the value its calculation produces, under the calculation's name. A raster styled in steps adds an entry like "Elevation classes", which samples the class each pixel falls into rather than its underlying value.
* **Zonal statistics** (for polygons), or **Statistics** (for lines): how the pixels get summarized.
  * Pick any combination of **Average**, **Median**, **Minimum**, **Maximum**, **Count**, and **Most common**, with **Sum** offered for polygons only. **Average** is selected by default. Reach for **Most common** on categorical rasters like land cover, where an average would be meaningless.
* **Selection method** (for polygons): which pixels count as inside the shape.
  * **Pixel center** includes a pixel only when its center falls within the polygon, and is the default. **All touched** includes every pixel the polygon touches, even partially, which makes the most difference for small or narrow shapes.
* **Sampling method** (for lines and points): how a value is read at a spot between pixel centers.
  * **Bilinear** blends the four nearest pixels and suits continuous data like elevation or temperature.
  * **Nearest** takes the closest pixel's value
  * Felt defaults to **Nearest** for rasters styled as **Categories** or **Image**, and **Bilinear** for everything else.

The result is a new layer with all of its original columns plus one per band and statistic.

{% hint style="info" %}
Features that fall outside the raster's coverage, or that cover only pixels with no data, come back empty rather than zero. Unlike the other analysis methods, **Sample raster** doesn't preview on the map: Felt shows a time estimate and creates the layer once the run finishes.
{% endhint %}

## Spatial analysis exercise

Try out Felt’s spatial analysis tools for yourself in this step-by-step tutorial to find suitable habitat for the Iberian Lynx!

Download the datasets: <https://drive.google.com/drive/folders/1eKmVEg1hZk8TlVnQPu150oaTQNu07YkX>

{% embed url="<https://www.youtube.com/watch?v=97NX-lqZjtU>" %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://help.felt.com/layers/spatial-analysis.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
