公告:所有在
2025 年 4 月 15 日之前注册使用 Earth Engine 的非商业项目都必须
验证是否符合非商业性质的资格条件,才能继续使用 Earth Engine。如果您在 2025 年 9 月 26 日之前未完成验证,您的访问权限可能会被暂停。
ee.FeatureCollection.runBigQuery 使用集合让一切井井有条 根据您的偏好保存内容并对其进行分类。
运行 BigQuery 查询,提取结果并将其显示为 FeatureCollection。
| 用法 | 返回 |
|---|
ee.FeatureCollection.runBigQuery(query, geometryColumn, maxBytesBilled) | FeatureCollection |
| 参数 | 类型 | 详细信息 |
|---|
query | 字符串 | 要在 BigQuery 资源上执行的 GoogleSQL 查询。 |
geometryColumn | 字符串,默认值:null | 要用作主要地图项几何图形的列的名称。如果未指定,系统会使用第一个几何图形列。 |
maxBytesBilled | 长整数,默认值:100000000000 | 处理查询时计费的字节数上限。任何超出此限制的 BigQuery 作业都将失败,并且不会产生费用。 |
示例
Code Editor (JavaScript)
// Get places from Overture Maps Dataset in BigQuery public data. Map.setCenter(-3.69, 40.41, 12) var mapGeometry= ee.Geometry(Map.getBounds(true)).toGeoJSONString(); var sql = "SELECT geometry, names.primary as name, categories.primary as category " + " FROM bigquery-public-data.overture_maps.place " + " WHERE ST_INTERSECTS(geometry, ST_GEOGFROMGEOJSON('" + mapGeometry+ "'))"; var features = ee.FeatureCollection.runBigQuery({ query: sql, geometryColumn: 'geometry' }); // Display all relevant features on the map. Map.addLayer(features, {'color': 'black'}, 'Places from Overture Maps Dataset'); // Create a histogram of the categories and print it. var propertyOfInterest = 'category'; var histogram = features.filter(ee.Filter.notNull([propertyOfInterest])) .aggregate_histogram(propertyOfInterest); print(histogram); // Create a frequency chart for the histogram. var categories = histogram.keys().map(function(k) { return ee.Feature(null, { key: k, value: histogram.get(k) }); }); var sortedCategories = ee.FeatureCollection(categories).sort('value', false); print(ui.Chart.feature.byFeature(sortedCategories).setChartType('Table')); Python 设置
如需了解 Python API 以及如何使用 geemap 进行交互式开发,请参阅 Python 环境页面。
import ee import geemap.core as geemap
Colab (Python)
import json import pandas as pd # Get places from Overture Maps Dataset in BigQuery public data. location = ee.Geometry.Point(-3.69, 40.41) map_geometry = json.dumps(location.buffer(5e3).getInfo()) sql = f"""SELECT geometry, names.primary as name, categories.primary as category FROM bigquery-public-data.overture_maps.place WHERE ST_INTERSECTS(geometry, ST_GEOGFROMGEOJSON('{map_geometry}'))""" features = ee.FeatureCollection.runBigQuery( query=sql, geometryColumn="geometry" ) # Display all relevant features on the map. m = geemap.Map() m.center_object(location, 13) m.add_layer(features, {'color': 'black'}, 'Places from Overture Maps Dataset') display(m) # Create a histogram of the place categories. property_of_interest = 'category' histogram = ( features.filter( ee.Filter.notNull([property_of_interest]) ).aggregate_histogram(property_of_interest) ).getInfo() # Display the histogram as a pandas DataFrame. df = pd.DataFrame(list(histogram.items()), columns=['category', 'frequency']) df = df.sort_values(by=['frequency'], ascending=False, ignore_index=True) display(df) 如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-25。
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["没有我需要的信息","missingTheInformationINeed","thumb-down"],["太复杂/步骤太多","tooComplicatedTooManySteps","thumb-down"],["内容需要更新","outOfDate","thumb-down"],["翻译问题","translationIssue","thumb-down"],["示例/代码问题","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-07-25。"],[],[]]