Geographic processing-Chapter 6 shared geographic Processing

Source: Internet
Author: User

We have discussed so many ways of geographic processing. In terms of ESRI's development technology, we have always promoted geographical processing, especially in the 9.2 system framework, geographic processing is promoted as a core technology. So what is the change in geographic processing in the 9.2 system?

One of the biggest differences between arcgis9.2 and the previous version of geographic processing is that it incorporates geographic processing into the desktop, ArcGIS Engine, and ArcGIS Server. That is to say, we can use geographic processing tools in ArcGIS Engine, and we can also use geographic processing in the same basic AO architecture ArcGIS Server. The powerful advantages of ArcGIS structural integration and functional integration are embodied in this aspect. Let's take a look at how the engine and server share geographic processing.

ArcGIS Engine geographic Processing

Section 1 ArcGIS Engine geographic Processing
In ArcGIS, geographic processing can run tools through scripting languages such as Python and JScript. Likewise, it can be executed through system languages such as C ++, Java, and DOTNET. The geoprocessor object model is provided in the ArcObjects object model diagram of 9.2. It is mainly used to call ESRI's geographic processing object library, including many igeoprocessor interfaces and geoprocessor object classes. 6-1

Use geoprocessor (or geographic processing engine)
Geographic processing tools can be run using Geographic processors. The geographical processor class is the main class for simplifying the execution of geographic processing tools. You can use the geographic processor interface igeoprocessor to access the attributes and methods of the executable tool, set the global environment, and check the result information. The geoprocessor class is a simple access node that executes any geographic processing tool in ArcGIS, including an extension module. We can view the example code "how to execute geoprocessing Tools" in the development help system ".
In fact, we can use ArcGIS Engine to call the corresponding interfaces of the ArcObjects object library. Why do we need a geographical processor? We can draw a conclusion by looking at the example below.
Here is an example. If we want to create a shape file, let's look at the codes corresponding to the geographical processor and arcobject. The model builder processing process is 6-2. The corresponding code is shown in table 1.

From table 1, we can easily see how easy it is to use a geographical processor to call a function!

The ArcGIS Engine calls the geoprocessing syntax, which is the same as that of ArcObjects, as shown in the preceding example code. Therefore, the engine Help Guide provides more detailed interface descriptions. In addition.

TS code (38 rows)

  1. Public sub createshapefile ()
  2. Const strfolder as string = "D:/Data"
  3. Const strname as string = "myshapefile" 'dont include. SHP Extension
  4. Const strshapefieldname as string = "shape"
  5. 'Open the folder to contain the shapefile as a workspace
  6. Dim pfws as ifeatureworkspace
  7. Dim pworkspacefactory as iworkspacefactory
  8. Set pworkspacefactory = new shapefileworkspacefactory
  9. Set pfws = pworkspacefactory. openfromfile (strfolder, 0)
  10. 'Set up a simple fields collection
  11. Dim pfields as ifields
  12. Dim pfieldsedit as ifieldsedit
  13. Set pfields = new esrigeodatabase. Fields
  14. Set pfieldsedit = pfields
  15. Dim pfield as ifield
  16. Dim pfieldedit as ifieldedit
  17. 'Make the shape field
  18. 'It will need a geometry definition, with a spatial reference
  19. Set pfield = new esrigeodatabase. Field
  20. Set pfieldedit = pfield
  21. Pfieldedit. Name = strshapefieldname
  22. Pfieldedit. type = esrifieldtypegeometry
  23. Dim pgomdef as igeometrydef
  24. Dim pgomdefedit as igeometrydefedit
  25. Set pgomdef = new geometrydef
  26. Set pgomdefedit = pgomdef
  27. With pgomdefedit
  28. . Geometrytype = esrigeometrypolygon
  29. Set. spatialreference = new unknowncoordinatesystem
  30. End
  31. Set pfieldedit. geometrydef = pgomdef
  32. Pfieldsedit. addfield pfield
  33. 'Add Another miscellaneous text field
  34. Set pfield = new esrigeodatabase. Field
  35. Set pfieldedit = pfield
  36. With pfieldedit
  37. . Length = 30
  38. . Name = "misctext"
  39. . Type = esrifieldtypestring
  40. End
  41. Pfieldsedit. addfield pfield
  42. 'Create the shapefile
  43. '(Some parameters apply to Geodatabase options and can be defaulted as nothing)
  44. Dim pfeatclass as ifeatureclass
  45. Set pfeatclass = pfws. createfeatureclass (strname, pfields, nothing ,_
  46. Nothing, esriftsimple, strshapefieldname ,"")
  47. End sub

Copy code

Geographic processing code (4 rows)

  1. Dim GP as object
  2. Set Gp = Createobject ("esrigeoprocessing. gpdispatch ")
  3. GP. createfeatureclass "D:/Data", "myshapefile. SHP", "polygon"
  4. GP. addfield "misctext", "text", 30
Copy codeSection 2 ArcGIS Server geographic Processing

(1) File Sharing
In ArcGIS Desktop, tools can run independently, and multiple processing tools and data can be combined in model builder. These tools can be saved in. in the tbx file, you can share it with others through emails, CDs, or other storage media. It is easy to use. You only need to add this toolbox in arctoolbox to use it.
(2) database sharing
At the product level of ArcGIS Server 9.2, two technologies are provided. One is database management technology, which is the ArcSDE product technology of products earlier than 9.2. In the Geodatabase of ArcSDE, you can save toolbox. We can save toolbox tools or model builder in the ArcSDE database, in this way, other people can access these geographic processing tools by connecting to the SDE database. And run the tool or model as in arctoolbox. 6-3

The warehouse receiving method of the geographic processing tool is the same as that in the arctoolbox operation. By creating a new tool or adding a new tool, select the tool to be saved in the database from the system tool, then the warehouse receiving is completed.
(3) web service sharing
ArcGIS Server 9.2 is powerful and can publish a variety of services, one of which is the geographical processing service. You can publish a toolbox through ArcGIS Server like a data service, which is called a geographical processing service. By publishing the ArcGIS service, anyone can access the Internet and ESRI products. The service is executed on the server. The server computer resources are used to allow the client to run the service and display the results. In addition, ArcGIS Server may have or install all ArcGIS extension products (such as spatial analysis or network analysis). If the client needs to run these functions, you do not need to install these extensions on their local machine.
We can use actual examples to see how to implement such a function.

The following example shows how to create and release a simple model to ArcGIS Server step by step. The model allows users to enter a vertex for interaction and buffer and analyze the vertex. The only data you need to process in this model is a vertex element.
This example consists of three steps:
L create and test models in your computer environment
L enable ArcGIS Server to access the folder containing your toolbox and Model
L release toolbox as ArcGIS geographic Processing Service

This example assumes that the system configuration is described in 6-4. The computer name [url = file: // cogitator/] // cogitator [/url] is your desktop computer. You will create toolbox and model tools on this machine and share folders. The server on which ArcGIS Server is located is named [url = file: // lab13/] // lab13 [/url], which can be accessed through the LAN. You do not need to copy any toolbox or data to the server. When necessary, the server can access your computer.

The configuration of this system is specially selected because it requires the server ([url = file: // lab13] // lab13 [/url]) you can access resources of other computers on the LAN ([url = file: // cogitator] // cogitator [/url]) and demonstrate how to create an authorized account.

Create model

Part 1: Create a folder and toolbox

In arccatalog, create a folder named gpserverexamp0le. It doesn't matter where you create it. Assume that the created path is E:/gpserverexample.
Create a new toolbox named myservertools under E:/gpserverexample and mark the label as my server tools.
Open ArcMAP, display the arctoolbox window, and add E:/gpserverexample/myservertools to the arctoolbox window. (Arctoolbox displays the label "my server tools" of the toolbox, as shown in 6-5 .)

Part 2: create a model
In my server tools, create a new bufferpoints model and set the label to "buffer points ".
Add the buffer tool to the model. Rename the output name "buffered points" and set it to the model parameter, as shown in Figure 6-6.
3. Right-click the model blank space and select create a new variable from the pop-up menu. Set the data type to feature, as shown in 6-7.

4. Rename the newly created variable as "points to buffer", connect it with the buffer tool with the connection tool, and set it as a model parameter, as shown in 6-8.

5. The "points to buffer" variable needs to know what element classes to create and draw them. You can right-click this variable and select Properties to set such information. Click the data type option and refer to any vertex element class or layer in "Import schema and symbology from. (This example uses the vertex element. In fact, the buffer function accepts any type of element classes, so you can choose any type) 6-9.

6. Create a new variable with the Data Type Linear Unit. Rename this variable to "buffer distance", connect to the distance [value or field] parameter in the buffer, and set this variable to the parameter (parameter), as shown in 6-10.

7. Right-click the output variable "buffered points" and choose "manage", as shown in Figure 6-11. Management output means that the output location can be specified when ArcGIS Server runs the model. Therefore, we recommend that you set management output for all models published through the server, except for tool layers (for tool layer, refer to example map service with geoprocessing ). The management output is written to the scratch workspace automatically created by ArcGIS Server.

8. Save the model and exit modelbuilder.





Part 3: test the model locally
The above describes how to prepare a model. Before releasing a model, we need to test the model. Because the input data type is feature set, a feature set needs to be placed interactively. Therefore, you need to execute the model in a map application, for example, ArcMap.

Open ArcMap and add myservertools to the toolbox.
Add the geographical processing result to display.
Open the buffer points tool. Dialog Box 6-12

One or more points are provided for buffering and the buffer distance.
Click OK.
After the tool is executed, a new layer will be added to the ArcMap content table. You cannot control the name of this layer. Because the output of the tool has been managed, the name is selected by ArcGIS. However, you can rename this layer In ArcMap.
The output is drawn with the default multi-deformation symbol. You can modify the filled style by editing the buffer point model.
Set the access toolbox to publish the my server tools toolbox to ArcGIS Server, you need to set the access path (E:/gpserverexample) that contains this toolbox for ArcGIS Server ). For specific settings, see "giving ArcGIS Server access to Folders" in the Desktop Help Guide.
In ArcGIS, a toolkit cannot be released. Only the Toolkit can be released to ArcGIS Server.
In the preceding steps, you have created and tested a buffer point model. And access this folder 6-13.

This folder is accessed through UNC pathnames, // cogitator/gpserverexample. You must know that there are two path names for the tool to be released:
E:/gpserverexample/myservertools
[Url = file: // cogitator/gpserverexample/myservertools] // cogitator/gpserverexample/myservertools [/url]

You can publish the toolbox in arctoolbox or right-click the toolbox in arccatalog and select publish to ArcGIS Server for publishing.
Note: When you publish a toolbox, you need to confirm that the Toolbox you publish uses its UNC path name instead of the local place name, as described below.
In arccatalog, browse [url = file: // cogitator/gpserverexample] // cogitator/gpserverexample [/url] and right-click myservertools, as shown in 6-14:

Note: Do not browse E:/gpserverexample and publish it here. If this is the case, ArcGIS Server will search for E:/gpserverexample on the local machine instead of on your machine.
Publish in arctoolbox. In the above step, we use the UNC path name to publish in arccatalog. In fact, we can also add the tool to arctoolbox and release it again:
L right-click my servertools and select Remove

L right-click arctoolbox, select Add toolbox, browse to // cogitator/gpserverexample, and add myservertools.
Once you have added the toolbox with the UNC path name, you can directly publish the toolbox in arctoolbox by right-clicking it.
The release wizard completes the above steps and starts to publish the toolkit. Then, we can publish the geographic processing service through the release wizard. The wizard details are not described here.
How does server access your toolbox?
After you release the toolkit, ArcGIS Server reads the content of the Toolkit and saves the location of the Toolkit and some parameters of the tool. It does not copy the toolbox to the server. When you stop and restart the service, ArcGIS Server re-reads the toolbox and refreshes the information. Therefore, if you modify the model, you must stop and restart the service.
In the preceding step, the service name is docexampletools. To add this ArcGIS service, you only need to add this service in the arctoolbox in the same way as adding other toolboxes. After adding a service, you can use the service tool like other tools.
In ArcMap, arccatalog can use the geographical processing service of ArcGIS. We can also use this service in ArcGIS Explorer, as shown in tasks in 6-15.

For details about how to use the geographical processing service of ArcGIS Explorer, see the help of ArcGIS Explorer.



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.