In this post, I address an common problem in geoscience research: how to arrange the original geodata into pre-defined grid system. Sometimes, we need to unify the resolution of various dataset or summary the scatter data to raster one.
Specifically, this brief tutorial will look at two different original data, and allow you to creat gridded data in python. For better illustration, two practial cases with detailed code are shown:
- Creating an emission inventory based on the emissions from point sources (e.g., power plants, cement plants)
- Remapping a population density map to a coarser resolution
1. Scatter data point
1 | import numpy as np |
2. Raster data
Noted in my last post, the resampling of tif-format dataset to raster file in other resolution relied on the skimage.transform function. Here, I present the method which directly deal with np.array.
2.1 equal coarse ratio on both axis
1 | ## creat a original data representing populaiton map |
1 | ## Method 1 reshape the original data array |
2.2 inequal coarse ratio on both axis
Method.1 interpolation
1 | from scipy import interpolate |
Method.2 Fourier transform method
Thanks to help from my new roomate who is expert in math, I learned to transfrom the 2-d array using Fourier transform method
1 | from scipy import fftpack |
Kommentare