SuperMap iObject Java implements overlay analysis

Author: Jiang Er


Preface

 This article mainly uses overlay analysis and intersection analysis as an example, provides code and comments as a reference, and provides screenshots of the running results to visualize the results. For detailed introduction to the overlay analysis function, please refer to the SuperMap official online help document, the following links: http://support.supermap.com.cn/DataWarehouse/WebDocHelp/iObjectsJava/index.html , https://help.supermap.com /iDesktopX/zh/


Table of contents

1. Functional principle

2. Main code

3. Complete sample code

4. Display of running results


1. Functional principle

Overlay analysis class (OverlayAnalyst). This class is used to perform various overlay analysis operations between two input data sets or record sets, such as clip, erase, union, intersect, identity, Symmetric difference (xOR) and update (update).

Overlay analysis is a very important spatial analysis function in GIS. It refers to the process of generating a new data set through a series of set operations on two data sets under a unified spatial reference system. Overlay analysis is widely used in resource management, urban construction assessment, land management, agriculture, forestry and animal husbandry, statistics and other fields. Therefore, through this overlay analysis class, the processing and analysis of spatial data can be realized, the new spatial geometric information required by the user can be extracted, and the attribute information of the data can be processed.

* Notice:

  1. The two data sets used for overlay analysis are called the input data set (called the first data set in SuperMap GIS). Its type can be points, lines, areas, etc.; the other is called the overlay data. The data set (called the second data set in SuperMap GIS) is generally a polygon type.
  2. It should be noted that the polygon dataset or record set itself should avoid containing overlapping areas, otherwise the overlay analysis results may be incorrect.
  3. The data for overlay analysis must have the same geographical reference, including input data and result data.
  4. When the amount of data for overlay analysis is large, a spatial index needs to be created on the result data set to improve the display speed of the data. 

2. Main code

The following main code shows intersection analysis:

// 设置叠加分析参数
System.out.println("开始设置叠加分析参数");
OverlayAnalystParameter overlayAnalystParamIntersect = new
                OverlayAnalystParameter();
overlayAnalystParamIntersect.setSourceRetainedFields(new String[] {"SmID","tt","ttt"});//设置进行叠加分析的第一数据集或记录集中需要保留的字段名称集合。
overlayAnalystParamIntersect.setOperationRetainedFields(new String[] {"SmID","smarea","col","col_1"});//设置进行叠加分析的第二数据集或记录集中需要保留的字段名称集合。
overlayAnalystParamIntersect.setTolerance(0.00000001);
// 调用相交叠加分析方法实相交分析
Boolean OverlayAnalystintersect =  OverlayAnalyst.intersect(DatasetVectorIntersected, DatasetVectorIntersect,resultDatasetIntersect,overlayAnalystParamIntersect);        
System.out.println("是否执行相交成功:" + OverlayAnalystintersect);

Note that the analysis results need to create a result data set for storage, for example:

//创建一个面矢量数据集,用于存储相交分析返回的结果//文件数据源
String resultDatasetIntersectName = datasource.getDatasets().getAvailableDatasetName( "resultDatasetIntersect");
DatasetVectorInfo DatasetVectorInfoIntersect = new DatasetVectorInfo();
DatasetVectorInfoIntersect.setType(DatasetType.REGION);    DatasetVectorInfoIntersect.setName(resultDatasetIntersectName);
DatasetVectorInfoIntersect.setEncodeType(EncodeType.NONE);
DatasetVector resultDatasetIntersect = datasource.getDatasets().create(DatasetVectorInfoIntersect);   

3. Complete sample code

For complete sample code, please see the resource link:

https://download.csdn.net/download/EliseJ/88576862

4. Display of running results

Guess you like

Origin blog.csdn.net/EliseJ/article/details/134592613