science 이 제품 또는 기능은 실험용 (GA 이전) 버전입니다. GA 이전 제품과 기능은 지원이 제한될 수 있으며, GA 이전 제품과 기능이 변경된 경우 다른 GA 이전 버전과 호환되지 않을 수 있습니다. GA 이전 버전 제품 및 서비스에는
Google Maps Platform 서비스별 약관이 적용됩니다. 자세한 내용은
출시 단계 설명을 참조하세요.
가입하여 장소 통계를 테스트해 보세요.
PLACES_COUNT 함수
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
PLACES_COUNT
함수는 지정된 검색 영역과 검색 필터를 기반으로 장소의 단일 개수 값을 반환합니다. PLACES_COUNT
함수에 검색 영역을 지정해야 하며, 필요에 따라 장소 유형, 영업 상태, 가격대 등 추가 필터 매개변수를 지정할 수 있습니다.
PLACES_COUNT
함수는 단일 값을 반환하므로 SELECT
절을 사용하여 호출합니다.
입력 매개변수:
필수: 검색 영역을 지정하는 geography
필터 매개변수입니다. geography
매개변수는 점, 선, 다각형을 지원하는 BigQuery GEOGRAPHY
데이터 유형으로 정의된 값을 사용합니다.
선택사항: 검색을 상세검색하기 위한 추가 필터 매개변수입니다.
반환:
예: 검색 반경 내 장소 수 계산
가장 간단한 PLACES_COUNT
함수 호출은 지리적 영역에 있는 모든 장소의 단일 개수를 반환합니다. 이 예에서는 엠파이어 스테이트 빌딩에서 1, 000미터 이내에 있는 모든 영업 중인 장소의 수를 반환합니다.
이 예에서는 BigQuery ST_GEOGPOINT
함수를 사용하여 점에서 GEOGRAPHY
값을 반환합니다.
SELECT `maps-platform-analytics-hub.sample_places_insights_us.PLACES_COUNT`(
JSON_OBJECT(
'geography', ST_GEOGPOINT(-73.9857, 40.7484), -- Empire State Building
'geography_radius', 1000 -- Radius in meters
)
) as count;
응답에는 단일 개수가 포함됩니다.

더 일반적인 호출은 검색 영역에 필터를 적용합니다. 다음 예에서는 필터를 사용하여 검색을 제한하여 다음 개수만 반환합니다.
- 최소 평점이 3인
restaurant
유형의 장소
- 저렴 또는 중간 가격대
- 현재 운영 중
- 반려견 동반 가능
SELECT `maps-platform-analytics-hub.sample_places_insights_us.PLACES_COUNT`(
JSON_OBJECT(
'geography', ST_GEOGPOINT(-73.9857, 40.7484), -- Empire State Building
'geography_radius', 1000, -- Radius in meters
'types', ["restaurant"],
'min_rating', 3,
'price_level', ['PRICE_LEVEL_INEXPENSIVE', 'PRICE_LEVEL_MODERATE'],
'business_status', ['OPERATIONAL'],
'allows_dogs', TRUE
)
) as count;
필터링된 응답:

장소 데이터 세트 쿼리는 최소 개수 기준점 5를 적용합니다. 위치 개수 함수의 장점 중 하나는 0을 포함한 모든 개수를 반환할 수 있다는 것입니다. 예를 들어 다음 호출은 1을 반환합니다.
SELECT `maps-platform-analytics-hub.sample_places_insights_us.PLACES_COUNT`(
JSON_OBJECT(
'geography', ST_GEOGPOINT(-73.9857, 40.7484), -- Empire State Building
'geography_radius', 500, -- Radius in meters
'types', ["restaurant"],
'min_rating', 4.0,
'free_parking_lot', TRUE,
'good_for_watching_sports', TRUE
)
) as count;
예: 다각형을 사용하여 음식점 수 계산
다각형을 사용하여 검색 영역을 지정할 수 있습니다. 다각형을 사용하는 경우 다각형의 점은 다각형의 첫 번째 점이 마지막 점과 동일한 닫힌 루프를 정의해야 합니다.
이 예에서는 BigQuery ST_GEOGFROMTEXT
함수를 사용하여 다각형에서 GEOGRAPHY
값을 반환합니다.
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 `maps-platform-analytics-hub.sample_places_insights_us.PLACES_COUNT`(
JSON_OBJECT(
'geography',geo, -- viewport
'types', ["restaurant"],
'min_rating', 1.0,
'max_rating', 4.5,
'min_user_rating_count', 1,
'max_user_rating_count', 10000,
'price_level', ['PRICE_LEVEL_INEXPENSIVE', 'PRICE_LEVEL_MODERATE'],
'business_status', ['OPERATIONAL'],
'allows_dogs', TRUE
)
) as count;
표시 영역의 응답은 다음과 같습니다.

예: 선을 사용하여 음식점 수 계산
다음 예에서는 연결된 점의 선을 사용하여 검색 영역을 정의하고 선 주변의 검색 반경을 100미터로 설정합니다.
이 선은 Routes API에서 계산한 이동 경로와 유사합니다. 경로는 차량, 자전거 또는 보행자용일 수 있습니다.
DECLARE geo GEOGRAPHY;
SET geo = ST_GEOGFROMTEXT('LINESTRING(-73.98903537033028 40.73655649223003,-73.93580216278471 40.80955538843361)'); -- NYC line
SELECT `maps-platform-analytics-hub.sample_places_insights_us.PLACES_COUNT`(
JSON_OBJECT(
'geography',geo, -- line
'geography_radius', 100, -- Radius around line
'types', ["restaurant"],
'min_rating', 1.0,
'max_rating', 4.5,
'min_user_rating_count', 1,
'max_user_rating_count', 10000,
'price_level', ['PRICE_LEVEL_INEXPENSIVE', 'PRICE_LEVEL_MODERATE'],
'business_status', ['OPERATIONAL'],
'allows_dogs', TRUE
)
) as count;
다음과 같은 대답이 표시됩니다.

예: 여러 호출의 결과 결합
PLACES_COUNT
함수에 대한 여러 호출 결과를 결합할 수 있습니다.
예를 들어 특정 지역 내에서 다음 가격대의 음식점 수를 보여주는 단일 결과를 원합니다.
PRICE_LEVEL_INEXPENSIVE
PRICE_LEVEL_MODERATE
PRICE_LEVEL_EXPENSIVE
PRICE_LEVEL_VERY_EXPENSIVE"
이 예에서는 각 가격 수준에 대해 PLACES_COUNT
함수를 호출하는 루프를 만들고 각 호출의 결과를 임시 테이블에 삽입합니다. 그런 다음 임시 테이블을 쿼리하여 결과를 표시합니다.
-- Create a temp table to hold the results.
CREATE TEMP TABLE results (type STRING, count INT64);
-- Create a loop that calls PLACES_COUNT for each price level.
FOR types IN (SELECT type FROM UNNEST(["PRICE_LEVEL_INEXPENSIVE", "PRICE_LEVEL_MODERATE", "PRICE_LEVEL_EXPENSIVE", "PRICE_LEVEL_VERY_EXPENSIVE"]) as type)
DO
INSERT INTO results VALUES (types.type, `maps-platform-analytics-hub.sample_places_insights_us.PLACES_COUNT`(
JSON_OBJECT(
'types', ["restaurant"],
'geography', ST_GEOGPOINT(-73.9857, 40.7484), -- Empire State Building
'geography_radius', 1000, -- Radius in meters
'business_status', ['OPERATIONAL'],
'price_level', [types.type]
)));
END FOR;
-- Query the table of results.
SELECT * FROM results;
결합된 대답:

또 다른 방법은 UNION ALL
명령어를 사용하여 여러 SELECT
문의 결과를 결합하는 것입니다. 다음 예시는 이전 예시와 동일한 결과를 보여줍니다.
SELECT "PRICE_LEVEL_INEXPENSIVE" as price_level, `maps-platform-analytics-hub.sample_places_insights_us.PLACES_COUNT`(
JSON_OBJECT(
'types', ["restaurant"],
'geography', ST_GEOGPOINT(-73.9857, 40.7484), -- Empire State Building
'geography_radius', 1000, -- Radius in meters
'business_status', ['OPERATIONAL'],
'price_level', ['PRICE_LEVEL_INEXPENSIVE']
)
) as count
UNION ALL
SELECT "PRICE_LEVEL_MODERATE" as price_level, `maps-platform-analytics-hub.sample_places_insights_us.PLACES_COUNT`(
JSON_OBJECT(
'types', ["restaurant"],
'geography', ST_GEOGPOINT(-73.9857, 40.7484), -- Empire State Building
'geography_radius', 1000, -- Radius in meters
'business_status', ['OPERATIONAL'],
'price_level', ['PRICE_LEVEL_MODERATE']
)
) as count
UNION ALL
SELECT "PRICE_LEVEL_EXPENSIVE" as price_level, `maps-platform-analytics-hub.sample_places_insights_us.PLACES_COUNT`(
JSON_OBJECT(
'types', ["restaurant"],
'geography', ST_GEOGPOINT(-73.9857, 40.7484), -- Empire State Building
'geography_radius', 1000, -- Radius in meters
'business_status', ['OPERATIONAL'],
'price_level', ['PRICE_LEVEL_EXPENSIVE']
)
) as count
UNION ALL
SELECT "PRICE_LEVEL_VERY_EXPENSIVE" as price_level, `maps-platform-analytics-hub.sample_places_insights_us.PLACES_COUNT`(
JSON_OBJECT(
'types', ["restaurant"],
'geography', ST_GEOGPOINT(-73.9857, 40.7484), -- Empire State Building
'geography_radius', 1000, -- Radius in meters
'business_status', ['OPERATIONAL'],
'price_level', ['PRICE_LEVEL_VERY_EXPENSIVE']
)
) as count
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 Creative Commons Attribution 4.0 라이선스에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책을 참조하세요. 자바는 Oracle 및/또는 Oracle 계열사의 등록 상표입니다.
최종 업데이트: 2025-07-17(UTC)
[null,null,["최종 업데이트: 2025-07-17(UTC)"],[],[],null,["The `PLACES_COUNT` function returns a single count value of places based on the\nspecified search area and search filters. You must specify the search area to\nthe `PLACES_COUNT` function and can optionally specify additional filter\nparameters, such as place type, operating status, price level, and more.\n\nBecause the `PLACES_COUNT` function returns a single value, call it using\na `SELECT` clause.\n\n- Input parameters:\n\n - **Required** : The `geography` [filter parameter](/maps/documentation/placesinsights/experimental/filter-params) that\n specifies the search area. The `geography` parameter takes a value defined\n by the BigQuery\n [`GEOGRAPHY`](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types#geography_type)\n data type, which supports points, linestrings, and polygons.\n\n - **Optional** : Additional [filter](/maps/documentation/placesinsights/experimental/filter-params) parameters to refine your\n search.\n\n- Returns:\n\n - A single `count` value as an `INT64`.\n\nExample: Calculate the number of places in a search radius\n\nThe simplest `PLACES_COUNT` function call returns a single count of all places\nin a geographical area. In this example, you return the count of all operational\nplaces within 1000 meters of the Empire State building.\n\nThis example uses the BigQuery\n[`ST_GEOGPOINT`](https://cloud.google.com/bigquery/docs/reference/standard-sql/geography_functions#st_geogpoint)\nfunction to return a `GEOGRAPHY` value from a point. \n\n```googlesql\nSELECT `maps-platform-analytics-hub.sample_places_insights_us.PLACES_COUNT`(\n JSON_OBJECT(\n 'geography', ST_GEOGPOINT(-73.9857, 40.7484), -- Empire State Building\n 'geography_radius', 1000 -- Radius in meters\n )\n) as count;\n```\n\nThe response contains a single count:\n\nA more typical call applies filters to the search area. The next example uses\nfilters to limit the search to only return a count of:\n\n- Places of type `restaurant` with the minimum rating of 3\n- A price level of inexpensive or medium\n- Currently operational\n- Allows dogs\n\n```googlesql\nSELECT `maps-platform-analytics-hub.sample_places_insights_us.PLACES_COUNT`(\n JSON_OBJECT(\n 'geography', ST_GEOGPOINT(-73.9857, 40.7484), -- Empire State Building\n 'geography_radius', 1000, -- Radius in meters\n 'types', [\"restaurant\"],\n 'min_rating', 3,\n 'price_level', ['PRICE_LEVEL_INEXPENSIVE', 'PRICE_LEVEL_MODERATE'],\n 'business_status', ['OPERATIONAL'],\n 'allows_dogs', TRUE\n )\n) as count;\n```\n\nThe filtered response:\n\nRemember that place dataset queries enforce a minimum count threshold of\n5. One of the advantages of the place count functions is\nthat they can return any counts, including 0. For example, the following call\nreturns a count of 1: \n\n```googlesql\nSELECT `maps-platform-analytics-hub.sample_places_insights_us.PLACES_COUNT`(\n JSON_OBJECT(\n 'geography', ST_GEOGPOINT(-73.9857, 40.7484), -- Empire State Building\n 'geography_radius', 500, -- Radius in meters\n 'types', [\"restaurant\"],\n 'min_rating', 4.0,\n 'free_parking_lot', TRUE,\n 'good_for_watching_sports', TRUE\n )\n) as count;\n```\n\nExample: Calculate the number of restaurants using a polygon\n\nYou can use a polygon to specify the search area. When using a polygon,\nthe points of the polygon must define a closed loop where the first point in the\npolygon is the same as the last point.\n\nThis example uses the BigQuery\n[`ST_GEOGFROMTEXT`](https://cloud.google.com/bigquery/docs/reference/standard-sql/geography_functions#st_geogfromtext)\nfunction to return a `GEOGRAPHY` value from a polygon. \n\n```googlesql\nDECLARE geo GEOGRAPHY;\nSET geo = ST_GEOGFROMTEXT('''POLYGON((-73.985708 40.75773,-73.993324 40.750298,\n -73.9857 40.7484,-73.9785 40.7575,\n -73.985708 40.75773))'''); -- NYC viewport\n\nSELECT `maps-platform-analytics-hub.sample_places_insights_us.PLACES_COUNT`(\n JSON_OBJECT(\n 'geography',geo, -- viewport \n 'types', [\"restaurant\"],\n 'min_rating', 1.0,\n 'max_rating', 4.5,\n 'min_user_rating_count', 1,\n 'max_user_rating_count', 10000,\n 'price_level', ['PRICE_LEVEL_INEXPENSIVE', 'PRICE_LEVEL_MODERATE'],\n 'business_status', ['OPERATIONAL'],\n 'allows_dogs', TRUE\n )\n) as count;\n```\n\nThe response for the viewport:\n\nExample: Calculate the number of restaurants using a line\n\nIn the next example, you define the search area using a line of connected\npoints with a search radius of 100 meters around the line.\nThe line is similar to a travel route calculated by the [Routes\nAPI](/maps/documentation/routes). The route might be for a vehicle, a bicycle,\nor for a pedestrian: \n\n```googlesql\nDECLARE geo GEOGRAPHY;\nSET geo = ST_GEOGFROMTEXT('LINESTRING(-73.98903537033028 40.73655649223003,-73.93580216278471 40.80955538843361)'); -- NYC line\n\nSELECT `maps-platform-analytics-hub.sample_places_insights_us.PLACES_COUNT`(\n JSON_OBJECT(\n 'geography',geo, -- line\n 'geography_radius', 100, -- Radius around line\n 'types', [\"restaurant\"],\n 'min_rating', 1.0,\n 'max_rating', 4.5,\n 'min_user_rating_count', 1,\n 'max_user_rating_count', 10000,\n 'price_level', ['PRICE_LEVEL_INEXPENSIVE', 'PRICE_LEVEL_MODERATE'],\n 'business_status', ['OPERATIONAL'],\n 'allows_dogs', TRUE\n )\n) as count;\n```\n\nThe response for the line:\n\nExample: Combine the results of multiple calls\n\nYou can combine the results of multiple calls to the `PLACES_COUNT` function.\nFor example, you want a single result showing the number of restaurants for\nthe following price levels within a specific area:\n\n- `PRICE_LEVEL_INEXPENSIVE`\n- `PRICE_LEVEL_MODERATE`\n- `PRICE_LEVEL_EXPENSIVE`\n- `PRICE_LEVEL_VERY_EXPENSIVE\"`\n\nIn this example, you create a loop to call the `PLACES_COUNT` function for each\nprice level, and insert the results of each call to a temporary table. You then\nquery the temporary table to display the results: \n\n```googlesql\n-- Create a temp table to hold the results.\nCREATE TEMP TABLE results (type STRING, count INT64);\n\n-- Create a loop that calls PLACES_COUNT for each price level.\nFOR types IN (SELECT type FROM UNNEST([\"PRICE_LEVEL_INEXPENSIVE\", \"PRICE_LEVEL_MODERATE\", \"PRICE_LEVEL_EXPENSIVE\", \"PRICE_LEVEL_VERY_EXPENSIVE\"]) as type)\nDO\n INSERT INTO results VALUES (types.type, `maps-platform-analytics-hub.sample_places_insights_us.PLACES_COUNT`(\n JSON_OBJECT(\n 'types', [\"restaurant\"],\n 'geography', ST_GEOGPOINT(-73.9857, 40.7484), -- Empire State Building\n 'geography_radius', 1000, -- Radius in meters\n 'business_status', ['OPERATIONAL'],\n 'price_level', [types.type]\n )));\nEND FOR;\n\n-- Query the table of results.\nSELECT * FROM results;\n```\n\nThe combined response:\n\nAnother option is to use the `UNION ALL` command to combine the results of\nmultiple `SELECT` statements. The following example shows the same results as\nfrom the previous example: \n\n```googlesql\nSELECT \"PRICE_LEVEL_INEXPENSIVE\" as price_level, `maps-platform-analytics-hub.sample_places_insights_us.PLACES_COUNT`(\n JSON_OBJECT(\n 'types', [\"restaurant\"],\n 'geography', ST_GEOGPOINT(-73.9857, 40.7484), -- Empire State Building\n 'geography_radius', 1000, -- Radius in meters\n 'business_status', ['OPERATIONAL'],\n 'price_level', ['PRICE_LEVEL_INEXPENSIVE']\n )\n) as count\n\nUNION ALL\n\nSELECT \"PRICE_LEVEL_MODERATE\" as price_level, `maps-platform-analytics-hub.sample_places_insights_us.PLACES_COUNT`(\n JSON_OBJECT(\n 'types', [\"restaurant\"],\n 'geography', ST_GEOGPOINT(-73.9857, 40.7484), -- Empire State Building\n 'geography_radius', 1000, -- Radius in meters\n 'business_status', ['OPERATIONAL'],\n 'price_level', ['PRICE_LEVEL_MODERATE']\n )\n) as count\n\nUNION ALL\n\nSELECT \"PRICE_LEVEL_EXPENSIVE\" as price_level, `maps-platform-analytics-hub.sample_places_insights_us.PLACES_COUNT`(\n JSON_OBJECT(\n 'types', [\"restaurant\"],\n 'geography', ST_GEOGPOINT(-73.9857, 40.7484), -- Empire State Building\n 'geography_radius', 1000, -- Radius in meters\n 'business_status', ['OPERATIONAL'],\n 'price_level', ['PRICE_LEVEL_EXPENSIVE']\n )\n) as count\n\nUNION ALL\n\nSELECT \"PRICE_LEVEL_VERY_EXPENSIVE\" as price_level, `maps-platform-analytics-hub.sample_places_insights_us.PLACES_COUNT`(\n JSON_OBJECT(\n 'types', [\"restaurant\"],\n 'geography', ST_GEOGPOINT(-73.9857, 40.7484), -- Empire State Building\n 'geography_radius', 1000, -- Radius in meters\n 'business_status', ['OPERATIONAL'],\n 'price_level', ['PRICE_LEVEL_VERY_EXPENSIVE']\n )\n) as count\n```"]]