Apply Python integrated geological statistics in component GIS

xiaoxiao2021-03-06  68

Apply Python integrated geological statistics in component GIS

- Take trend surface analysis with Python and SuperMap Object as an example

Mavan

Li Lin

Wang Xiaofui

Summary: As GIS applications expand and deepen in the field of geological applications, it is necessary to introduce and integrate geological statistics for GIS tools. Applying COM component technology and Python and its scientific computational extension module SCIPY can quickly and efficiently develop geological statistical analysis modules with COM interfaces and integrate into component GIS tools.

Keywords: Geological Statistics, Trend, Supermap Object, Component GIS, Python, SCIPY

1 Introduction

Geological statistics is a rapid development of emerging disciplines in the field of mathematics geological sectors, widely used in unusual evaluation, exploration, mineral set, reserves and other territory production and research (Zhao Pengda, 1994, Hou Jingru 1996, 1998). Trend analysis or trend analysis, as one of geological statistics, is to decompose the geological phenomenon of research, expressed as the mathematical equation:

Z = Z0 A R (1)

Z represents geological phenomena, Z0 represents regional factors (background), A represents partial factors (abnormal), and R represents a random factor (interference value). In the study, the problem often comes down to the problem of looking for anomalies on the region. The method of trend surface analysis is to represent a synthesis of generic information or some indicators as a space surface, and then manually construct a surface representative factor (background value) according to the mathematical method, and simultaneously apply statistical methods to eliminate random factors. The purpose of achieving highlighting and abnormal values ​​(in Chongwen, 1980, Zhao Xudong, 1992).

Traditional geological statistical analysis or trend analysis is to apply geographical professional software packages or other mathematics, statistical software bags with regression analysis, and then combined with maps such as space and regional explanations. At present, with the introduction of GIS in practical work and research work, GIS methods and tools have also been introduced in many combined geological statistics, but existing GIS tools do not support geological statistical analysis, so space information And indicators have improved the improvement of work efficiency between GIS tools and geological statistics tools, causing loss of unnecessary data information accuracy, sometimes even because of the closure of data file formats. Can't do or interrupt.

With the expansion and deepening of GIS applications, it is imperative to introduce and integrate geological statistics for GIS tools, and therefore it is necessary to carry out geological statistics and GIS integration techniques and methods. In this paper, it will be treated as an example, explore the method of developing geological statistical analysis tools for COM component technology and Python and its scientific calculation expansion module, and how to integrate geological statistics expansion modules in component GIS tools.

2. Geological Statistics and GIS Tool Integration

At present, the integrated mode commonly used in GIS basic software and spatial analysis model and geographical model mainly has the following (Song Guanfu, 1998, Fang Yu, 2001, Feng Kezhong, 2003): (1) Through data files in GIS platform software and spatial analysis model Or establish a connection between the geographical model, which is a loose integration method. Its advantage is that the development of the development and spatial analysis model of the GIS platform can be carried out independently, as long as the consistent data exchange format can be carried out; its disadvantage is to exchange data by file mode, not suitable for large and frequent data exchange; 2) Directly use the secondary development language provided by GIS software, such as MapInfo, ArcInfo has its secondary development language. This approach is suitable for developing some small systems, but due to most of the secondary development language provided by GIS, it is difficult to develop a relatively complex analysis model; (3) based on component technology extension. Component technology has promoted the generation of component geographic information systems, greatly simplifies the difficulty of GIS integration spatial analysis model or geological model. Based on component interface call mode, on the one hand, the independence between GIS system development and analysis model development is guaranteed, and the seamless integration of the two is achieved. Therefore, the geological statistical analysis tool can be introduced and integrated into the development or extension of ArcGIS 8.0 and above, SuperMap Object, etc., based on component geographic information systems, such as ArcGIS 8.0 and above, SuperMap Object et al. As the dynamic scripting language, Python has the advantages of simple syntax, easy to learn, interpretation, no need to compile, easy to deploy, and maintenance, using Python development efficiency than the language and other languages ​​such as static programming languages, and develops Python. And the difficulty of maintenance is low, as system extensions and rapid development languages ​​have the advantages of general static programming languages ​​(Hammond, 2000, Lutz, 2001, http://www.python.org); on the other hand, Python has high-rise Built-in data structure, excellent scientific calculation expansion library SCIPY (including scientific computing, statistical analysis, visualization module, http://www.scipy.org), therefore in ArcGIS, SuperMap Object, etc. COM-based component geographic information system In the platform, geological statistical analysis tools can be implemented and integrated with Python.

3. System design and implementation

3.1. System structure

The design of geological statistical analysis tools requires the following objectives: (1) Geological Statistics Analysis Tool will be exposed to the caller in the form of a COM component library, and the component can be called COM expand or integrated GIS tool call; 2) Internal implementation of the component, the structure is hidden on the caller, the caller is interacting with the component through the COM interface, so that the deployment of the component is completely unrelated to the component calorie, the component itself can be modified at any time, upgrade without affecting The use of the caller; (3) The data structure of the component, the data file is not bound to any particular GIS platform to ensure that components can be used or integrated in multiple GIS tools.

We will use Python and its scientific computational extension modules to develop geological statistics modules for object-oriented methods, and use pythoncom (hammond, 2000, http://www.activestate.com) to write modules to call in COM. Interface [1] (Figure 1). Therefore, the system is mainly composed of two parts: (1) Geological statistics analysis of Python Writing calculation component library, this section uses Python implementation, can run in any environment that can run Python; (2) Apply the geological statistics implemented by Pythoncom Learn to calculate the COM interface of the component library, through this interface, any programming environment and language that can call COM components can call this component library, Pythoncom must run in the Windows environment. Any GIS tool that can be integrated or extended through a COM can use this geological statistical analysis to calculate the component library. GIS tool

Component caller

(ArcGIS)

SuperMap Obeject)

...

Geological Statistics Component Library Written by Python

COM

transfer

interface

Trend surface analysis

regression analysis

Cluster analysis

......

Geological statistics component library

Python Executive Environment

Standard library

SCIPY expansion library

Pythoncom extension

Windows API Other Runture ...

Figure 1 Geological statistics component library system structure

3.2. System implementation

We first use Python, with its powerful scientific calculation extension module SCIPY to write relevant modules of geological statistics. SCIPY has a large number of outstanding scientific computing kits, such as matrix operations, linear algebra [2], statistical analysis, FFT, etc., can be used directly during programming; all kinds of scientific computing algorithms built into SCIPY are mostly used C language or Fortran language applied mature algorithm or code library implementation, and then integrated in Python. Therefore, using the relevant algorithm for geological statistics using SCIPY, on the one hand, it can be implemented quickly and efficiently by Python; on the other hand, since the SCIPY itself is the basic algorithm, speed and use of the FORTRAN language. Language or Fortran language is written in a similar algorithm, so the geological statistics operation of SCIPY will not be discounted because Python is a scripting language.

Below we use the SCIPY to achieve trend surface analysis as an example to introduce the implementation of the entire system. The trend surface generally uses two mathematical functions, one is a polynomial function, and the other is Fourier fraction, wherein the polynomial trend is most common. The trend surface solve process includes the following steps: (1) The mathematical expression (polynomial and secondary number of Fourier fraction), using the least squares method, using the least squares method to establish a solution clause group according to the requirements of the Trend surface of the need, and the least squares can be used. Document (Yu Chongwen, 1980, Zhao Xudong, 1992), directly uses a good equation group; (2) calculate the solution matrix of the equation in accordance with known observation data (Xi, Yi, Zi); (3) Apply Gaussian Solving the solution group; (4) Calculate the fit and residual of the trend surface by solving the results (i.e., A) in Equation 1. In these 4, the third step is to program a more difficult implementation, but SCIPY provides an abstract data structure such as matrix, and implements algorithms such as linear equation solution, which can be used directly, and the example is shown in Figure 2 [3]. Using matrix operations or linear equations solving function, resulting and efficiency are consistent, for users, such as using MATLAB and other tools, can not consider the underlying algorithm, because SCIPY has been optimized, no need to worry. For actual applications, the coefficient matrices A and B are first calculated, and then they can be solved directly to the fixed coefficient matrix to obtain an expression of the trend surface function. # Import the SCIPY module

>>> from scipy import *

# 建立 matrix a and b

>>> a = Mat ('[1 3 5; 2 5 1; 2 3 8]')

>>> b = Mat ('[10; 8; 3]')

# 通过 运 运 运 运

>>> a.i * b

Matrix ([[[- 9.28],

[5.16],

[0.76]]])

# By calling the linear equation to solve the solution

>>> linaalg.solve (a, b)

Array ([[- 9.28],

[5.16],

[0.76]]])

Figure 2 Two methods for solving linear equations in the Python command line environment

After completing the Python code, the next step is to package this code into a COM object, you can define a new class, you can also directly encapsulate this class into a COM object, implement the required properties and methods, using Pythoncom extension, implement Progid, CLSID, PUBLIC_METHODS, etc. Register this Python class in the registry, making it a COM object that can be called.

Thus, for the geological analysis, this object can be called, in the visualization tool such as GIS, the original data, trend surface, residuality are represented as a contour or surface, and the geographical analysis is performed.

3.3. Component use

Hereinafter, how to integrate this component into the GIS tool in SuperMap Object to use and call Python as an example to illustrate how this component is integrated into the GIS tool [4].

(1) Data organization: By spatial analysis or query, the "query" method needs to be analyzed by spatial analysis or query, generates a "replandset", obtain the Z value you need to analyze through the "SorecordSet.GetfieldValue method," SorecordSet.getGeometry) ) "The method gets the geometric object that needs to be analyzed. It is generally the pointOPoint, and the X, Y coordinate, written temporary file or array, loop all X, Y, Z. (2) Call of trend analysis: We write Python to solve the trend analysis component to pass data using text files, and its advantage is that the amount of data can be transmitted, and the GIS platform is not related, and the weakness is not as high as memory. However, for geographical problems, since the amount of data is generally large, the text file is used is more appropriate. Call trend analysis requires the following methods to create objects and call (Figure 3), strDataFile is the input data file path and file name, StrResultPath is the path of the output data file, the component will result, fit, residual data files Write this directory.

DIM Objtrend As Object

Set objtrend = creteObject ("Geostatistics.Trend")

'Call 2 trend surface analysis

Objtrrend.Poly2 (strdatafile, strResultpath)

Figure 3 Analysis of trend surfaces under VB

(3) Generate the required data set in SuperMap Object: According to Python's output, you can create a new data set in SuperMap Object to read these data. Create a new dataset "objDataSet", app "Objdataset.Query (", true), generate a "RECORDSET", then read (original data, residual) or calculate (trend surface) X, Y, Z, generate "SoGeopoint" objects according to X, Y, add this object to "Objdataset" with the "ADDNEW" method of the "Recordset" object, and assign the original data, trend surface, and residual value (Z) to the corresponding Get "field" to dynamically generate the required data sets.

(4) Visualization analysis in SuperMap Object: Using the previously generated data set, we can use the SuperMap Desktop and other tools, which generate the GRID data by these data, and then perform 3-dimensional visual display and analysis, and directly apply the programming method. Generate the required data sets by similar methods such as "SogridAnalyst.Point2DtoGrid". When the GRID data set is generated, it can be analyzed by visualization method, combined with GIS spatial analysis, such as superposition analysis, buffer analysis, and analysis of geological mechanisms.

4 Conclusion

Applying Python and its extended module SCIPY can efficiently implement geographical statistical analysis, using the Pythoncom extension module to encapsulate it to COM components, call the Geological Statistics Analysis Function for the GIS Tool. Compared to other development languages, Python excellent scientific computing, statistical analysis, visual expansion module SCIPY, and Python dynamic language advantages, the development efficiency and development quality of geological statistics components can be improved, and the development cycle is shortened. Based on COM-based development and calls ensure the development of the GIS system and the independence of Python extension development. For components developed by Python objects, you can modify at any time (including compiling packages), and will not affect GIS components. For the call; on the other hand, the seamless integration of the Python extension component and the GIS tool. references

1. Zhao Pengda, Li Zijin, Hu Wangliang, deposit statistics prediction (m). Beijing: Geological Publishing, 1994, 10-195

2. Hou Jingru, Yin Zhennan, Li Weiming, etc., practical geological statistics (M). Beijing: Geological Publishing House, 1998

3. Review and Prospects of Hou Jingru, China Geological Statistics (Space Information Statistics) (J), Geological and Exploration, 1996,32 (1): 20-25

4. Introduction to Zhao Xudong, Petroleum Mathematics Geology, Beijing: Petroleum Industry Press, 1992, 65-81

5. Method and Application of Chongwen, Mathematical Geology, Beijing: Metallurgical Industry Press 1980,

6. Feng Kezhong, Wan Qing, Qi Hui, Based on Component Technology, GIS Generalized Space Analysis, Earth Information Science, 2003, 1: 62-66

7. Song Guanfu, Zhonglu Wu; Research and Development of Component Geographic Information System, China Image Graphics, 1998, 3 (4): 314-317

8. Fang Yu, Zhou Chenghu, etc., the fourth-generation GIS software research, China Graphic Image Journal, 2001, 6 (9): 817-823

9.

Hammond

M., Robinson A., Python Programming On Win32, O'Reilly, 2000

10. Lutz M., Programming Python, 2nd Edition, O'Reilly, 2001

11. Rossum G., Extending and Embedding The Python, http://www.python.org, 2003

12. http://www.python.org

13. http://www.activestate.com

14. http://www.scipy.org

[1] pythoncom is a Python extension that Python encapsulates the Python module into a COM object in a Windows environment. Detail introduces Movan, integrated with Python method in component GIS development, not published

[2] SCIPY matrix operation and linear algebra module constructed in Atlas Lapack and Blas, it is a very good linear algebraic code library [3] Since this problem actually solves the code too long, it is inconvenient to include the text, but the idea and solving method is completely consistent

[4] Some nouns, objects, and methods used in this section are subjects or methods of SuperMap Object, and unfringers can refer to their relevant documents.

转载请注明原文地址:https://www.9cbs.com/read-87314.html

New Post(0)