中国气候分布矢量图

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

中国气候分布矢量图_如何用30行代码构建气候图相关推荐

  1. 铅笔素描算法_如何用10行代码将任何图像变成铅笔素描

    铅笔素描算法 by Rishav Agarwal 通过里沙夫·阿加瓦尔 如何用10行代码将任何图像变成铅笔素描 (How to turn any image into a pencil sketch ...

  2. 2019机器学习代码实现_如何用3行代码实现任何机器学习项目

    2019机器学习代码实现 Wouldn't it be great to be able to solve complex machine learning problems quickly and ...

  3. vant组件实现上传图片裁剪_如何用 120 行代码,实现交互完整的拖拽上传组件?...

    作者 | 前端劝退师 责编 | 伍杏玲 你将在该篇学到: 如何将现有组件改写为 React Hooks函数组件 useState.useEffect.useRef是如何替代原生命周期和Ref的. 一个 ...

  4. 如何用50行代码构建情感分类器

    选自Toward Data Science,作者:Rohith Gandhi,机器之心编译. 本文介绍了如何构建情感分类器,从介绍自然语言处理开始,一步一步讲述构建过程. 自然语言处理简介 语言把人类 ...

  5. thymealf如何实现传单个变量给html_梦回2013,看尤大vue的第一行代码,如何用30行代码实现vue(超简洁,适合初学者)...

    非非非标题党,干货预警!!! 介绍 大家好,我是清池交友 app 开发日记,记录清池交友 app 开发中学习过程和踩坑日记,伪全栈[1] 技术栈:前端 js,vue,uniapp,后端 java 尤大 ...

  6. 如何用 30 行代码实现微信自动回复机器人?

    作者 | Ahab 责编 | 胡巍巍 写在前面 很多朋友对itchat非常感兴趣,近日又学到了itchat另一种有趣的玩法--微信自动回复机器人. 程序很简单仅仅三十行代码左右,实现了机器人自动与你的 ...

  7. 实时观看:如何用30行代码炸毁27吨重的发电机

     聚焦源代码安全,网罗国内外最新资讯! 编译:奇安信代码卫士团队 上周早些时候,美国司法部公开了一份针对黑客组织 Sandworm 的起诉书.为俄罗斯军事情报机构格鲁乌 (GRU) 效劳的六名黑客被控 ...

  8. ds--8600使用手册_我如何用57行代码复制一个价值8600万美元的项目

    ds--8600使用手册 by Tait Brown 泰特·布朗(Tait Brown) 我如何用57行代码复制一个价值8600万美元的项目 (How I replicated an $86 mill ...

  9. 想了解直播系统开发美颜的原理,先来学习如何用1行代码实现人脸识别

    想了解直播系统开发美颜的原理,先来学习如何用1行代码实现人脸识别 环境搭建: 1. 安装 Ubuntu17.10 > 安装步骤在这里 2. 安装 Python2.7.14 (Ubuntu17.1 ...

  10. python制作表白神器_程序员的七夕用30行代码让Python化身表白神器

    转眼又到了咱们中国传统的情人节七夕了,今天笔者就带大家来领略一下用Python表白的方式.让程序员的恋人们感受一下IT人的浪漫. 一.词云制作 首先咱们可以用之前介绍过的wordcould包制作词云. ...

最新文章

  1. R语言ggplot2可视化时间序列散点图、X轴和Y轴都是时间信息、使用as.POSIXct函数自定义指定Y轴的时间范围(setting time limits in y axis)
  2. 编译cscope-15.8a遇到的问题与解决方案
  3. java web mvc思想介绍
  4. Windows 技术篇-搜狗输入法中文状态下却输入为英文,原因及解决办法。明明是中文却输入不了中文,只能输入英文
  5. python创建数组并运行,python中Numpy的数组创建
  6. 动态生成HTML页面
  7. Hystrix仪表盘解释
  8. 树莓派使用STEP7:安装wiringPi硬件外设驱动C库
  9. es6判断对象key是否存在,ES6中获取对象的key
  10. SharedPreferences详解
  11. 故宫学生网页设计作品 dreamweaver作业静态HTML网页设计模板 旅游景点网页作业制作
  12. iOS 瀑布流布局实现详解
  13. android ios 混合编程,React Native与原生(Android、iOS)混编,三端痛点解析
  14. 特斯拉电动卡车霸气发布,还有一个意外惊喜(全新跑车)
  15. VoIP五个不为人知的秘密
  16. xcode4 引入poco库
  17. ActiveX控件dsoFramer的使用(word、excel、PPT)
  18. 单片机毕业设计不用愁!!30篇单片机毕业设计参考案例
  19. word 2016编辑区鼠标光标消失/变白解决方案
  20. 微信小程序实现当前页面多个视频文件只能播放一个视频,其他视频暂停,点击当前暂停当前

热门文章

  1. 元宇宙大杀器来了!小扎祭出4款VR头显,挑战视觉图灵测试
  2. fig r函数_R语言图形函数par()参数应用举例.pdf
  3. 直流无刷电机的一些介绍
  4. Linux之进程管理一
  5. c语言里的pow函数(好理解,易懂)
  6. 免费好用的文字转语音工具
  7. 什么是事件流? 什么是事件冒泡? 什么是事件捕获?
  8. 中职学校计算机课程标准,中等职业学校信息技术课程标准2020.pdf
  9. 减少域名DNS解析时间将网页加载速度提升新层次
  10. 声音和视频在计算机的格式,格式工厂完成音频和视频合并