Skip to Content
Python 用于地理空间数据分析
book

Python 用于地理空间数据分析

by Bonny P. McClain
May 2025
Intermediate to advanced
282 pages
4h 2m
Chinese
O'Reilly Media, Inc.
Content preview from Python 用于地理空间数据分析

第 10 章 使用 Python 测量气候数据 使用 Python 测量气候数据

本作品已使用人工智能进行翻译。欢迎您提供反馈和意见:translation-feedback@oreilly.com

开发学习 Python 和地理空间分析的技术技能和途径固然重要,但如果不提供背景资料或创造分享的叙事方式,一切都只是架子上的数据而已。

在最后一章中,您将通过访问大地遥感卫星、中巴地球资源卫星(CBERS)哨兵卫星的卫星图像层,探索探索时间序列数据的三种方法。您将利用自己的地理空间分析技能来研究有关气候变化和森林砍伐的问题。

空间建模是预测、预报和监测全球气温升高和森林砍伐实时状况的重要工具,它反过来帮助我们预测这些现象的后果,并有可能进行干预或做好准备。

通过三个示例重点介绍了一些功能强大的 Python 软件包:Xarray、Web 时间序列服务 (WTSS) 和濒危森林 (FAR)。虽然这些看起来是新工具,但在前面的章节中,我们已经介绍了它们的许多依赖关系。最后一个示例是对用于预测建模的软件包的统计功能的深入探讨,您将在分析森林砍伐时使用这些软件包。您可以在随附的笔记本中运行代码,因为对其中所有内容的完整解释超出了本书的范围。

示例 1:利用降水数据研究气候预测

空间分析通常依赖于多维数据分析。可以把网格数据集想象成一个立方体。 在 Python 中(以及在一般的计算机编程中),数组存储数据列表。列表中的对象可以单独引用,也可以集体引用。这在调用 Python 数组时非常重要,因为您可以通过索引号访问每个项。

多维和 N 维数组或张量在 NumPy ndarrays 中显示。将张量视为数据或信息的容器。在 Python 中,NumPy提供了处理原始 ndarrays 的基本数据结构和 API。

您将使用真实世界的数据集,这些数据集编码了有关数组的值如何映射到位置的信息。您所使用的数据都标有编码信息,如时间戳、坐标、海拔高度、土地覆盖和降水量。

目标

美国政府国家海洋和大气管理局(NOAA)的任务是 "预测气候、天气、海洋和海岸的变化",并通报和解决极端天气事件对社会和环境造成的紧急影响。在本练习中,您将使用公开可用的数据集分析每日降水量。对比美国大陆 2015 年和 2021 年的数据,您将观察数据中的模式,以确定是否存在明显的可观测差异。

首先,我将向您介绍 Xarray,它是一个开源项目,可与 NumPy、SciPy 和 matplotlib 互操作,并扩展到 NumPy ndarrays 和 pandas dataframes 之外。

与前几章一样,在完成对软件包及其支持文档的介绍后,我强烈建议您尝试使用不同的数据集以及 Python 软件包和库的应用。

下载数据

首先,导航至网格气候数据集:降水并选择气候预测中心(CPC)全球降水数据集。与所请求的纬度/经度对齐的网格单元将返回给定纬度/经度的天气数据。

下载感兴趣的年份(2015 年和 2021 年),并将文件上传到 Google 驱动器或直接上传到电脑。图 10-1显示了文件夹和文件的层次结构。

Files in Google Colab
图 10-1. Google Colab 中的文件

在 Xarray 中工作

Xarray 是一个 Python 库,其中包含许多您现在应该已经熟悉的依赖项,如 NumPy 和 pandas,以及一些您在使用 ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

实用 Linux 系统管理

实用 Linux 系统管理

Kenneth Hess
ppk on JavaScript

ppk on JavaScript

Peter-Paul Koch
ASP.NET 2.0 Illustrated

ASP.NET 2.0 Illustrated

Alex Homer, Dave Sussman

Publisher Resources

ISBN: 9798341659025