span8
span4
span8
span4
This article contains a number of writing geodatabase relationship classes examples.It includes demos for concepts covered inIntroduction to Working with Geodatabase Relationship Classes.Examples cover 1:M Relationship,Inserting into a M:N M:N or Attributed Relationship,and Advanced M:N Relationship.
For the following examples,it is assumed that the relationships have already been created in ArcGIS.This is required,as FME cannot create the relationships,but merely populate them.
* 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.TheComparison of FME readers and writers for SDE and Geodatabasearticle may also be useful.
Note: FME cannot create the relationship class in the target geodatabase.Either create the relationship class in ArcGIS/ArcPro,or use a template.
In this example,a 1:M relationship class translation will be demonstrated.As mentioned in the previous article,when dealing with a relationship class that is centered around a 1:M category,there is no intermediate table to keep track of these relationships.As such the relationships are bound to each other through the Primary and Foreign Keys.
Steps
1) Open the provided workspace ‘1ManyRelStart.fmwt' or open a blank workspace and add an ‘Esri File Geodb' reader.
If you opened the provided workspace,skip to step 3.
2) For the Esri File Geodb reader,navigate to the 1ManyRelStart.gdb.Select it and click OK.
Click OK again.The reader should be added,when asked select Parcels and Neighborhoods feature types.The reader should be added,when asked select Parcels and Neighborhoods feature types.
3) Add an AttributeCreator to each Feature class,with the new attribute being
‘geodb_feature_has_relationships' and the value being ‘yes'.
AttributeCreator parameters
4) Add an ‘AttributeRenamer' transformer after each ‘AttributeCreator'.This allows us to rename the ObjectID to the Geodb_oid for the origin and destination feature class.This is done to tell the writer which features are related.
AttributeRenamer parameters
5) Now it is time to add the writer to the workspace.Writers > Add Writer.Select ‘Esri File Geodb' as the format.
Select the Folder location where you would like to save the output geodatabase,and give the geodatabase a name.
点击参数,and set the Import XML Workspace Template to the supplied XML document: ‘XMLWorkspaceTemplate.XML'.This will allow you to write to a new geodatabase using a template that will provide the schema (includes the relationship class).
Note: Unless changing the output name after each complete translation,remove the XML template after the initial translation,to allow overwriting of the existing geodatabase.
Click Run.The workspace should successfully complete.Check the geodatabase in any ArcGIS product.You should be able to see which features are related to which using ArcMap.Here is an example for ParcelID: 144.It can be seen,as being related to the Kitsilano Neighborhood.
Sometimes,the data in the origin and destination feature classes already exists and you just want to add the relationships to the relationship table.You can do this if:
- the relationship is M:N or an attributed relationship
- the relationship class already exists in your geodatabase
To add the relationships,set the geodb_type to geodb_relationship or geodb_attributed relationship (if attributed) and the geodb_rel_origin_oid and geodb_rel_destination_oid to their respective OBJECTID's.This does require that FME reads the feature classes which participate in the relationship but does not involve writing them out again.Only the relationship table needs to be written to in this case.
Steps
From looking at the workspace,you can see two feature classes from a Geodatabase being read in.Before we continue let's take a look at the geodatabase we are reading from.
2) Open ArcCatalog and navigate to the folder holding the geodatabase contained in the
FMWT file.
From looking at the geodatabase we can see 2 tables (Structure and ADDRESS) as well as a relationship class(Structure_to_Address_rel).
Examining the source data in ArcCatalog
Here you can see that the relationship class has already been created.The view can be accessed through ArcGIS,and opening the properties of the relationship class.Right click relationship class > Properties.As a reminder,this is because relationship classes must be created in ArcGIS and then they can be populated through FME.
3) With the fact,this is a M:N relationship we need to ensure a few attributes are stored on features to be written to the relationship class.
The Origin and Destination oid,refer to the primary and foreign keys on the respective feature classes.In this example,we used the ObjectID as the value for the newly created origin/destination oid.It is important to note,that these newly created values,are not explicitly written to the geodatabase,but rather help FME process how the features are related to the relationship.In order to store these features to each feature class,we need to add an AttributeManager per feature class.This allows the user to create the required attributes mentioned previously.
Origin AttributeManager Parameters (Structure table):
Destination AttributeManager Parameters (Address table):
4) With the Primary and Foreign keys set,we can now merge the features using a FeatureMerger Transformer.This is going to merge the features using the field that is shared between the two feature classes,in this case,Structure.SiteID and Address.Remarks.
5) Lastly,another AttributeManager transformer is required to ensure that the features are recognized as a feature class.This is done by setting the geodb_type as ‘geodb_relationship',if you were dealing with an attributed relationship,the value would need to be set to ‘geodb_attributed_relationship'.
6) Lastly,the writer is added.It is here we write directly to the relationship table.In order to do this correctly,the values we set earlier:
Geodb_rel_origin_oid
Geodb_rel_destination_oid
Geodb_type
We do not have to set the Foreign Key values (StructureEventID and AddressEventID) because these will be populated by the writer as long as the above values have been mapped accordingly.
7) Run the workspace.The Relationship class should now be populated with the Foreign key values for AddressEventID and StructureEventId.
If beginning with 2 feature classes and you want to insert into a new geodatabase with a relationship class,a combination of the 1:M relationship workspace and updating a M:N relationship workspace are required to carry this task out.Again,it should be noted that the relationship class needs to be created in the destination prior to translation,via ArcGIS.An example of such a workspace can be seen in the ‘Many2ManyAdvanced' template.
Introduction to Working with Geodatabase Relationship Classes
Writing ArcGIS Geodatabase Attachments
Geodatabase Geodatabase行为:更新一个文件
Using the FeatureReader to Query a Geodatabase
Converting from Geodatabase Format
Writing ArcGIS Geodatabase Attachments
Converting to Geodatabase Format
Working with Geodatabase Domains: Creating A Coded Domain
Introduction to Working with Geodatabase Relationship Classes
Viewing and Inspecting Geodatabases
© 2019 亚搏在线Safe Software Inc |Legal