Publishing Spatial views as a Feature Access Service
The following Blog will take you through the process of using ArcMap 10.x to publish a spatial view as a Feature Access service.
What is a database view?
Database views are database elements that store SQL query statements that act like tables.
Views can be used to join tables together, similar to joins in ArcMap. But because the view is stored in the database, it can be used by many users in many map documents. For example, frequently Census data is stored in a table separate from the Census geographies feature class. Using a view, all users given access will be able to create analytical maps based on Census data without having to create a join.
Views can also be used to filter attributes either for ease of use or for permissions reasons. For example, if you are storing ownership information for parcels, that data may include personal identification numbers that not all staff should have access to. A view can be used to give a user access to some but not all of the fields in a table. In this case, the user should be granted access to the view but not the table.
Spatial views are database views that contain a single spatial column. They are useful in organising your spatial data with other attribute data in a predefined way, in the same database or another database. They are also READ-ONLY, hence spatial views cannot be edited via ArcMap.
Step 1: Create spatial database views
Before attempting this step ensure that you have a working connection to a SDE geodatabase and have two feature classes or a table and feature class that can be related to one another via a primary key and foreign key.
The following example is taken from the CMGD Configuring and Managing the Multiuser Geodatabase course.
- In ArcCatalog, right-click your Database connection for example gisowner@Naperville connection, and choose New > View
- Enter a descriptive View name ideally one which includes the names of the tables being linked.
- Enter the View Definition this is a SQL statement that controls the output created in terms of the columns and association between the tables/feature classes.
In the example below Store_ID is the primary key of the Stores feature class and foreign key in the Store Revenue table without these keys the View cannot be created
SELECT Stores.OBJECTID, Stores.Name, Stores.Address, Stores.Shape, Store_Revenue.Revenue | |||||||
FROM Stores | |||||||
LEFT JOIN Store_Revenue | |||||||
ON Stores.Store_ID = Store_Revenue.Store_ID |
Step 2: Test database views
Now that we have created a database view, we want to test it before publishing it.
- Open ArcMap
- In the Catalog window, connect to your Database connection containing the spatial view.
- Note that the views have icons that look like tables with a little box. This is because ArcMap has not yet investigated the views enough to determine what geometry type is being used.
4. Drag the View into the map
ArcMap will create a query layer based on the view to display in the map.
- Check the OBJECTID field as the unique identifier field, and click Finish
- View the attribute table for the layer
All the fields specified in the database view definition are available in the layer.
To be able to use our Spatial View on ArcGIS Online in Collector or just within a Web map we will need to publish this view as Feature Access service.
Process for adding Spatial View as Feature Access
- File -> Share As-> Service
- Choose Publish a service
- Click Next
- Must create without feature access checked (i.e. just Mapping)
- Choose a connection
- Enter a Service name
- Click Next
- Select a folder to publish the service to
- Click Continue
- Choose Capabilities and ensure Mapping is the only box checked
- Click the Analyze button to check for any issues with the service before publishing.
- Click Publish
- From ArcCatalog->GIS Servers
- Locate the GIS Server and Service you have published
- Right-click the service and select Service Properties
- Choose Capabilities and check Feature Access.
- Check Service workspace to ensure registered to SDE.
You will now be able to view the features with all the associated data from the view in your Feature access service within ArcMap, online in Web maps and in Web apps like Collector.
By Nathaniel Meyer
Reblogged this on Everything is Spatial.
I am curious why you can’t publish the spatial views that you are intending on using as reference data in a separate map service that you would overlay with feature service layers in the web map to be consumed by collector.
If you are using Collector for Off-Line data collection, map services are not supported. Only feature services can be taken off-line.
Is it possible to publish a spatial view to arcgis online? Even with third party tools? I want a hosted solution to this problem.
I am curious as to how to publish a view (query layer) as a feature service and be able to consume it in Operations Dashboard. Whenever I use the workflow described in this blog, or any other variations, I do not have full access to the widgets in dashboard. Only when I make a feature class am I able to apply summaries, guages, and the like in dashboard.
Can I perform the Editing on the Published Feature Service with Feature access & CREATE , UPDATE. and DELETE Operations allowed? Provided , I am using Spatial View as part of my Feature Service.
Ahh so helpful! Wasn’t able to find this anywhere else 😀