ee.FeatureCollection.runBigQuery
با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
یک پرس و جو BigQuery را اجرا می کند، نتایج را واکشی می کند و آنها را به عنوان FeatureCollection ارائه می کند.
استفاده | برمی گرداند | ee.FeatureCollection.runBigQuery(query, geometryColumn , maxBytesBilled ) | مجموعه ویژگی ها |
استدلال | تایپ کنید | جزئیات | query | رشته | جستجوی GoogleSQL برای انجام در منابع BigQuery. |
geometryColumn | رشته، پیش فرض: null | نام ستونی که به عنوان هندسه ویژگی اصلی استفاده می شود. اگر مشخص نشده باشد، از اولین ستون هندسه استفاده خواهد شد. |
maxBytesBilled | طولانی، پیش فرض: 100000000000 | حداکثر تعداد بایت های صورتحساب هنگام پردازش پرس و جو. هر کار BigQuery که بیش از این حد باشد با شکست مواجه می شود و صورتحساب دریافت نمی شود. |
نمونه ها
ویرایشگر کد (جاوا اسکریپت)
// 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'));
راه اندازی پایتون
برای اطلاعات در مورد API پایتون و استفاده از geemap
برای توسعه تعاملی به صفحه محیط پایتون مراجعه کنید.
import ee
import geemap.core as geemap
کولب (پایتون)
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)
جز در مواردی که غیر از این ذکر شده باشد،محتوای این صفحه تحت مجوز Creative Commons Attribution 4.0 License است. نمونه کدها نیز دارای مجوز Apache 2.0 License است. برای اطلاع از جزئیات، به خطمشیهای سایت Google Developers مراجعه کنید. جاوا علامت تجاری ثبتشده Oracle و/یا شرکتهای وابسته به آن است.
تاریخ آخرین بهروزرسانی 2025-07-24 بهوقت ساعت هماهنگ جهانی.
[null,null,["تاریخ آخرین بهروزرسانی 2025-07-24 بهوقت ساعت هماهنگ جهانی."],[],[],null,["# ee.FeatureCollection.runBigQuery\n\nRuns a BigQuery query, fetches the results and presents the them as a FeatureCollection.\n\n\u003cbr /\u003e\n\n| Usage | Returns |\n|------------------------------------------------------------------------------------|-------------------|\n| `ee.FeatureCollection.runBigQuery(query, `*geometryColumn* `, `*maxBytesBilled*`)` | FeatureCollection |\n\n| Argument | Type | Details |\n|------------------|-----------------------------|------------------------------------------------------------------------------------------------------------------------------------|\n| `query` | String | GoogleSQL query to perform on the BigQuery resources. |\n| `geometryColumn` | String, default: null | The name of the column to use as the main feature geometry. If not specified, the first geometry column will be used. |\n| `maxBytesBilled` | Long, default: 100000000000 | Maximum number of bytes billed while processing the query. Any BigQuery job that exceeds this limit will fail and won't be billed. |\n\nExamples\n--------\n\n### Code Editor (JavaScript)\n\n```javascript\n// Get places from Overture Maps Dataset in BigQuery public data.\nMap.setCenter(-3.69, 40.41, 12)\nvar mapGeometry= ee.Geometry(Map.getBounds(true)).toGeoJSONString();\nvar sql =\n \"SELECT geometry, names.primary as name, categories.primary as category \"\n + \" FROM bigquery-public-data.overture_maps.place \"\n + \" WHERE ST_INTERSECTS(geometry, ST_GEOGFROMGEOJSON('\" + mapGeometry+ \"'))\";\n\nvar features = ee.FeatureCollection.runBigQuery({\n query: sql,\n geometryColumn: 'geometry'\n});\n\n// Display all relevant features on the map.\nMap.addLayer(features,\n {'color': 'black'},\n 'Places from Overture Maps Dataset');\n\n\n// Create a histogram of the categories and print it.\nvar propertyOfInterest = 'category';\nvar histogram = features.filter(ee.Filter.notNull([propertyOfInterest]))\n .aggregate_histogram(propertyOfInterest);\nprint(histogram);\n\n// Create a frequency chart for the histogram.\nvar categories = histogram.keys().map(function(k) {\n return ee.Feature(null, {\n key: k,\n value: histogram.get(k)\n });\n});\nvar sortedCategories = ee.FeatureCollection(categories).sort('value', false);\nprint(ui.Chart.feature.byFeature(sortedCategories).setChartType('Table'));\n```\nPython setup\n\nSee the [Python Environment](/earth-engine/guides/python_install) page for information on the Python API and using\n`geemap` for interactive development. \n\n```python\nimport ee\nimport geemap.core as geemap\n```\n\n### Colab (Python)\n\n```python\nimport json\nimport pandas as pd\n\n# Get places from Overture Maps Dataset in BigQuery public data.\nlocation = ee.Geometry.Point(-3.69, 40.41)\nmap_geometry = json.dumps(location.buffer(5e3).getInfo())\n\nsql = f\"\"\"SELECT geometry, names.primary as name, categories.primary as category\nFROM bigquery-public-data.overture_maps.place\nWHERE ST_INTERSECTS(geometry, ST_GEOGFROMGEOJSON('{map_geometry}'))\"\"\"\n\nfeatures = ee.FeatureCollection.runBigQuery(\n query=sql, geometryColumn=\"geometry\"\n)\n\n# Display all relevant features on the map.\nm = geemap.Map()\nm.center_object(location, 13)\nm.add_layer(features, {'color': 'black'}, 'Places from Overture Maps Dataset')\ndisplay(m)\n\n# Create a histogram of the place categories.\nproperty_of_interest = 'category'\nhistogram = (\n features.filter(\n ee.Filter.notNull([property_of_interest])\n ).aggregate_histogram(property_of_interest)\n).getInfo()\n\n# Display the histogram as a pandas DataFrame.\ndf = pd.DataFrame(list(histogram.items()), columns=['category', 'frequency'])\ndf = df.sort_values(by=['frequency'], ascending=False, ignore_index=True)\ndisplay(df)\n```"]]