GP service step by step: Buffer points
Creates polygons around points.
BufferService (geoprocessing service).
User digitizes a point.
Of all the examples, this is the most basic service.
Data can be found at C:\arcgis\ArcTutor\GP Service Examples\BufferPoints. After completing all the steps described below, you will have duplicated the contents of this folder.
Create a toolshare folder
- Start ArcCatalog.
- Create a new folder, BufferPts, in a location of your choice, as follows:
- Navigate to an existing folder of your choice.
- In the Catalog tree, right-click the folder and click New > Folder.
- Name this folder BufferPts.
- In the Catalog tree, right-click BufferPts and click New > Folder.
- Name the folder ToolData.
- In the Catalog tree, right-click ToolData and click New > File Geodatabase.
- Name the file geodatabase Schema.
- Using the same steps, create a folder within BufferPts named Scratch. Within the Scratch folder, create a new file geodatabase named Scratch.
Create the toolbox
In the Catalog tree, follow these steps:
- Right-click the BufferPts folder.
- Point to New > Toolbox.
- Name the toolbox BufferService.
Create schema feature class
You will need a point feature class to use as a schema for the feature set variable you will use in the model described below.
- In BufferPts/ToolData, right-click the Schema geodatabase and click New > Feature Class.
- Name the feature class Point.
The feature type is Points.
- Click Next.
- Click Next.
- Accept the default value for XY Tolerance and click Next.
- Accept the default value for Configuration keyword and click Next.
- Click Finish (the feature class does not contain any user-defined attributes).
Create the model
With the steps below, you will create a new geoprocessing model to buffer point features.
- Right-click the BufferService toolbox, point to New, then click Model. This opens the ModelBuilder window.
- To add the Buffer tool
- Click Add on the ModelBuilder toolbar.
- On the Add Data or Tool dialog box, navigate to Toolboxes > System Toolboxes > Analysis Tools > Proximity.
- Click Buffer and click Add. (An alternative to this method is to drag the Buffer tool from the ArcToolbox, Search, or Catalog window onto the ModelBuilder canvas.) The ModelBuilder canvas now appears as follows:
- When using ModelBuilder, you often need to move and resize elements (tools and variables). In the illustration above, the output variable is actually named Output Feature Class but is truncated because of the size of the variable. To resize, click the output variable and click and drag one of the small blue selection squares. Now your model looks as follows:
- Right-click Buffer, point to Make Variable > From Parameter, then click Input Features.The model now looks as illustrated below:
- Right-click Input Features and click Properties. On the Input Features Properties dialog box, click the Data Type tab.
- In the Select data type drop-down list, choose Feature Set. On the Import schema and symbology from box, enter the path or browse to the point feature class Points you created in the above steps.
- Click OK. The Input Features variable is now a blue color.
- Right-click Buffer, point to Make Variable > From Parameter, then click Distance [value or field]. A new model variable is created.
- You may need to click and drag the variable so that it is not on top of the Input Features variable and resize it to show the complete variable name.
- Right-click the Distance [value or field] variable and click Rename. Rename the variable to Distance.
- Right-click Distance and click Properties. On the Distance Properties dialog box, click the Data Type tab.
- In the Select data type drop-down list, choose Linear Unit.
- Click OK.
- Double-click Distance (or right-click and click Open). Set the distance to 1000 meters. The Distance variable is now a blue color, and the Output Feature Class variable is a green color. This signifies that all required inputs to Buffer have been provided.
- Right-click the Output Feature Class variable (the output of Buffer) and click Rename. Rename the variable to Output Polygons.
- Double-click Output Polygons and enter %scratchworkspace%\BufferedPoints.shp
- Click OK
- Right-click Input Features and click Model Parameter. P (for parameter) appears next to the variable.
- Right-click Distance and click Model Parameter. P appears next to the variable.
- Right-click Output Polygons and click Model Parameter. P appears next to the variable.
The model should now appear similar to the illustration below:
- In the main ModelBuilder menu, click Model and click Model Properties
- Set Name to BufferPoints
- Set Label to Buffer Points
- Check the Store Relative pathnames option.
The illustration below shows these settings:
- Click OK.
- In the main ModelBuilder menu, click Model and click Save. Then click Model again and click Close
Test the model
In the next series of steps, you will test your model using ArcMap—always a good idea before publishing a service.
- Start ArcMap and add data to create a map, or open an existing map document.
- In ArcMap, use the Geoprocessing menu to open both the Geoprocessing Options and Environments Settings dialog boxes.
- Configure the following:
- Geoprocessing Options: Check the Overwrite the outputs of geoprocessing operations check box.
- Geoprocessing Options: Check the Add results of geoprocessing operations to the display check box.
- Environments Settings: Expand the Workspace category and set the scratch workspace to BufferPoints\Scratch, the folder you created above.
These settings are illustrated below:
- In the Catalog window of ArcMap, navigate to your toolshare folder and choose the BufferService toolbox you created above.
- Double-click Buffer Points. (Optionally, you can right-click Buffer Points and click Open). This opens the Buffer Points tool dialog box, as illustrated below.
- Click Add Feature to add a point feature to buffer. You can add more than one feature.
- Optionally, change the Distance parameter.
- Click OK.
The tool begins to execute. When the tool finishes execution, a new layer named BufferedPoints is added to the ArcMap table of contents.
- Exit ArcMap. You do not need to save your changes.
Publish the service
To publish a toolbox to ArcGIS Server, you must have administrator access to ArcGIS Server. To connect to a server, expand the GIS Servers entry in the Catalog tree and click Add ArcGIS Server. Your server administrator—the person in charge of setting up and maintaining accounts for your ArcGIS Server installation—is responsible for setting up an account for you and granting you administrator privileges.
Once you have established an administrator connection to ArcGIS Server, you are ready to publish your toolbox.
- In ArcCatalog , right-click the BufferService toolbox and click Publish to ArcGIS Server.
- On the Publish to ArcGIS Server dialog box, choose the server you want to publish to. Name the service BufferService (this is the default name—the same as the name of the toolbox).
- Click Next.
- Click Finish.
Use the service
In the next series of steps, you will use your geoprocessing service in ArcMap.
- Open ArcMap and add data of your choosing, or open an existing map document.
- In the Catalog window of ArcMap, navigate to your server connection under GIS Servers.
- Find the geoprocessing service BufferService under the server and expand BufferService to display its contents, the Buffer Points task.
- Double-click Buffer Points task. (Optionally, you can right-click Buffer Points and click Open). This opens the Buffer Points task dialog box. Note that unlike the Buffer Points tool dialog box (shown above) when you tested your model, this dialog box does not show the Output Polygonsparameter. This is because ArcGIS Server writes the output polygons to a location on the server (defined by %scratchworkspace%), and there is no need for you to specify an output location.
- Click Add Feature () to add a point feature to buffer. You can add more than one feature.
- Optionally, change the Distance parameter.
- Be sure to turn backgroud process off to allow process dialog box appears by running following steps:
- Click Geoprocessing from ArcMap.
- SelectGeoprocessing Options
- If the Enable check box of Background Processing is checked, uncheck it. Otherwise leave the way it is.
- Click OK.
- Click Geoprocessing menu > Results, expand Current Session, then expand the BufferPoints entry. Note how you can view outputs, inputs, environments, and messages for the execution of the task. Anytime you execute a geoprocessing tool, a result is written to the Results window.
It should only take a few moments for the task to complete. A new layer is added to the ArcMap table of contents. This layer is named Output Polygons [<time>_<date>], as illustrated below.
In the next series of steps, you will be modifying the BufferService properties and running the Buffer Points task again to see the effect of changing these properties. Therefore, you do not want to exit ArcMap.
Modifying service properties
By changing service properties, you can affect how tasks execute.
- In the Catalog window, navigate to the server containing the BufferService geoprocessing service.
- Right-click BufferService and click Stop. Geoprocessing services must be stopped before their properties can be changed.
- Right-click BufferService and click Service Properties.
- Click the Parameters tab.
There are three basic parameters that you can modify that affect how the task executes. Change these parameters as discussed below, click OK, then start the service (right-click BufferService and click Start). Then run the task again in ArcMap to see the effect.
Synchronous means that the client waits until the server has finished executing the task. Asynchronous means that the client is free to do other work while the server executes the task. You should choose synchronous only for tasks that execute quickly.
BufferService has one task, Buffer Points, and this task executes quickly. Change the execution type to synchronous, restart the service, then execute Buffer Points again. With synchronous execution, the progress dialog box remains open until the task is finished executing.
Maximum Number of Records Returned by Server
The number you enter is the maximum number of records or features that can be transferred from the server to the client. A value of 0 means no records can be transferred. The default is 1000. After stopping the service, change the value to 0, restart the service, then execute Buffer Points again. The task executes and a layer is created, but there are no features since the maximum is set to 0. If you view the result on the Results window, Output Polygons has <data exceeds transfer limit>.
Geoprocessing models write messages during the execution of model processes. These messages include warnings, errors, and other information. The messages can contain paths to data residing on your server or local area network, and you may not want the paths to this data to be viewed by users. By default, messages are not shown.
Check the checkbox next to Show Messages, restart the service, then execute Buffer Points again. You should see more messages in both the progress dialog box (if the service is running synchronously) and in the result.
When you are developing and testing services, you almost always want to show messages.