The PLACES_COUNT_PER_TYPE function returns a table of counts for each place
type specified to the function. For example, if you search for the types
doctor, hospital, and pharmacy the response contains a table with a
separate row for each type.
Because the PLACES_COUNT_PER_TYPE function returns a table, call it using a
FROM clause.
Input parameters:
Required: The
geographyfilter parameter that specifies the search area. Thegeographyparameter takes a value defined by the BigQueryGEOGRAPHYdata type, which supports points, linestrings, and polygons.For examples of using different types of search geographies, such as viewports and lines, see
PLACES_COUNTfunction.Required: The
typesfilter parameter that specifies the place types to search for.Optional: Additional filter parameters to refine your search.
Returns:
A table with one row per
typesvalue. The table contains the columnstype(STRING),count(INT64), andplace_ids(ARRAY<STRING>) whereplace_idscontains up to 250 place IDs for eachtype.
Example: Return count of restaurant, cafes, and bars
In this example, you search for all operational restaurant, cafe, and bars in the specified search area defined as a polygon in New York City.
The types parameter takes an array of STRING values specifying the place
types to search for. For the complete list of possible values, see
Place types.
This example also uses the BigQuery
ST_GEOGFROMTEXT
function to return a GEOGRAPHY value from a polygon.
DECLARE geo GEOGRAPHY; SET geo = ST_GEOGFROMTEXT('''POLYGON((-73.985708 40.75773,-73.993324 40.750298, -73.9857 40.7484,-73.9785 40.7575, -73.985708 40.75773))'''); -- NYC viewport SELECT * FROM `PROJECT_NAME.places_insights___us.PLACES_COUNT_PER_TYPE`( JSON_OBJECT( 'types', ["restaurant", "cafe", "bar"], 'geography', geo, 'business_status', ['OPERATIONAL'] ) );
This function returns a table with three rows, one per type:
