FME Version
Files
Introduction
In FME 2021.2, we have added a new reader and writer to allow you to work with Esri Knowledge in FME. In this tutorial, we’ll walk through how to create relationships between the entities we uploaded in the previous tutorial.
Requirements
- FME Form 2023.0 +
- ArcGIS Pro 3.1+
- ArcGIS Enterprise 11.1+
- Completion of Creating and Adding Data to Esri Knowledge Graph tutorial
Step-by-step Instructions
Part 1: Join Roles and Movies to Create RolePlayed Relationship
1. Read in Roles CSV
In FME Workbench, start a blank workspace. Add a Comma Separated Value (CSV) reader to the canvas and browse the file roles.csv (see attached).
Click on the "Parameter..." button,
Under Dataset Parameter, Switch the value of the Feature Type Name(s) to From File Name(s) and Click OK.
2. Inspect the Data
Click on the roles reader feature type to open the popup menu, then click the Inspect Source Data button to view the data in Visual Preview.
In Visual Preview, you can see that the table contains the attributes personID and movieID. We will use these attributes to join with the Knowledge Graph entities created in the previous tutorial.
3. Read in Esri Knowledge Graph
If you haven’t completed the previous tutorial, please pause here and complete that one first before proceeding.
Add an Esri Knowledge reader to the canvas, and select the MovieDatabase_<yourname> Connection.
Click on the "Parameters" button
From Table, click on the ellipsis(...)
In the Select Feature Type dialog, select "Country", "Movies", and "Persons" tables.
4. Update Person Attribute Names
Add an AttributeManager to the canvas after the "Persons" feature type. Open the AttributeManager transformer and perform the following operations.
Remove the attributes objectid and name.
Rename the attributes as below:
id --> personID
globalid --> personGlobalID
5. Join Roles and Persons
Add a FeatureJoiner to the canvas and connect the Left input port to the roles reader feature type and the Right input port to the AttributeManager.
In the parameters, set the Join On to personID for both Left and Right.
6. Update Movies Attribute Names
Add an AttributeManager to the canvas and connect it to the Movies reader feature type.Open the AttributeManager transformer and perform the following operation
Remove the attributes objectid, title, and year
Rename the attributes as below:
id --> movieID
globalid --> movieGlobalID
7. Join Movies and Persons
Add another FeatureJoiner to the canvas and connect the Left input port to the Joined output port on the other FeatureJoiner, then connect the Right input port to the AttributeManager_2 (coming from the movies reader feature type).
In the parameters, set the Join On to movieID for both Left and Right.
8. Prepare Data to Create a Relationship
This step will prepare the two key attributes to define the relationship between entities, Movies, and Persons. Add another AttributeManager to the canvas and connect it to the Joined output port on the FeatureJoiner_2. Open the AttributeManager transformer and perform the following operations.
Remove the following attributes movieID, personID, movieID, and country
Rename the attributes as below.
personGlobalID --> kg_origin_id
movieGlobalID --> kg_dest_id
NOTE: Please ensure that the attribute names are correct, as these are case-sensitive
9. Write RolePlayed Relationship
Add an Esri Knowledge writer to the canvas and select the MovieDatabase_<yourname> Connection. Set the Feature Class or Table Definition to Automatic, then click OK.
In the Feature Type dialog, set the Feature Class or Table Name to RolePlayed and select kg_relationship as Geometry.
Connect the RolePlayed writer feature type to the AttributeManager_3 coming from the second FeatureJoiner.
Part 2: Join Country and Movies to Create MadeIn Relationship
10. Update Country Attribute Names
Add an AttributeManager to the canvas and connect it to the Country reader feature type.Open the AttributeManager transformer and perform the following operations.
Remove the attribute objectid
Rename the attributes as below:
globalid --> countryGlobalID.
11. Join Country and Movies
Add another FeatureJoiner to the canvas, connect the Left input port to the AttributeManager coming from the movies reader feature type, then connect the Right input port to the AttributeManager coming from the country reader feature type.
In the parameters, set the Join On Left to country coming from the Movies entity, and Right to name coming from the Country entity.
12. Prepare Data to Create a Relationship
In this step, prepare the data to create a relationship between two entities, "Movies", and "Country". Add another AttributeManager to the canvas and connect it to the Joined output port on the FeatureJoiner_3. Open the AttributeManager transformer and perform the following operation
Remove attributes movieID, name
Rename the attributes as below.
movieGlobalID --> kg_origin_id
countryGlobalID --> kg_dest_id
13. Write MadeIn Relationship Out to Esri Knowledge Graph
Click the Writers drop-down on the top menu bar and select Add Feature Type.
In the Add Feature Type dialog, set the Feature Class or Table Name to MadeIn, then change the Geometry to kg_relationship.
Connect the MadeIn writer feature type to the AttributeManager_5.
Part 3: View Output Relationships in ArcGIS Pro
14. Run the Workspace and View Output in ArcGIS Pro.
Run the workspace, then view the output in ArcGIS Pro. In ArcGIS Pro, click on Investigation, then click on the RolePlayed relationship and view the table.
Next, click on the MadeIn relationship and view the table.
To view all the relationships together, right-click on Relationship Types > Add To New > Link Chart. Now you can view the newly created relationship in the Link Chart. Notice that Persons are connected to the Movies entity by connection RolePlayed and countries by the MadeIn relationship.
Comments
0 comments
Please sign in to leave a comment.