#Python

Sometimes, we need to clip or extract the raster image with polygon features, e.g., only focus on the percipitation within China using global dataset. This post will introduce two methods to mask the 2-d array-like dataset by a specific geometry using Python.

  • The first method use GeoPandas module to test those raster coordidnates within/out of the shapefile
  • The second method which I strongly recommended with faster speed was based on shapely module.

mehr

I’m writing today about downloading, handling, and plotting satellite derived air pollution maps with cartopy and fiona using Python. One key task in this post is to clip a raster-like (2-d array) dataset with a polygon in pure Python environment (i.e., no need for ArcGIS or QGIS GUI-based software).

The satellite sensor can offer critical supplementary data of several atmospheric species, e.g., SO2, NO2, PM2.5. Comparaing to ground-based monitoring which might be sparse in some areas (e.g., Africa, South America, oceans), the satellite observation offers a full picture for better understanding the spatiotemporal patterns of some air pollutants.

Below is an excerpt of a NO2 column maps within Chengyu urabn agglomeration in China.

mehr

Hillshade is the representation of the earth’s surface under the radiation of sun. A terrain raster data can be better visualized by adding the information of hillshades. This blog will introduce some procrdures to overlay the hillshade with terrain for a nice picture.

mehr

In this post, I present some simple programs written in Python for post-processing the flexpart-wrf output.

It mainly contains several aspects, data merging, data processing and data visualization. I will also show some tips tp creat self-defined colormaps for nice plots.

PS: All th codes are also uploaded in my GitHub respority PyFlex

mehr

以前处理WRF等气象模型的输出文件,总是下载到本地电脑做后处理分析。由于计算量不断增加,模拟生成的文件往往会很大。因而,我考虑直接在服务器中处理数据。本来是很容易的事情,却因为课题组服务器的系统版本较旧,在安装有关工具时耗去了不少时间。在此记录我的探索过程。

气象模拟文件的后处理PartA: 曲折的安装

mehr

Welcome to my collection of Python scripts and code snippets for everyday use. This document contains a variety of scripts and code snippets that can be used to automate repetitive tasks, process data, and perform various other operations. Whether you are a beginner or an experienced Python programmer, this collection of scripts and code snippets will provide you with useful tools and shortcuts for your everyday work.

In this document, you will find code snippets and scripts for tasks such as:

  • Data processing
  • File manipulation
  • Web scraping
  • Automating tasks
  • And more!

This document is organized into sections for easy navigation, so you can quickly find the script or code snippet that you need. Many of them were collected from stackoverflow.

On 2022.03.31, I re-organize all the scripts into Python 3.x version and post again.
On 2023.02.12, I edited the whole content with help from ChatGPT

mehr

全国空气质量历史数据是大气环境研究的重要基础资料,而我国官方平台仅提供实时监测信息,而且还只支持IE浏览器(╮(╯_╰)╭)。

我曾尝试采用爬虫工具获取并存储逐时信息,但限于权限,未能在实验室服务器上连续长时间运行。互联网上直接提供数据或API端口的网站有很多,如环境云PM25.in, 青悦开放环境数据中心等。其中,beijingair最具分享精神,提供了2013年至今的详尽历史数据,且完全免费。

由衷感谢@王_晓磊的出色工作和无私分享,极大地推动了我国环境数据的公开与透明。其数据格式为每日一份csv文件存储当日所有站点/城市的逐时信息。在长时间尺度的数据分析时,需逐一阅读各原始文件。此处,我考虑将全年数据文件整合为多维度数据存储格式(HDF5)文件,便于调用和处理。

mehr

网络中有丰富的地理信息数据资源,此处介绍我采用Python工具实现地形地貌、行政区划、城市交通路网等数据获取及可视化的部分实例,供大家参考学习。

mehr

提要:此文介绍利用Python语言处理NASA MODIS火点数据(Global Monthly Fire Location Product,MCD14ML),可实现的基本功能包括:(1)特定时期的火点信息提取;(2)特定区域内的火点信息提取;(3)火点密度空间分布的计算与可视化表达

mehr

Jupyter(即原来的Ipython Notebook Project)基于Web端的实时交互,拥有着极佳的用户体验。同时,Jupyter体系可直接使用其他语言,用户呢能够在同一界面下调用R内核或Python内核(共支持49种),功能十分强大。
在Mac OS下尝试在Jupyter中添加R语言内核,遇到了一些问题,在此记录个人安装过程和诸问题的解决方法。

STEP1 基本软件准备

  • Python和IPython.作为初学者,我直接安装了Python的科学计算发行版Anaconda,其包含了Python2.7并内置很多有用的Package(numpy, SciPy, Matplotlib),Jupyter(Ipython Notebook)以及Spyder(个人感觉类似于R studio的集成开发环境)
  • R 3.2.1(World-Famous Astronaut),官网下载安装即可。

STEP2 有关库的安装

主要工作是为R语言添加IRkernal这一新的Package, 以实现Jupyter对R语言的支持。主要的步骤如下(依照IRkernal的README文档):

mehr

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×