Skip To Content

Tutorial: Perform web editing using data from a database

Complexity: IntermediateData Requirement: Installed with software Goal: Create a feature service that allows you to edit data residing in a database over the web using the map viewer in ArcGIS Online.

Web-based editing allows a larger group of people to add to and improve on your data. These include fieldworkers, analysts in other departments of your company, or perhaps even crowdsourced volunteers who may be able to make valuable contributions to your data given a user-friendly editing interface.

In this tutorial, you will load data to your database, grant privileges on the data, register your database with ArcGIS Server, author a map document, publish a feature service, and consume the feature service through the map viewer in ArcGIS Online to edit the data.

Before beginning this tutorial

If you want to publish a feature service from a database, it is assumed that you have a database that can store spatial data. If you do not, you must install database management software and create a database. In some cases, you must also install a spatial type or enable the database to store spatial data. You can publish feature services from one of the following database management systems:

You will need two users to complete this tutorial: one user who has privileges to create tables and feature classes in the database (a data owner) and one who initially only has connect privileges to the database (a data editor). You will grant the data editor privileges to edit the data to be published as a feature service.

If you are the database administrator, you can use the database management system's tools to create both users and grant the required privileges. Alternatively, you can use the Create Database User geoprocessing tool to create the data owner user, but you will still need to use database management system tools to create the data editor user. If you are not the database administrator, ask him or her to create a data owner and data editor for you to use to complete this tutorial.

If you've just installed ArcGIS Server, consider reading the following before you begin this tutorial:

  • For details on how to configure your ArcGIS Server site, see Getting started after installation in the help.
  • If you don't have prior experience with feature services, see What is a feature service?
  • To publish data to ArcGIS Server, you must register the data. How you register the data depends on whether you want your feature service accessing the data in your source database or whether you want the feature service to access a copy of the data. For the purposes of this tutorial, the feature service will access the data in your database. However, you should understand what this means and what other options are available. See Make your data accessible to ArcGIS Server and Determining how the server will access service data to help you determine which method is best for your situation.

Prepare the data

This tutorial contains instructions to copy feature classes into your database through ArcGIS. Data copied in through ArcGIS meets the following criteria, which is required to publish data as a feature service:

  • Feature classes you publish to a feature service to be edited must contain a not null integer field that is automatically populated with unique values by the database. This field will be used as an ObjectID field.
    Tip:

    If your data is added to the database using ArcGIS, a qualifying ObjectID field is automatically added to the table. If you have existing feature classes stored in DB2, Oracle, PostgreSQL, or ALTIBASE that you want to publish, you can use the Add Incrementing ID Field tool to add a not null integer field that is populated by the database to your table.

  • ArcGIS only recognizes one spatial column, one spatial reference, and one geometry type (that is, points, lines, or polygons) for a feature class. If your feature class contains more than one spatial column, ArcGIS will use the first one it comes to when reading the table from left to right. If your feature class contains records with different spatial references, geometries, or dimensionalities, ArcGIS will read the value of the first record in the feature class and use that. Records that do not correspond to that value will not be used.
  • All feature classes published to a feature service must have a spatial reference. Feature classes with unknown spatial references cannot be published.
  • ArcGIS recognizes specific data types. If your feature class contains data types not supported by ArcGIS, they cannot be viewed by ArcGIS clients and cannot be accessed through the feature service. See DBMS data types supported in ArcGIS for a list of the data types with which ArcGIS can work.

To create a feature class in ArcGIS that meets all these requirements, complete the next section of the tutorial.

Add feature classes to the database

Connect to the database as the data owner (the user who has privileges sufficient to create tables in the database) and copy feature classes from a file geodatabase installed with ArcGIS Server.

Connect to the ArcGIS Server sample data

A file geodatabase (tree_maintenance.gdb) is installed with ArcGIS Server. Connect to it from ArcMap.

If you installed ArcGIS Server on a Linux machine, copy or ftp the tree_maintenance.gdb to a directory on your ArcMap. The default location of the data on the ArcGIS Server Linux machine is <home directory of installing user>/arcgis/server/help/samples/data.

  1. Start ArcCatalog or ArcMap and open the Catalog window.
  2. Click Connect To Folder Connect To Folder.
  3. Choose the sample data folder, located in the directory where you installed ArcGIS Server (Windows) or copied from your ArcGIS Server (Linux) installation.

    By default, the Windows data is installed to C:\Program Files\ArcGIS\Server\help\samples\data.

  4. Click OK to add the folder to the Folder Connections in the Catalog tree.

Connect to the database as the data owner

Connect to the database as the data owner user so you can copy data into the database.

  1. Expand the Database Connections node in the Catalog tree of the Catalog window.
  2. Double-click Add Database Connection and connect to the database as the data owner user.

    See Database connections in ArcMap for information on connecting to a database.

  3. Name the connection file so that you can identify it as the data owner's connection.

    For example, right-click the new connection, point to Rename, then type dataowner@mydatabase.sde.

Copy data to your database

Copy the trees, villages, and streets feature classes from the tree_maintenance file geodatabase and paste them into your database.

  1. Open the sample data folder.
  2. Double-click the tree_maintenance geodatabase to connect to it.
  3. If you are working in ArcMap, be sure to open the Contents pane in the Catalog window.
  4. Press and hold the Shift key and choose the streets, trees, and villages feature classes in the tree_maintenance geodatabase.

    You must click on the feature classes in the Contents tab (ArcCatalog) or Contents pane (ArcMap) to choose multiple feature classes at the same time.

  5. Right-click the highlighted feature classes and click Copy.
  6. Right-click your database connection and click Paste.

Copies of the streets, trees, and villages feature classes are in your database.

Grant privileges on the data

The user who will access the data you publish must be granted privileges sufficient to edit the data. For example, if you want people to insert new features and update existing features in the feature classes you publish, you must grant the connecting user select, insert, and update privileges on the data. If you only want people to update existing records, grant the connecting user select and update privileges on the data.

You can publish the data as the data owner if you are publishing to a test site or are completing this tutorial merely for educational purposes. However, if you are publishing data to a production site, the connection used to access the data should have the least privileges required.

If you use database-authenticated users, grant privileges on the data to the database user. If you use Windows authentication to connect to the database, you must grant the privileges to the ArcGIS Server account.

The following steps grant select, insert, and update privileges on the feature classes to be included in your feature service. If you are using your own data, follow the same basic steps to grant privileges on your data.

  1. Right-click the trees feature class under the database connection in the Catalog tree, point to Manage and click Privileges.

    The Privileges dialog box opens.

  2. If the data editor database user or ArcGIS Server account is already in the list, check the boxes to grant select, insert, and update privileges on the trees feature class.
  3. If the data editor database user or ArcGIS Server account is not already in the list, do the following:
    1. Click Add to open the User/Role dialog box.
    2. If you have privileges in the database to view the system table that lists all users and roles in the database, you can choose the database user or role you want to add from the list by checking the box next it; otherwise, type the name of the database user, database role, operating system login, or Windows group to which you want to grant privileges.
    3. Click OK to close the User/Role dialog box.

      The Select box is already checked.

    4. Check the Insert and Update boxes and click OK to apply the privileges and close the dialog box.
  4. Repeat these steps for the villages and streets feature classes.

Author a map document to support feature services and web editing

Once you have the data you want to publish and have granted privileges so ArcGIS Server can access the data, you can author a map document to support the feature service you will use for web editing.

Connect to the database as a data editor

If you are using database authentication, connect to the database as the data editor user. Follow the same procedure to connect to the database as you did to connect as the data owner, only, this time, connect as the data editor. Be sure to save the user name and password with the connection by checking Save user name and password.

If you are using operating system authentication, you can connect with a login that has at least select privileges on the data. The feature service will access the data as the ArcGIS Server account, which you have already granted privileges to edit the data, not the login you are using to create and publish the map.

To help you find the connection file, rename it to be dataeditor@mydatabase. You will need this connection file when registering the database with the server.

Register the database with the server

To publish to ArcGIS Server, you must create a publisher connection to your GIS server and register your database with it. For this tutorial, you will register the database so that the publisher database is the same as the server database. That means the published feature service will access the data directly in the source database.

  1. First, connect to the server to publish data. Follow the instructions in Make a publisher connection to ArcGIS Server in ArcMap to make this type of connection.
  2. Once you are connected to the server, you can register the database. Right-click the GIS server connection and click Server Properties.
  3. On the Data Store tab, click the Add Add button next to Registered Databases.

    The Register Database dialog box opens.

  4. Enter a unique name for the registered database.
  5. Click Import and browse to and select the database connection file you created in the last section (the editor's connection to the database).
  6. Make sure the box is checked next to Same as publisher database connection.
  7. Click OK to close the Register Database dialog box.
  8. Click OK to close the ArcGIS Server Properties dialog box.

Add data to the map and set properties

You can drag the feature classes you want to publish from the editor's database connection in the Catalog window to the map. ArcMap checks for the properties it requires, such as an ObjectID field and spatial reference. If it cannot determine these properties, you will be prompted to specify the required information.

When you add a database table to ArcMap, a query layer is defined to access that table. You can alter the query layer that defines what data is displayed in ArcMap. See Modifying a query layer for instructions on changing the query layer definition.

Note:

The query definition cannot join tables; query layers can only contain data from one table if you want to publish a feature service.

When you have finished configuring the map, save your map document.

  1. Start ArcMap if it is not already started.
  2. Double-click the data editor connection in the Catalog window to connect to the database.
  3. One at a time, choose the feature classes from the database connection and drag them onto the map.

    If you are using the tutorial data, choose the villages, trees, and streets feature classes.

    ArcMap calculates the spatial extent of the data and displays the features on the map.

  4. Make sure the layers are drawn in the correct order. For the tutorial data, the order should be trees, streets, villages. If the layers are in the wrong order, click List By Drawing Order List By Drawing Order and drag the layers into the right order in the table of contents.

Once the data has been added to the map, you can set field properties, symbology, and a layer description. You can also configure HTML pop-up windows. See Author feature services for more information on setting map properties.

Set properties for the trees layer

Set general properties for the trees layer.

  1. Right-click the trees layer in the ArcMap table of contents and click Properties.

    The Layer Properties dialog box opens.

  2. On the General tab, change the Layer Name to Public Trees.
  3. Type the following for the Description: An inventory of trees in public spaces, which are maintained by the Parks Department.
  4. Set a minimum scale beyond which the trees layer will not draw.
    1. Under Scale Range, click Don't show layer when zoomed.
    2. Set the minimum scale to 1:500,000.
    3. Leave the maximum scale set to <None>.
  5. Click Apply to set the property changes you've made so far.

Set field aliases.

  1. Click the Fields tab.
  2. Assign aliases to the fields as follows:
    1. Choose tree_planted from the fields list, and type Date Planted in the Alias field.
    2. Choose eg_decid from the fields list, and type Evergreen or Deciduous for the alias.
    3. Choose last_trimmed from the fields list, and type Date Trimmed for the alias.
  3. Click Apply to set field aliases.

Next, change the symbology for the trees layer.

  1. Click the Symbology tab of the Layer Properties dialog box.
  2. Click Categories.

    The Unique values category is selected by default.

  3. Choose Evergreen or Deciduous from the Value Field drop-down list.
  4. Click Add All Values.

    The values d and e are added to the list with default symbols and colors.

  5. Change the symbol for the deciduous (d) trees.
    1. Double-click the default symbol for d to open the Symbol Selector dialog box.
    2. Click Style References and check the box next to Civic.
    3. Click OK to add the Civic symbols to the Symbol Selector.
    4. Choose the Tree 3 symbol.

      You will need to scroll down to find the symbol.

    5. Click OK to apply your change.
  6. Change the symbol for the evergreen (e) trees.
    1. Double-click the default symbol for e to open the Symbol Selector dialog box.
    2. Choose the Tree 2 symbol.
    3. Click OK to apply your symbol change.
  7. Click OK to apply all symbology changes and close the Layer Properties dialog box.

Set properties for the villages layer

Set general properties for the villages layer.

  1. Right-click the villages layer in the ArcMap table of contents and click Properties.

    The Layer Properties dialog box opens.

  2. On the General tab, change the Layer Name to Villages.
  3. Type the following for the Description: Boundaries of the villages of Osokopf.
  4. Set a minimum scale for drawing the villages layer.
    1. Under Scale Range, click Don't show layer when zoomed.
    2. Set the minimum scale to 1:10,000,000.
    3. Leave the maximum scale set to <None>.
  5. Click Apply to set the property changes you've made so far.

Set field aliases.

  1. Click the Fields tab.
  2. Assign aliases to the fields as follows:
    1. Choose village_name from the fields list, and type Name for the alias.
    2. Choose population from the fields list, and type Population (2010) for the alias.
  3. Click Apply.

Change the color used to symbolize the villages layer.

  1. Click the Symbology tab.
  2. Click Categories.

    Unique values is selected by default.

  3. Choose Name from the Value Field drop-down list.
  4. Click Add All Values.
  5. Choose a different color for each village.
  6. Once all your symbology changes are made, click OK to apply all your changes and close the Layer Properties dialog box.

Set properties for the streets layer

The recommended practice is to publish a separate map service for reference data. However, to reduce the number of steps needed to complete this tutorial, the streets layer will be part of your feature service even though it is only used as reference data.

  1. Follow the same procedures that you did for the other layers to set general properties, symbology, and field aliases for the streets layer.
  2. For the streets layer, you'll also want to set label properties.
  3. Click the Labels tab.
  4. Check Label features in this layer.
  5. Make sure the Label Field is set to the st_name field.
  6. Set a scale range for the labels.
    1. Under Other Options, click Scale Range.
    2. Click Don't show labels when zoomed, and set the minimum scale to 1:250,000.
    3. Click OK to close the Scale Range dialog box.
  7. Click Apply to apply your changes.

By default, HTML pop-up windows are enabled for all feature classes. However, you won't be editing the streets layer, so you can disable HTML pop-up windows.

  1. Click the HTML Popup tab in the Layer Properties dialog box.
  2. Uncheck Show content for this layer using the HTML Popup tool.
  3. Click OK to apply your changes and close the Layer Properties dialog box.

Publish a map service with feature access enabled

Now that your data and map are ready, you can publish a map service with feature access enabled.

  1. From the main menu in ArcMap, choose File > Share As > Service.
  2. In the Share as Service window, choose Publish a service. Click Next.
  3. In the Publish a Service dialog box, choose the publisher connection to ArcGIS Server you set up earlier in the tutorial.
  4. By default, the name of the map document is used for the service name. Instead of using the default, type TreeMaintenance.
  5. By default, services are published to the root folder (root) of ArcGIS Server. Accept the default location and click Continue.

    The Service Editor dialog box displays. Use Service Editor to choose what users can do with your feature service and take fine-grained control of how the server exposes your feature service.

  6. Click the Capabilities tab.
  7. By default, mapping and KML are enabled. Choose Feature Access. Enabling this option creates an associated feature service with your map service that allows clients to perform feature editing over the web.
  8. In the left pane of the Service Editor dialog box, click Feature Access and review the URLs to be used for the service.
  9. Under Operations allowed, uncheck Delete.

    Remember, you did not grant the connecting user privileges to delete features.

  10. In the left pane of the Service Editor dialog box, click Item Description and type the following:
    1. For Summary, type Service used to update the inventory of public trees.
    2. For Tags, type trees,maintenance,parks.
    3. For Description, type The Tree Maintenance feature service can be used to update the inventory of public trees.
  11. Click Analyze to be sure you will be able to publish your features.

    If any error messages are returned, you must correct those before you can publish. You can correct warning or informational messages, but you do not have to; they are provided to improve the performance and usability of your resultant service but are not required for the service to function. You can ignore warning 24041, since you can only use default templates when editing database data through a feature service.

  12. Click Publish Publish.

Your feature service is published to ArcGIS Server. Now you can consume your feature service in a web application and make edits.

Consume the feature service in a web application

In this section of the tutorial, you'll use the map viewer in ArcGIS Online to add, update, and edit features in your database over the web. You can deploy the map viewer directly through the ArcGIS Server Service Directory. It does not require any configuration or programming work to use the Map Viewer.

To get started, follow these steps:

  1. Open a web browser and browse to the ArcGIS Server Services Directory. Typically, this is located at http://gisserver.domain.com:6080/arcgis/rest/services. You can also access the Services Directory by opening the shortcut installed with ArcGIS Server.
  2. In the services list, click TreeMaintenance (Feature Server).
  3. On the TreeMaintenance (FeatureServer) page, the trees, streets, and villages feature classes are listed, as well as the supported operations for the feature service. Review these parameters to be sure they are correct.
  4. Click View In: ArcGIS Online map viewer at the top of the page.

    A new window (or tab) opens, displaying the map viewer.

  5. At the top of the Map Viewer, click Edit.

    The Add Features dialog box opens.

  6. Zoom in to different areas of the map and edit attributes of existing features. To edit an attribute:
    1. Click on a feature.

      The HTML pop-up window opens.

    2. Type a new value in a field. For dates, choose a date from the calendar.
    3. Click Close to apply your edits and close the HTML pop-up window.
  7. Also, add new features to the trees layer. To do this:
    1. Click either the d (deciduous) or e (evergreen) symbol in the Add Features pane.
    2. Click the point on the map where you want to place the tree.
    3. Select the tree you added and add attributes through the HTML pop-up window.
    4. Click Close to apply your edits and close the HTML pop-up window.
  8. Verify that edits to your features are reflected in your database.

    You can do this by switching back to your ArcMap document and refreshing the map display. The features you added to your web map appear in the map display. To see edits to the attributes, open the attribute table for the trees layer in ArcMap.

  9. If you want, you can sign in to ArcGIS Online and save your map.

Further reading

Now that you've successfully tested your feature service using the ArcGIS Online map viewer, you might want to consider how you can use and share your feature service in other ArcGIS clients. For example

  • Portal for ArcGIS also has a map viewer. You can share your feature service with a portal organization of which you're a member, and allow others to edit the feature service in the map viewer.
  • In ArcGIS Online and Portal for ArcGIS, you can create a customized web mapping application using the application templates. These templates can be deployed on your organization's web server.
  • ArcGIS API for JavaScript offers the most advanced web mapping capabilities and customization options. If you're comfortable programming using this API, you can create a rich editing experience for your users on the web by utilizing a feature service identical to the one you created in this tutorial.

Remember that web-based editing allows external users to add to and improve on your data. By exploring one or all of the ArcGIS clients listed above, you give yourself additional options that can help you tailor your editing scenario for a specific purpose, goal, or organizational strategy.