中国气候分布矢量图

    科技2023-12-22  124

    中国气候分布矢量图

    Even if we do not need a lot of experience to do that kind of map let’s split the work and take some minutes to speak about the dataset.

    即使我们不需要大量的经验来制作这种地图,我们也要分拆工作并花一些时间来谈论数据集。

    0°)数据集 (0°) Dataset)

    To build a climatic map we need climate data! This is possible through Copernicus Climate Change Service (link to the website here & some wiki explication here).

    要建立气候图,我们需要气候数据! 这通过哥白尼气候变化服务(网站链接,可以在这里与一些维基解释这里 )。

    Quickly Copernicus Climate Change Service is a European project fund by the European Commission. But why Copernicus you might ask? Because this part of the Copernicus Program which is an Earth Observation Program dedicated to giving a scientific picture of the health of our blue dot. But still why Copernicus you might ask? Nicolaus Copernicus is at the origin of modern astronomy. Copernicus program is at the origin of full, free, and open access to space data.

    哥白尼快速气候变化服务是欧盟委员会的一项欧洲项目基金。 但是您为什么会问哥白尼呢? 因为哥白尼计划的这部分是地球观测计划,致力于对我们蓝点的健康状况进行科学描绘。 但是,为什么您可能会问哥白尼呢? 哥白尼(Nicolaus Copernicus)是现代天文学的起源。 哥白尼计划起源于对空间数据的完全,免费和开放的访问。

    So now let’s dive into the data. Thanks to Copernicus Climate Change Service you can easily download data. Here as we are focusing on climate data we are going to download the 2m temperature as well as rainfall. This data is built on satellite measures, in-situ data, and models. (link)

    现在,让我们深入研究数据。 借助哥白尼气候变化服务,您可以轻松下载数据。 在这里,由于我们关注气候数据,我们将下载2m温度和降雨量。 此数据基于卫星测量,原位数据和模型。 ( 链接 )

    Let’s download (netCDF format) the monthly reanalysis of the precipitation and the temperature from 1981 until 2019 above France. We should have 456 values for precipitation as well as temperature.

    让我们下载(netCDF格式)每月从1981年到2019年法国上方的降水和温度的重新分析。 我们应该有456个降水和温度值。

    I°)入门包 (I°) Starter pack)

    So what do we need to work on this data?

    那么我们需要处理这些数据吗?

    One conda virtual environment design for geodata science with the following libraries :

    一种具有以下库的地理数据科学conda虚拟环境设计:

    NumPy (basic array management library) [link],

    NumPy (基本数组管理库)[ 链接 ],

    matplotlib (basic visualization management library) [link],

    matplotlib (基本可视化管理库)[ 链接 ],

    pandas (used to manage data) [link],

    熊猫 (用于管理数据) [ 链接 ],

    geopandas (used to manage geospatial data) [link],

    geopandas (用于管理地理空间数据)[ link ],

    xarray (used to manage netCDF data (here our climate data)) [link]

    xarray (用于管理netCDF数据(此处为气候数据))[ 链接 ]

    rasterio (mostly used to work on satellite imagery) [link]

    rasterio (主要用于处理卫星图像)[ link ]

    rioxarray (rasterio xarray extension to combine both easily) [link]

    rioxarray (rasterio xarray扩展可以轻松地将两者结合) [link]

    Fiona (used to manage vector and here just for better visualization) [link]

    Fiona (用于管理矢量,此处仅用于更好的可视化)[ link ]

    sklearn (used for machine learning) [link]

    sklearn (用于机器学习)[ 链接 ]

    Installation of this environment might be the longest task of this small article.

    安装此环境可能是这篇小文章中最长的任务。

    II°)预处理 (II°) Preprocessing)

    Now that we have all the needed packages the first step is to open the data on our Jupyter notebook by using xarray.open_dataset and set a projection by using rio.set_crs() [this is where rioxarray extension is needed]. Here we have two data variable as expected t2m: Temperature at 2meter & tp: Total Precipitation

    现在我们有了所有需要的软件包,第一步是使用xarray.open_dataset打开Jupyter笔记本上的数据,并使用rio.set_crs()设置投影[这是需要rioxarray扩展的地方] 。 这里我们有两个数据变量,如预期的t2m:2米处的温度和tp:总降水量

    As I prefer to work on a tiff file than netCDF I’m going to save our dataset on two images by using again the rioxarray extension. One image with all the temperature data above France since 1981 and another with the total precipitation. Then I’m going to move on rasterio and work like it was an image!

    由于我更喜欢​​使用tiff文件而不是netCDF,因此我将再次使用rioxarray扩展名将数据集保存在两个图像上。 一张图像包含自1981年以来法国以上的所有温度数据,另一幅包含总降水量。 然后,我将继续进行光栅处理并像图像一样工作!

    As tp and t2m are now simple images we can apply a mask to have only the data above France. Let’s plot our mask :

    由于tp和t2m现在是简单的图像,因此我们可以应用蒙版仅包含法国上方的数据。 让我们绘制面具:

    France mask 法国面具

    Now let’s use it to mask our image.

    现在,使用它来掩盖我们的图像。

    We have now an image with a shape of (468, 98, 148) [468: the number of total precipitation values, [98, 148] the position]. That sounds perfect but we need one last step to be able to do some clustering on it!

    现在,我们得到了一个图像,其形状为(468,98,148)[468:总降水值的数量,[98,148]位置]。 听起来很完美,但是我们需要最后一步才能对其进行聚类!

    Indeed sklearn clustering is allowing only 2D vector with a specific format [x1: y1, x2:y2, …., xn, yn]. Here xi is the position and yi the feature vector. So let’s give the relevant format to our data.

    实际上,sklearn聚类仅允许使用特定格式[x 1 :y 1 ,x 2 :y 2 ,....,x n ,y n ]的2D向量。 这里x i是位置,y i是特征向量。 因此,让我们为数据提供相关格式。

    So why our image has a shape of (14504, 936)? Because as explained x1 should be the position. But in our case, we were working with a [98, 148] matrix. So we just need to work with a 98 x 148 list. And 98 x 148 = 14504. And why 936 features for each pixel? Because precipitation has 468 values and 2meters temperature has also 468. So that leads to 936 features. To summarize we have now for each position 936 features.

    那么,为什么我们的图像的形状为(14504,936)? 因为如前所述,x 1应该是位置。 但是在我们的例子中,我们正在使用[98,148]矩阵。 因此,我们只需要处理98 x 148的列表。 98 x 148 =14504。为什么每个像素需要936个特征? 因为降水有468个值,而2米的温度也有468个。因此得出936个特征。 总而言之,我们现在为每个位置提供936个功能。

    III°)加工| 聚类 (III°) Processing | Clustering)

    The most difficult part is already done! Indeed now that we have our data to the sklearn format it’s very simple!

    最困难的部分已经完成! 的确,现在我们将数据转换为sklearn格式,这非常简单!

    You have to import KMeans from sklearn.cluster. Then you can decide how many climate types you want on your map (labels). After that, you will oblige your data to fit on one of those labels based on the features (so the climate data)

    您必须从sklearn.cluster导入KMeans。 然后,您可以决定要在地图上(标签)上多少种气候类型。 在那之后,您将根据特征使数据适合这些标签之一(因此,气候数据)

    After you will need to retrieve the label for each pixel. Then just for visualization purposes, we are going to reshape the data like a basic image.

    之后,您将需要检索每个像素的标签。 然后仅出于可视化目的,我们将像基本图像一样重塑数据。

    IV°)可视化 (IV°) Visualization)

    Let’s check the result !!

    让我们检查结果!

    Based on this map it could be possible to guess the name corresponding to the label. For example, the brown part is representing for sure high mountain climate. Now the challenge is to verify our result. But hopefully, researchers have already done a climatic map in France based on different analyses (link to the research paper here). So let’s compare!

    根据此映射,可以猜测与标签相对应的名称。 例如,棕色部分肯定代表高山气候。 现在的挑战是验证我们的结果。 但希望研究人员已经基于不同的分析在法国绘制了气候图(链接到此处的研究论文)。 因此,让我们进行比较!

    We are not so far from the expected result. That looks very promising for other analyses. Moreover in France, we had already a climatic map but that not the case for every country 😉 !

    我们离预期的结果不远。 对于其他分析来说,这看起来很有希望。 此外,在法国,我们已经有了气候图,但并非每个国家都有这种情况😉!

    谢谢阅读! (Thanks for reading!)

    Photo by USGS on Unsplash USGS在 Unsplash上 拍摄的照片

    BONUS

    奖金

    If you love to read the information on Copernicus Climate Change Service this link might be perfect for you!

    如果您喜欢阅读哥白尼气候变化服务的相关信息,那么此链接可能对您而言是完美的!

    https://confluence.ecmwf.int/display/CKB/ERA5

    https://confluence.ecmwf.int/display/CKB/ERA5

    Contact

    联系

    basile.earthobservation@gmail.com

    basile.earthobservation@gmail.com

    https://github.com/BasileGoussard

    https://github.com/BasileGoussard

    https://www.linkedin.com/in/basile-goussard/

    https://www.linkedin.com/in/basile-goussard/

    参考书目 (Bibliography)

    Copernicus Climate Change Service (C3S) (2017): ERA5: Fifth generation of ECMWF atmospheric reanalyses of the global climate. Copernicus Climate Change Service Climate Data Store (CDS), 2020. https://cds.climate.copernicus.eu/cdsapp#!/home

    哥白尼气候变化服务中心(C3S)(2017):ERA5:ECMWF第五代全球气候大气再分析。 哥白尼气候变化服务局气候数据存储(CDS),2020年。https: //cds.climate.copernicus.eu/cdsapp#!/ home

    Daniel Joly, Thierry Brossard, Hervé Cardot, Jean Cavailhes, Mohamed Hilal et Pierre Wavresky, « Les types de climats en France, une construction spatiale », Cybergeo : European Journal of Geography [En ligne], Cartographie, Imagerie, SIG, document 501, mis en ligne le 18 juin 2010, consulté le 03 septembre 2020. URL : http://journals.openedition.org/cybergeo/23155 ; DOI : https://doi.org/10.4000/cybergeo.23155

    Daniel Joly,Thierry Brossard,HervéCardot,Jean Cavailhes,Mohamed Hilal和Pierre Wavresky,《法国气候类型》,《建筑空间》,《 网络地理 》 :欧洲地理杂志 [En ligne],制图学,Imagerie,SIG,文献501 ,网址: http : //journals.openedition.org/cybergeo/23155 ; 2010年6月18日,发行日期为2020年9月3日。 DOI: https : //doi.org/10.4000/cybergeo.23155

    翻译自: https://medium.com/swlh/how-to-build-a-climatic-map-in-30-lines-of-code-fcba6ce090d5

    中国气候分布矢量图

    相关资源:中科院武汉植物园植被分布矢量图
    Processed: 0.010, SQL: 8