span8
span4
span8
span4
The above video covers theory covered inIntroduction to Working with Geodatabase Relationship Classes,and the example covered in this article.
Geodatabase attachments are a way to connect additional information to features in the form of a specific file (i.e.an image,a PDF,or a text document).As theArcGIS documentationmentions:
"For example,if you have a feature representing a building,you could use attachments to add multiple photographs of the building taken from several angles,along with PDF files containing the building's deed and tax information."
You can attach one or more files to a feature and then retrieve the information using query tools in ArcGIS.
* The ESRI File Geodatabase reader/writer used/mentioned in this article requires a licensed version of ArcGIS.For more information on required ArcGIS license levels,please seeRequired ArcGIS License Types for FME Geodatabase Formats.
Attachments and FME
Because attachments are handled by a relationship class,FME is capable of easily creating this sort of connection.However,the attachments table have be created in ArcGIS beforehand.The key is to read the contents of the file to be attached into an attribute and write that attribute to a DATA field in the attachments table.The relationship class must be created in ArcGIS beforehand.The key is to read the contents of the file to be attached into an attribute and write that attribute to a DATA field in the attachments table.
An AttributeFileReader transformer or the Data File reader can be used to read the contents of a file into an attribute.In the case of the Data File reader,be sure to set the reader parameter "Read Whole File at Once" to Yes.reader can be used to read the contents of a file into an attribute.In the case of the Data File reader,be sure to set the reader parameter "Read Whole File at Once" to Yes.
The exercise to follow will demonstrate how to write to a relationship class while adding attachments.
attachments.zip
Note: the template files provided in the download will allow us to write to a geodatabase that already has a feature class,attachment table,and the relationship set up.Normally this would have to be set up in ArcGIS beforehand.When using an XML Template file,the workspace will only be able to run once,all future translations will require the template to be removed from the writer.
In the image below,we see a visualization of our source GML file containing Fire Hall,亚搏国际在线官网Community Centre,and Library data in the Data Inspector.
Fire Halls,亚搏国际在线官网Community Centres,Libraries in geographic markup language (GML)
In the image below,we see a visualization of the system paths where photographs and PDF files that will be used as attachments are located.
Paths to photograph and pdf file attachments in the PointsOfInterest folder.
For this exercise,a beginning workspace has been provided,.
You'll immediately notice that the workspace is already partially set up.The source and destination schema objects are already in place and ready to read from/write to.There are also a few transformers already in place to map the Reader and Writer schema.The only things missing are the transformers required to set up the relationship - adding them is the main task for this exercise.However,we'll be helped by a number of predefined transformers that have been set up and copied to a bookmark.
Predefined transformers
1.Download Attachments Folder
As mentioned above,relationship classes cannot be created through FME.As such,it is necessary to determine the relationship between your features prior to running the translation.For this demo,the destination Geodatabase with the needed empty feature class and defined relationship has been provided (please see attachments.zip in the download section).Download and extract this zip folder as it not only contains the needed destination Geodatabase,it also contains the necessary files that will be used as attachments during the 亚搏在线workflow.
2.Read Source Data
Fire Hall,亚搏国际在线官网Community Centre,and Library geometry are read from the source Points of Interest Geographic Markup Language file using the GML reader.
The Directory and File Pathnames reader is used to read the system path to the images and PDF files that will be used as the attachments.Though the readers have already been added as part of the beginning workspace,make sure that the source parameter for each reader is pointing to the proper dataset.
3.Setup Source Attributes to Match Destination Schema
Some additional work is required in order to modify attributes for each of the Source Datasets so that they match the destination schema.
ForFireHalls,this means renaming the following attributes with the AttributeManager:
Input Attribute | Output Attribute | Attribute Value | Action |
Name | Description | Rename | |
HallNumber | Name | Rename | |
Address | Street | Rename |
Rename FireHalls attributes
For亚搏国际在线官网CommunityCentres,this means modifying the following attributes with the AttributeManager:
Input Attribute | Output Attribute | Attribute Value | Action |
CentreName | Name | Rename | |
CentreAddress | Street | Rename | |
CentreURL | Website | Rename | |
DocumentName | Description | Rename | |
PostalCode | unknown | Set Value |
Rename 亚搏国际在线官网CommunityCentres attributes
ForLibraries,this means modifying the following attributes with the AttributeManager:
Input Attribute | Output Attribute |
Attribute Value | Action |
LibraryName | Name | Rename | |
LibraryAddress | Street | Rename | |
LibraryURL | Website | Rename | |
DocumentName | Description | Rename | |
PostalCode | unknown | Set Value |
Rename Libraries attributes
4.Add Relationship Related Attributes
FME needs to be told that the features participate in a relationship class.To do this,we will use an AttributeCreator transformer.This transformer can be found in the "Transformers to Use" bookmark.Two instances of the AttributeCreator are needed given that there are two streams of data (the Points of Interest and the Attachments).
Copy/move this transformer into both of the light brown bookmarks entitled "4.Add Relationship related attributes".For the Points of Interest (FireHalls,亚搏国际在线官网CommunityCentres和图书馆功能类型),connect all three existing AttributeManager transformers to the new AttributeCreator.For the paths to the attachment files (PATH feature type),simply connect the Directory and File Pathname reader to the second AttributeCreator.
Workspace after adding and connecting the predefined AttributeCreator.
Open the properties dialog for one of the AttributeCreators and you'll see that all it does is set a format attribute called geodb_feature_has_relationships.The attribute,geodb_feature_has_relationships set to yes,is all that is required to tell FME that these features participate in a relationship.
Attribute geodb_feature_has_relationships set to yes
Each set of features also needs an ID number.Assuming that one does not already exist,we can create one with a Counter transformer.Again,we need one instance per set of features,and there is already a pre-defined transformer in the "Transformers to Use" bookmark.Move/copy the Counter transformer from the bookmark and connect one instance of it after each of the AttributeCreator transformers from the previous step.Inspect the Counter parameters and you'll find it is creating an attribute called geodb_oid.
Counter creating an ID attribute,geodb_oid
5.Connect Schema
At this point,features are ready to write to the Geodatabase,so you can create connections from the Counter transformers to the existing AttributeRenamer transformer and PointsOfInterest__ATTACH feature type.
Complete data flow
Open the parameters dialog for the AttributeRenamer_POIType transformer.Here we need to rename the fme_feature_type attribute to POIType,the reason for this to ensure the name of the feature is source feature is maintained in an attribute.In this case,we will have Firehalls,亚搏国际在线官网Community Centres and Libraries still.The parameters should be set as follows:
6.Add Relationship Related Attributes
We now need to define the relationship between the two sets of features,and we do this by creating origin and destination ID numbers.Again,we need one instance per set of features,and there are already two pre-defined transformers we can use.Move the two AttributeRenamer transformers (i.e.AttributeRenamer_Origin and AttributeRenamer_Destination) from the "Transformers to Use" bookmark into the yellow,centre bookmark.Make a duplicate connection from the Points of Interest (FireHalls,亚搏国际在线官网CommunityCentres and Libraries feature types) Counter to AttributeRenamer_Origin,and another from PATH Counter to AttributeRenamer_Destination:
Workspace after adding relationship related attributes.
Check the parameters for each AttributeRenamer.You'll see that each is renaming the newly created ID to either an Origin or Destination ID.This is what FME will use to write the relationship class.
7.Build Relationship Information
Add a FeatureMerger transformer.This is how the relationship will be built.Connect the Origin AttributeRenamer to the Requestor port and the Destination AttributeRenamer to the Supplier.Open the parameters dialog for the FeatureMerger.Set the Requestor attribute to be Name and the Supplier attribute to be path_rootname.
The result of this is that data gets merged where the filename (path_rootname) of the attachment matches the name of the Point of Interest feature (Name).
For example,if I have a point of interest called "Big Tall Statue" (Origin ID = 13) and there is a file named "Big Tall Statue.jpg" (Destination ID = 22) then the result will be a single feature ("Big Tall Statue",Origin ID = 13,Destination ID = 22) that defines a relationship between those features.
When writing this to the Relationship Class,it will define the relationship between these features in the PointsOfInterest and PointsOfInterest_ATTACH tables.
The other outstanding issue to take care of is the case where there are multiple attachments for a particular point of interest.So,while still in the FeatureMerger parameters dialog,change "Process Duplicate Suppliers" to Yes and enter Docs as the list to create.
FeatureMerger parameters
Now when the workspace is run,for features with multiple attachments,multiple files are stored in a list,like so:
Docs{0}.path_filename
Docs{0}.geodb_rel_destination_oid
Docs{1}.path_filename
Docs{1}.geodb_rel_destination_oid
What we now need to do is explode this list into individual features – so that there is a relationship record for each attachment – and this is done with a ListExploder transformer.Insert a ListExploder transformer after the FeatureMerger and connect the Merged output port of the FeatureMerger to the input of the ListExploder.Open the ListExploder parameters dialog and select Docs{} as the list to explode:
ListExploder parameters
Each feature that gets sent to a FME Writer should have an attribute indicating the geometry type.In most cases you – the user – never need to know about this attribute and don't need to set it.However,here these features will be currently flagged as point features (i.e.points of interest) and we need to tell FME they are actually non-geometry,relationship features.So,add an AttributeCreator transformer after the ListExploder and connect the AttributeCreator to the Elements port of the ListExploder.
Open the parameters dialog of the AttributeCreator and use it to create a new attribute called geodb_type.It should be given a value of geodb_relationship.This will tell FME to write these to the Geodatabase as relationship features.
AttributeCreator parameters following the List Exploder.
You can now connect the AttributeCreator_3 to the PointsOfInterest__ATTACHREL Writer feature type.
8.Setup the fields in the Attachment Table
At the moment we're writing a relationship between features,but the destination features (attachments) are currently just a reference to a file,not the file itself.We need to use these references to read the attachment file contents.A pre-defined section of workspace will do this for us.Look for the ‘Setup the fields in the attachments table' bookmark.
Examine what these transformers are doing.The AttributeCopier is doing some basic schema mapping while the StringConcatenator is setting an attribute to tell ArcGIS about the type of file being attached.Finally,the AttributeFileReader reads the content of the attachment,using the filename obtained from the original PATH Reader.
Connect the contents of this bookmark into the main workspace (i.e.into the connection between the attachments Counter and the Writer feature type (PointsOfInterest__ATTACH)).Remove any existing connection to PointsOfInterest__ATTACH.
9.Write Relationship Data & Attachments
At this point,we should check (in the Navigator window) that the transaction type is set to Edit Session.
Note: the template files provided will allow us to write to a geodatabase that already has a feature class,attachment table,and the relationship set up.Normally this would have to be set up in ArcGIS beforehand.When using an XML Template file,the workspace will only be able to run once,all future translations will require the template to be removed from the writer.
Relationship classes must be written to in an edit session.Now save and run the workspace (make sure ArcGIS and Data Inspector is closed to avoid any data lock issues).When you inspect the PointsOfInterest features in ArcGIS (remember they are in the Feature Dataset called City) query them with the HTML PopUp tool.
PointsOfInterest features in ArcGIS queried with the HTML PopUp tool
Introduction to Working with Geodatabase Relationship Classes
Writing Geodatabase Relationship Classes
I have tried the tutorial and Im testing it with our data and the wrong photos are being attached to the features.any idea what could the issue be,is there a sort order for the 亚搏在线workflow .
any help will be appreciated
Thank you
Hi@adi
Apologies for the delay in getting back to you.I personally have not tested building relationships when the relationship is based on GlobalID's.I suspect if this functionality is supported it will be in FME 2019.
In terms of the data and attachments being mixed up,this suggests that the Joining of your two features is not quite configured correctly.If you can try and test with a single attachment and its target feature,and try to get them to join correctly(this is how the relationship will be populated) that should solve the issue.This takes place in the FeatureMerger.Also to note,what type of relationship class is present?As outlined in the following article,some relationship classes do not require writing to the Relationship table.See Relationship Background section here:https://knowledge.亚搏在线safe.com/articles/28340/working-with-geodatabase-relationship-classes-atta.html
If still having trouble,if you are able to post a sample of your data/workspace I could take a look.
Converting from Geodatabase Format
Converting to Geodatabase Format
Working with Geodatabase Domains: Creating A Coded Domain
Introduction to Working with Geodatabase Relationship Classes
Viewing and Inspecting Geodatabases
Working with Geodatabase Subtypes: Creating A Subtype
Tutorial: Getting Started with Geodatabase
Writing Geodatabase Relationship Classes
Working with Geodatabase Field Aliases: Altering Alias Values
Working with Geodatabase Metadata: Writing/Updating Metadata
© 2019 亚搏在线Safe Software Inc |Legal