For the complete documentation index, see llms.txt. This page is also available as Markdown.

Spatial filter

Filter map layers by drawing a polygon or circle with the Spatial filter. View statistics for the area or export the filtered data.

Add the Spatial filter extension so people can draw a polygon or circle to filter your map. Its panel shows layer results, such as counts and averages, plus the shape's measurements. Anyone viewing the map can use it.

Circle drawn over San Francisco street trees, with the Spatial filter panel showing a count of 2,119 and the circle's radius, area, and perimeter.

Add a Spatial filter

  1. On the map, click Edit map.

  2. In the toolbar, click Developer Platform > Spatial filter. The filter appears in the Extensions section of the legend, and its settings open.

  3. Optional: In Title, enter a name for the tool.

  4. In Types, select the shapes people can draw: Polygon, Circle, or both.

  5. Under Filter results from…, turn on each layer the filter applies to.

A Spatial filter can apply to vector and raster layers. Layers that stream pre-rendered tiles from a remote tile service can't be filtered, so their switches are unavailable. To change the settings later, in edit mode, click the filter in the Extensions section of the legend.

Draw a filter

A Spatial filter works in view mode, including in an embed, but not in edit mode. If you're editing, click Done first.

  1. In the legend, click the Spatial filter.

  2. If the filter offers both shapes, select Polygon or Circle.

  3. Draw the shape on the map. The filtered layers show only what falls inside it, and the panel shows the results.

  4. Click Done. The panel closes, and the filter stays in place.

Drawing more than one shape filters to their combined area. To remove the filter, click the trash icon at the top of the Spatial filter panel.

Only the person who draws a Spatial filter sees it, and it clears when they leave the map. The layer doesn't change. To show everyone a filtered view, filter the layer itself. To make a new layer from the features inside an area, use the Clip operation in Spatial analysis.

Filter results

The Spatial filter panel shows one result for each filtered layer:

  • Vector layer: a feature count, such as Count of Parcels. A line or polygon that falls only partly inside the shape counts in full.

  • Raster layer: the average value of the band used to style the layer, such as Average of Elevation, or the most common value for a raster styled by category.

Under the results, the Measurements section shows the shape's area and perimeter. For a circle, it also shows the radius.

A map's dashboard components respond to the Spatial filter while Update based on other filters is on (the default), so they chart only the area someone draws.

Export the filtered area

To export data inside a Spatial filter, click the download icon at the top of its panel. Select GeoPackage, GeoJSON, CSV, Shapefile, KML, or GeoParquet for vector layers, or GeoTIFF for raster layers. A vector export includes each whole feature that intersects the shape. A GeoTIFF export is clipped to the shape.

The download icon appears for people with Edit access to the map. For other logged-in people and people viewing an authenticated embed, it appears only when the viewer Export data setting is on. See Map settings and Export data.

Last updated

Was this helpful?