Difference Between Graphic Layer and Feature Layer

5721
4
04-04-2013 04:26 AM
Santosh_Pavan_KumarNukala
New Contributor III
Namaste/Hola/Hi,

I am currently trying to provide a facility to draw lines, polygons, plot custom drawn symbols as PictureMarkerSymbols.. into a layer. Features like creation of new layer, adding geometries and symbols. saving the layer and setting active layer.. will need to be provieded.
Currently I have started my work plotting symbols on a graphic layer.. but I want to know if there are any disadvantages of using a Graphic Layer over FeatureLayer consisting of feature classes .. I would like to know the difference between Graphic Layer and a Feature Layer.
Is there any problem with saving geometries as graphic layers as .LYR files  ?? and re-using them later considering I dont have much information to store as part of tables.

Gracias/ Thanks in Advance
Santosh
0 Kudos
4 Replies
AlexanderGray
Occasional Contributor III
ok when posting question you should provide more information.  First what product your using, arcgis desktop, server, engine and which version?  Secondly within that product what are you using?  In desktop it could be ArcMap, ArcCatalog, Globe, Scene..   In Engine, which control?  In server which API?  Then which development environment (.net, java, python) and the type of customization (add-ins, extensions. etc.)

I am going to take a leap and assume it is desktop customization of ArcMap 10.x with .net and add-ins or extension code. 

The ArcMap graphics layer is stored in the map document (mxd.)  It is unique to this document and cannot be shared and used much.  It can contain multiple geometry types (line, point, polygon, text, etc.) but no attribute information.  As such it is not GIS data because it contains no attributes.  GIS data is stored in a database of some sort, even if the database is a flat file.  It is a geometry with geographical coordinates and a series of attributes that describe it in some what.  In ArcGIS, GIS data is stored in a geodatabase or shapefile (usually.)  In the esri world, a feature class is a set of geographic features that share the same type (line, point, polygon, etc.), the same coordinate system (geographic, lambert, etc.)  and the same attributes and are stored together in the same file (usually a set of related files) or data table (usually a set of related tables.) 
A layer in the map is a reference to a data source, the feature class and symbology, sub -queries and other information on how to draw the feature class on the map.  A layer files (.lyr) is the layer in the map serialized to a file, it does not contain any features, only information on where the feature class is located and how to draw it.

I can't tell you what to do because I don't know your requirements, that is up to you to figure out.  Saving geometries in graphic layers is not very useful.  Saving them in .lyr files is impossible.  You should look into saving them into feature classes in a geodatabase.
0 Kudos
Santosh_Pavan_KumarNukala
New Contributor III
ok when posting question you should provide more information.  First what product your using, arcgis desktop, server, engine and which version?  Secondly within that product what are you using?  In desktop it could be ArcMap, ArcCatalog, Globe, Scene..   In Engine, which control?  In server which API?  Then which development environment (.net, java, python) and the type of customization (add-ins, extensions. etc.)

I am going to take a leap and assume it is desktop customization of ArcMap 10.x with .net and add-ins or extension code. 

The ArcMap graphics layer is stored in the map document (mxd.)  It is unique to this document and cannot be shared and used much.  It can contain multiple geometry types (line, point, polygon, text, etc.) but no attribute information.  As such it is not GIS data because it contains no attributes.  GIS data is stored in a database of some sort, even if the database is a flat file.  It is a geometry with geographical coordinates and a series of attributes that describe it in some what.  In ArcGIS, GIS data is stored in a geodatabase or shapefile (usually.)  In the esri world, a feature class is a set of geographic features that share the same type (line, point, polygon, etc.), the same coordinate system (geographic, lambert, etc.)  and the same attributes and are stored together in the same file (usually a set of related files) or data table (usually a set of related tables.) 
A layer in the map is a reference to a data source, the feature class and symbology, sub -queries and other information on how to draw the feature class on the map.  A layer files (.lyr) is the layer in the map serialized to a file, it does not contain any features, only information on where the feature class is located and how to draw it.

I can't tell you what to do because I don't know your requirements, that is up to you to figure out.  Saving geometries in graphic layers is not very useful.  Saving them in .lyr files is impossible.  You should look into saving them into feature classes in a geodatabase.




Thanks for the reply.. I am currently developing a stand alone application on ArcGIS Engine Only using arcobjects 10.1 in Visual C# - Extending ArcObjects.. not as add-in. I have a requirement to facilitate the user to draw basic geometries like line, point polygon, circle, triangle, ellipse, Symbols  on MapControl and save them as Layers.. as told earlier i have started my work by drawing geometries on graphics layer and saved them in .lyr files using
                  //create a new LayerFile instance
                  ILayerFile layerFile = new LayerFileClass();
                  //create a new layer file
                  layerFile.New(saveFileDialog.FileName);
                  //attach the layer file with the actual layer
                  layerFile.ReplaceContents((ILayer)i_Layer);
                  //save the layer file
                  layerFile.Save();
I have typecasted IGraphicLayer to ILayer and saving them into .lyr files. Please let me know if there is something wrong as you stated in your post "Saving them in .lyr files is impossible". Secondly I have assigned spatial reference to the graphic layers, so next time I open the graphic layer.. it displays according the spatial reference. Third I have not much attribute data pertaining to the geometries to be stored. In case I want to store any info pertaining to IElement( i.e IGraphicElement like ILineElement, IMarkerElement .. )  I can store them in xml and save them into IElementProperties.CustomProperty for that particular IElement ( Symbol, Line, Polygon etc). Also for your info.. my user is not aware of saving geometries in separate feature Classes for each geometry type because he has not much GIS knowledge. All he knows is drawing some basic geometries on mapcontrol and save them into as a vector layer and open and view the layer for future use. Also would like to do basic operations like move, select, copy, cut, paste features. Please share you view or any more info on this.
Meanwhile I would try to implement as suggested by you in feature classes in geodatabase.

Regards,
Pavan
0 Kudos
AlexanderGray
Occasional Contributor III
Ok, I was unclear, it is impossible to save features to a layer file.  Graphics are a different thing.  I was also unaware you are using engine in which you do things a little differently. 

Ultimately you must advise your client what is best for them, I don't know the details of their application but you asked the forum for an opinion and I will give you mine.

"store them in xml and save them into IElementProperties.CustomProperty for that particular IElement"
You can do that but the question is why?  You would be effectively building your own custom database model.  You wouldn't be able to leverage all the esri built in tools to take advantage of it.  The only advantage I could see in using a graphic layer is the possibility of storing different geometry types in the same layer.  You can actually use an annotation feature class for that, since you can store an IElement in an annotation and still have it in a geodatabase with the attribute table etc.  Using the standard esri storage, you open up the possibility of using esri built in editing functions, display, identify, etc. as well as the ability to share data with other esri applications.  There are also built in exporters to other formats to use in other software.  There is a little more overhead in setting up the geodatabase and editing it according to esri procedures but I think they are worth it.  There are even data recovery and cleaning tools for geodatabase that you wouldn't have for your custom graphics layer.
0 Kudos
Santosh_Pavan_KumarNukala
New Contributor III
Ok, I was unclear, it is impossible to save features to a layer file.  Graphics are a different thing.  I was also unaware you are using engine in which you do things a little differently. 

Ultimately you must advise your client what is best for them, I don't know the details of their application but you asked the forum for an opinion and I will give you mine.

"store them in xml and save them into IElementProperties.CustomProperty for that particular IElement"
You can do that but the question is why?  You would be effectively building your own custom database model.  You wouldn't be able to leverage all the esri built in tools to take advantage of it.  The only advantage I could see in using a graphic layer is the possibility of storing different geometry types in the same layer.  You can actually use an annotation feature class for that, since you can store an IElement in an annotation and still have it in a geodatabase with the attribute table etc.  Using the standard esri storage, you open up the possibility of using esri built in editing functions, display, identify, etc. as well as the ability to share data with other esri applications.  There are also built in exporters to other formats to use in other software.  There is a little more overhead in setting up the geodatabase and editing it according to esri procedures but I think they are worth it.  There are even data recovery and cleaning tools for geodatabase that you wouldn't have for your custom graphics layer.






Thank you for the reply. Now that I am trying to create a geodatabase and manage layers.. I am putting down my approach to create features and store them in different feature layers in geodatabase.. Please add to this
1. Create Geodatabase
2. Use IWorkspaceEdit to Edit the geodatabase - IWorkspaceEdit::StartEditing.
3. Create a feature dataset (if required) and apply IDatasetEdit ( IDatasetEdit only has IsBeingEdited function. Is there any function to Specify a dataset is to be edited)
4. Create a Feature Layer / Get the existing feature layer name (IFeatureLayer)
5. Create a Feature Class (Point / Polyline/ Polygon) / get the existing feature class if already present
6. Create the geometry.
7. Store the geometry in the feature
8. Store the feature  IFeature::Store
9. Dont know if there is any interface to stop the DatasetEdit.
10. IWorkspaceEdit::StopEditing

Assuming the user Creates a new feature layer or want to modify the existing feature layer, the user selects a layer from combobox list of layer names and starts drawing on the mapcontrol and clicks on Save Feature Layer, does the feature layer gets saved with all the different geometries drawn or a save is required for each feature class (i.e Point , Polyline etc) separately.
Please let me know if the above mentioned steps will serve the purpose of creating and managing the feature layers. kindly request you to mention the appropriate interfaces or class names if you remember.. looking forward to your reply soon.

Regards,
Pavan
0 Kudos