Gdal source code analysis (13) gdal grid Interpolation

Source: Internet
Author: User
I. Introduction

Http://www.gdal.org/grid_tutorial.html.

Grid interpolation refers to the process of creating a raster image from discrete data points. Normally, you have a series of discrete points in the study area. If you want to convert these points to the grid data of the rule for further processing, or merge with other grid data. It is one of grid interpolation:

Grid Interpolation

Data Interpolation and approximation algorithms can be used to solve this problem, but interpolation is not only used to solve this problem. Sometimes, you do not need to perform data interpolation. What you need to do is to calculate the statistical value and other indicators of the data coverage area. The statistical value itself is very useful, or you can choose a better interpolation algorithm and parameter based on these.

This is what the gdal mesh interpolation API understands. It can help you better perform data interpolation (see discrete data interpolation below) or calculate data metric information (participate in the following data indicator calculation ).

There are two ways to use this interface. One is to use the C language interface programming implementation of gdalgridcreate, and the other is to use the gdal_grid tool. The following sections describe the algorithm principle and Parameter Representation of gdal grid interpolation API.

2. Discrete Data Interpolation 1. Inverse Distance weight interpolation (inverse distance to a power)

The inverse distance weight interpolation method is a weighted average interpolation method. You should provide discrete data values, coordinate information of each point, and the output grid. Then, the function will calculate the data values of the output grid nodes by interpolation. The calculation method for each grid node is as follows:

The meanings of letters in the above formula are:

  • Zi is the value of known vertex I;
  • R is the distance from a grid node to point I;
  • P is the weight index;
  • N is the number of vertices in the search ellipse.

In this algorithm, the weight coefficient ω is calculated as follows:

Refer to the FunctionGdalgridcreateMedium structGdalgridinversedistancetoapoweroptionsParameter List andGdal_gridToolInvdistOption List.

2. Moving Average)

Moving Average is a simple data Average algorithm, specifically using an elliptical moving window, then searching all discrete points in the moving window, and then calculating the average value. You can specify the Rotation Angle for an elliptical search, and the center of the elliptic is located in a grid node. The average value of the minimum number of data points can be set. If there are not enough points in the moving window, the grid node is empty and then filled with the nodata value.

The mathematical formula of an algorithm can be expressed using the following formula:

The meanings of letters in the above formula are:

  • Z is the result of interpolation,
  • Zi is the value of known vertex I;
  • N is the number of vertices in the search ellipse.

Refer to the FunctionGdalgridcreateMedium structGdalgridmovingaverageoptionsParameter List andGdal_gridToolAverageOption List.

3. Nearest Neighbor)

The nearest neighbor interpolation does not use any interpolation algorithm or smoothing algorithm. You only need to find the discrete point closest to the grid node in the search ellipse, and then use the value of the discrete point as the node value of the grid. If no vertex is found, set the grid node to the nodata value.

Refer to the FunctionGdalgridcreateMedium structGdalgridnearestneighboroptionsParameter List andGdal_gridToolNearestOption List.

Iii. Data indicator calculation

All metric calculations are controlled using a struct called gdalgriddatametricsoptions.

1. Minimum Data Value (minimum data value)

Search for the minimum value found in the ellipse. If no vertex is found, the nodata value is returned. The formula is as follows:

Formula:

  • Z is the returned result value;
  • Zi indicates the value of vertex I;
  • N indicates the point in the search ellipse.
2. maximum data value)

If no vertex is found, the nodata value is returned. The formula is as follows:

Formula:

  • Z is the returned result value;
  • Zi indicates the value of vertex I;
  • N indicates the point in the search ellipse.
3. Data range)

In the search for the difference between the maximum and minimum values in an ellipse, if there is no vertex, The nodata value is returned. The formula is as follows:

Formula:

Z is the returned result value;

Zi indicates the value of vertex I;

N indicates the point in the search ellipse.

4. Search Ellipse)

The search window used in the grid interpolation algorithm is a rotating elliptical, which can be described using the following three parameters:

  • First radius (if the rotation angle is 0, it is the X axis)
  • Second radius (if the rotation angle is 0, it is the Y axis)
  • Rotation Angle (counterclockwise)

Only vertices within the search elliptic (including on the boundary) are used for calculation.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.