FME Version
Files
-
- 40 KB
- Download
Introduction
The ArcGIS Online Feature Service writer has support for three modes: insert, update, and delete. This mode can be set either at the feature type level (to apply to every feature written to the corresponding feature service) or at the feature level using the fme_db_operation attribute.
This writer mode setting works in much the same way on this writer as it does for any of the database writers in FME as documented here: Database Writer Mode One important difference with the ArcGIS Online Feature Service writer, however, is that it does not allow for manually selecting the attribute to be used as a unique identifier for making updates and deletes. Updates and deletes are done using an Object ID field that is automatically added when a new Feature Service is created. Any features being sent to the writer to be updated or deleted, therefore, must have this field set on them.
To attach the Object ID field to your features, you can add an ArcGIS Online Feature Service reader into your workflow (the FeatureReader transformer can also be used for this). In this example after the ChangeDetector, a FeatureJoiner is used to merge the Object ID to the updated features.
The attached workspace shows an example of how to write updates to an ArcGIS Online Feature Service. This same method is used for inserts and deletes as well.
Step-by-step Instructions
Part 1: Writing Data to ArcGIS Online
1. Open FME Workbench
Open FME Workbench and click New to create a new workspace.
2. Download the PlayingFieldStatus.zip file
3. Add a Shapefile Reader to the Canvas
Drag and drop the PlayingFieldStatus.zip to the canvas. This will add a reader to your workspace. Since the file is zipped FME will not know which format to select. In the text box beside Format, write Shape and select Esri Shapefile when it appears. Click OK to add the reader.
4. Inspect the Data
Click on the reader on the canvas. Then, click on the Run button above it. This will read in the data.
5. Add an ArcGIS Online (AGOL) Feature Service Writer
Select the canvas again and start type ArcGIS, then scroll down and select the ArcGIS Online (AGOL) Feature Service writer.
Next, select Parameters on the left-hand side. First, select an ArcGIS Online connection. If you do need to create a new ArcGISOnline connection, you can create a new connection by selecting Add Web Connection. Next, create a name for your connection and select Authenticate. Enter your ArcGISOnline username and password and select Sign In.
Then for Feature Service type PlayingFields. Finally, select OK to close the dialogue. Click OK again to close the Writer.
Connect the reader and writer together.
6. Write the Data to ArcGIS Online
Select Run to write the data to ArcGIS Online. Log into ArcGIS Online to confirm that the data has been written out.
Part 2: Detecting Changes and Uploading ArcGIS Online
1. Open up the starting workspace UpdateArcGISOnlineStarting in FME Workbench
2. Add an ArcGIS Online Reader to the workspace
Select the canvas and start type ArcGIS, then scroll down and select the ArcGIS Online (AGOL) Feature Service reader.
Select Parameters, then, select the ArcGIS Online Connection previously created. Select the ellipsis next to FeatureService and navigate to the PlayingFields feature service just created.
Next, select the ellipsis next to Layers and select the PlayingFieldsStatus. Click OK. Then, click OK again.
Attach the reader to the Original port on the ChangeDetector. Next, attach the reader to the Left port on the FeatureJoiner.
3. Review the Transformers
Click on the cogwheel of the ChangeDetector, this will open up the parameter of the ChangeDetector. For more information on ChangeDetection in FME see Change Detection.
The ChangeDetector here is using the RecordID to determine which features have been updated. A ChangeDetector can be used without a key attribute but it will not be able to determine if an individual feature has been updated.
The ChangeDetector is also set to Check Attributes. Users have the ability to set which attributes to check and in this case, it is only checking the few selected attributes. The ObjectID is not included because the ObjectID is not found in the JSON file.
4. Run the workspace and inspect the data
Click the Run button with feature caching enabled to inspect all the features in the workspace.
First, click on the Output of the AttributeManager. The AttributeManger is used to ensure the attribute names match the output from the ArcGIS Online Feature Service Reader. This is essential for the ChangeDetector to pick up the changes from the original dataset.
Next, select the Updated port in the ChangeDetector to view the output in Visual Preview. Notice a new attribute is added to the output of the ChangeDetector, it is the fme_db_operation. This attribute is used by the writer to determine how to handle the feature.
Finally, the FeatureJoiner is used to add the Object ID to the features that are updated. Inspect the Joined port to verify the Object ID is added.
The FeatureJoiner is set to Attribute Conflict Resolution is set to Use Right. This will ensure the updated features will be carried through the join.
5. Add the ArcGIS Online Writer
Select the canvas again and start typing ArcGIS, then scroll down and select the ArcGIS Online (AGOL) Feature Service writer.
Next, select Parameters on the left-hand side. First, select an ArcGIS Online connection.
Then for Feature Service type PlayingFields. Finally, select OK to close the dialogue. Click OK again to close the Writer.
Attach the Joined port to the ArcGIS Online writer.
Next, open up the parameters on the writer. Typically, the Write Mode would determine if features are Inserted, Deleted, or Updated. However, the fme_db_operation will override whatever is set in the fme_db_operation.
6. Write to ArcGIS Online and check the output
Click the Run button again to update the features in ArcGIS Online. Next, check the output in ArcGIS Online to ensure that the records were updated.
Data Attribution
The data used here originates from open data made available by the City of Vancouver, British Columbia. It contains information licensed under the Open Government License - Vancouver.
Comments
0 comments
Please sign in to leave a comment.