รหัสตัวอย่าง
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
เข้าถึง API ตารางการคาดการณ์ด้วย Python
import io
import requests
import xarray as xr
API_KEY = "AIza...(replace with your API key)"
params = {"time": "2025-05-15T20:00:00Z"}
response = requests.get(
url="https://contrails.googleapis.com/v2/grids",
params=params,
headers={"x-goog-api-key": API_KEY},
)
response.raise_for_status()
dataset = xr.load_dataset(io.BytesIO(response.content))
หากต้องการแสดงข้อมูลเป็นภาพ ให้ใช้โน้ตบุ๊ก Public_Contrails_API_Tester
วิธีเข้าถึง API ของภูมิภาคการพยากรณ์ด้วย Python
import requests
import geopandas as gpd
API_KEY = "AIza...(replace with your API key)"
params = {"time": "2025-05-15T20:00:00Z"}
response = requests.get(
url="https://contrails.googleapis.com/v2/regions",
params=params,
headers={"x-goog-api-key": API_KEY},
)
response.raise_for_status()
geodataframe = gpd.GeoDataFrame.from_features(response.json())
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-06-02 UTC
[[["เข้าใจง่าย","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"]],["อัปเดตล่าสุด 2025-06-02 UTC"],[[["Access the Contrails API using Python with libraries like `requests` and `xarray` to retrieve contrail environmental impact data."],["Define parameters such as bounding box, aircraft type, and time to specify your API query."],["Utilize the provided Google API key and endpoint URL for authentication and data retrieval."],["Refer to the linked Google Colab notebook for a comprehensive example on querying the API and visualizing the data."]]],[]]