> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://help.sigmacomputing.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://help.sigmacomputing.com/_mcp/server.

# Within

The **Within** function determines if one geography is fully contained within another geography.

This function isn't compatible with all data platform connections. To check if your connection supports it, see [Supported data platforms and feature compatibility](/docs/region-warehouse-and-feature-support#supported-data-platforms-and-feature-compatibility).

## Syntax

```
Within(geography1, geography2)
```

The function has these arguments:

<dl>
  <dt>
    geography1
  </dt>

  <dd>
    Required
  </dd>

  <dd>
    The geography value that might be contained within geography2.
  </dd>

  <dd>
    Can be a point, a line, or polygon
  </dd>

  <dt>
    geography2
  </dt>

  <dd>
    Required
  </dd>

  <dd>
    The geography value that might contain geography1.
  </dd>
</dl>

## Examples

```
Within(Geography("POLYGON((1 1, 2 1, 2 2, 1 2, 1 1))"), Geography("POLYGON((0 0, 3 0, 3 3, 0 3, 0 0))"))
```

The function returns `True`, because the first polygon is fully contained within the second.

```
Within([Centroid], [Coordinates])
```

```
Within(MakePoint(-73.985428, 40.748817), [Coordinates])
```

The first **Within** function determines if the **Centroid** of the polygon is within the polygon, while the second function determines if the Empire State Building (-73.985428, 40.748817) is within the polygon.

![Example of Within function, confirming that the centroid of a polygon is within it](https://files.buildwithfern.com/sigma.docs.buildwithfern.com/6a98f868e2dd789fa90a545e70953330cc212299a7b8ffaac959e5cf24013548/assets/docs-images/0cc74b9-1.png)

```
Within([Coordinates], [Brooklyn])
```

The **Within** function determines if the values in the **Coordinates** column are within the boundaries of Brooklyn.

![Example of Within function, determining if a location is in Brooklyn](https://files.buildwithfern.com/sigma.docs.buildwithfern.com/5b53102faeaf60915d38974b4ad7fd2f2854c8650706d4da6d934fb6ad987592/assets/docs-images/8016df4-2.png)

## Related resources

* [Centroid](/docs/centroid)
* [MakePoint](/docs/makepoint)
* [MakeLine](/docs/makeline)
* [Intersects](/docs/intersects)
* [Geography functions](/docs/geography-functions)