当前位置:网站首页>[modulebuilder] GP service realizes the intersection selection of two layers in SDE

[modulebuilder] GP service realizes the intersection selection of two layers in SDE

2022-06-25 23:11:00 DORIC. MA

0 demand

SDE Save two feature classes in , One is the range line data , One is the target element data . Need to use GP The service implements a function , That is, specify a feature in the scope line feature class , Automatically filter out the features in the target feature class that intersect with the range line , And return the attribute information of intersecting elements .

1 Ideas

Several problems need to be solved :

  1. What analysis method is used to judge the intersection relationship between elements ?
  2. How to make GP Service can call SDE Data in ?

About the problem 1:

The most straightforward way to judge the intersection relationship is to use 【 Analysis tools - Superposition analysis - The intersection 】 Tools , There is no big problem with this approach , But it needs to generate intermediate feature classes , And it takes a relatively long time , Not a good solution . One recommended way is to use 【 Data management tools - Layer and table views - Select layers by spatial location 】 Tools , The tool can also realize complex spatial relationship selection , No intermediate feature classes are generated and the time is short .

One more thing to pay attention to when judging the intersection relationship , In the use of 【 Select layers by spatial location 】 When the tool judges intersecting elements , Feature classes that share edges with the scope line are also judged to intersect , It is necessary to eliminate this special case from the search results .

About the problem 2:

call SDE The premise of the data in is Connect SDE, Can generate SDE Save the connection file to a specific path and assign the absolute path to GP Tools .

2 Realization

GP The tool flow is shown in the figure :

 Insert picture description here

In this tool flow , The upper edge is the target feature class , The lower edge is the scope line feature class . The two intersect at 【 Select layers by spatial location 】, Then remove the common edge feature class , Get the target results . Detail the steps :

step 1: Specify the feature layer

Make Feature Layer The tool assigns the feature layer , Convert feature classes to feature layers , Make it a follow-up 【 Select layers by spatial location 】 Input class of the tool .

In the upper branch Dest_Name As Make Feature Layer Preconditions for tools , Represents the name of the target feature class , Used to dynamically specify the use of SDE Which feature class in is the target feature , Can improve the whole of GP Reusability of tools .

 Insert picture description here In the upper branch Dest Is a string variable , Used for setting up SDE Location of the feature class , The content is SDE The absolute path to the connection file and its internal feature classes .
 Insert picture description here In the upper branch Make Feature Layer The input variable is Dest, Output Dest_Layer.
 Insert picture description here The overall idea of the upper branch is similar to that of the upper branch , The only difference is to increase Code Variable input , This variable is used to construct SQL Statement to filter a specific feature in the scope line feature class . This variable is specified as GP Input parameters of the tool , Ensure that this parameter can be specified from the front end after the service is published .
 Insert picture description here

step 2: Select layers by location

This link will Dest_Layer and Extent_Layer Select as input , Spatial relationship selection INTERSECT.
 Insert picture description here

step 3: Remove common edge features

Input steps 2 The result of our choice , Spatial relationship selection 【 Edge intersection 】, Enter the range line again , The selection type is 【 Remove from the selected results 】. Set the processing result of this step as the output parameter , Ensure release GP After the service, the front end can obtain the processing results .
 Insert picture description here  Insert picture description here

step 4: Execute tools and publish Services

Complete step by step GP Service release

3 Example GP Download tool

CSDN Resource download address

原网站

版权声明
本文为[DORIC. MA]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/176/202206251944167360.html