> [!NOTE]
> **Note:** For significantly better performance and efficient batch processing, use [`PLACES_COUNT_V2`](https://developers.google.com/maps/documentation/placesinsights/place-count-functions/places-count-v2.md.txt).

The `PLACES_COUNT_PER_GEO` function takes an array of geographic areas to search
and returns a table of places counts per area. For example, if you specify an
array of zip codes as the search area, the response contains a table with a
separate row for each zip code.

Because the `PLACES_COUNT_PER_GEO` function returns a table, call it using
a `FROM` clause.

- Input parameters:

  - **Required** : The `geographies`
    [filter parameter](https://developers.google.com/maps/documentation/placesinsights/place-count-functions/filter-params) that specifies the search area. The
    `geographies` parameter takes an array of values defined by the BigQuery
    [`GEOGRAPHY`](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types#geography_type)
    data type, which supports points, linestrings, and polygons.

  - **Optional** : Additional [filter](https://developers.google.com/maps/documentation/placesinsights/place-count-functions/filter-params) parameters to refine your
    search.

- Returns:

  - A table with one row per geographic area. The table contains the columns `geography` (`GEOGRAPHY`), `count` (`INT64`), and `place_ids` (`ARRAY<STRING>`) where `place_ids` contains up to 250 place IDs for each geographic area.

## Example: Calculate the number of restaurants in each county of New York City

This example generates a table of counts of operational restaurants per county
in New York City.

> [!NOTE]
> **Note:** Because the response table contains a `geographies` field, you can visualize it using tools that support BigQuery `GEOGRAPHY` types. For an example of visualizing the results of a function, see [Visualize
> results](https://developers.google.com/maps/documentation/placesinsights/place-count-functions/places-count-per-geo#visualize_results). For more information and example on visualizing Places Insights results, see [Visualize query results](https://developers.google.com/maps/documentation/placesinsights/visualize-data.md.txt).

This example uses the [United States Census Bureau
Data](https://console.cloud.google.com/marketplace/product/united-states-census-bureau/us-geographic-boundaries)
BigQuery [public dataset](https://cloud.google.com/bigquery/public-data) to get
the boundaries for the three counties in New York City: "Queens","Kings", "New
York". The boundaries of each county are contained in the `county_geom` column.

This example then uses the BigQuery
[`ST_SIMPLIFY`](https://cloud.google.com/bigquery/docs/reference/standard-sql/geography_functions#st_simplify)
function to return a simplified version of `county_geom`. The `ST_SIMPLIFY`
function replaces nearly straight chains of edges with a single long edge.

```googlesql
DECLARE geos ARRAY<GEOGRAPHY>;

SET geos = (SELECT ARRAY_AGG(ST_SIMPLIFY(county_geom, 100))
            FROM `bigquery-public-data.geo_us_boundaries.counties`
            WHERE county_name IN ("Queens","Kings", "New York") AND state_fips_code = "36");

SELECT * FROM `PROJECT_NAME.places_insights___us.PLACES_COUNT_PER_GEO`(
  JSON_OBJECT(
      'geographies', geos,
      'types', ["restaurant"],
      'business_status', ["OPERATIONAL"]
      )
);
```

## Example: Calculate counts per county filtered by brand

The following example uses the `brand_ids` filter to retrieve
place counts and sample place IDs for specific brands, such as Starbucks
`"1413758728321880760"`:

```googlesql
DECLARE geos ARRAY<GEOGRAPHY>;

SET geos = (SELECT ARRAY_AGG(ST_SIMPLIFY(county_geom, 100))
            FROM `bigquery-public-data.geo_us_boundaries.counties`
            WHERE county_name IN ("Queens","Kings", "New York") AND state_fips_code = "36");

SELECT * FROM `PROJECT_NAME.places_insights___us.PLACES_COUNT_PER_GEO`(
  JSON_OBJECT(
      'geographies', geos,
      'brand_ids', ["1413758728321880760"], -- Filter for Starbucks
      'business_status', ["OPERATIONAL"]
      )
);
```

## Visualize results

The following images show this data displayed in Looker Studio as a filled map,
including the outline of each county:

![Filled map for filtering wheelchair accessible convenience and grocery stores in New York City.](https://developers.google.com/static/maps/documentation/placesinsights/images/place_count_geo_map.png)

To import your data into Looker Studio:

1. Run the function above to generate the results.

2. In the BigQuery results, click **Open in -\> Looker Studio**. Your results
   are automatically imported into Looker Studio.

3. Looker Studio creates a default report page and initializes it with a title,
   table, and bar graph of the results.

   ![Default report in Looker Studio.](https://developers.google.com/static/maps/documentation/placesinsights/images/default_data_view.png)
4. Select everything on the page and delete it.

5. Click **Insert -\> Filled map** to add a filled map to your report.

6. Under **Chart types -\> Setup** configure the fields as shown below::

   ![Heatmap setup in Looker Studio.](https://developers.google.com/static/maps/documentation/placesinsights/images/filled_geo_function_fields.png)
7. The filled map appears as above. You can optionally select **Chart types -\>
   Styles** to further configure the appearance of the map.

For more information and example on visualizing Places Insights results, see
[Visualize query results](https://developers.google.com/maps/documentation/placesinsights/visualize-data.md.txt).