Create element classes in element Datasets

Source: Internet
Author: User
Public Ifeatureclass ifeaturedataset _ createfeatureclass (ifeaturedataset featuredataset, string nameoffeatureclass ){ // This function creates a new feature class in a supplied feature dataset by building all of  // Fields from scratch. ifeatureclassdescription (or iobjectclassdescription if the table is    // Created at the workspace level) can be used to get the required fields and are used    // Get the instanceclassid and extensionclassid.  // Create new fields collection with the number of fields you plan to add. must add at least two fields  // For a feature class: Object ID and shape field. Ifields fields = New Fieldsclass (); ifieldsedit fieldsedit = (ifieldsedit) fields; fieldsedit. fieldcount_2 = 3; // Create Object ID field. Ifield fielduserdefined = New Field (); ifieldedit fieldedit = (ifieldedit) fielduserdefined; fieldedit. name_2 = "Objectid" ; Fieldedit. aliasname_2 = "Object ID" ; Fieldedit. type_2 = esrifieldtype. esrifieldtypeoid; fieldsedit. set_field (0, fielduserdefined ); // Create shape field. Fielduserdefined = New Field (); fieldedit = (ifieldedit) fielduserdefined; // Set up geometry definition for the shape field. // You do not have to set the spatial reference, as it is inherited from the feature dataset. Igeometrydef geometrydef = New Geometrydefclass (); igeometrydefedit geometrydefedit = (igeometrydefedit) geometrydef; geometrydefedit. geometrytype_2 = ESRI. ArcGIS. Geometry. esrigeometrytype. esrigeometrypolyline; // By setting the grid size to 0, you are allowing ArcGIS to determine the appropriate grid sizes for the feature class.  // If in a personal Geodatabase, the grid size is 1,000. If in a file or ArcSDE Geodatabase, the grid size  // Is based on the initial loading or inserting of features. Geometrydefedit. gridcount_2 = 1; geometrydefedit. set_gridsize (0, 0); geometrydefedit. hasm_2 = False ; Geometrydefedit. hasz_2 =False ; // Set standard field properties. Fieldedit. name_2 = "Shape" ; Fieldedit. type_2 = esrifieldtype. esrifieldtypegeometry; fieldedit. geometrydef_2 = geometrydef; fieldedit. isnullable_2 = True ; Fieldedit. required_2 = True ; Fieldsedit. set_field (1, fielduserdefined ); // Create a field of type double to hold some information for the features. Fielduserdefined = New Field (); fieldedit = (ifieldedit) fielduserdefined; fieldedit. name_2 = "Avg_income" ; Fieldedit. aliasname_2 = "Average income for 1999-2000" ; Fieldedit. editable_2 = True ; Fieldedit. isnullable_2 = False ; Fieldedit. precision_2 = 2; fieldedit. scale_2 = 5; fieldedit. type_2 = esrifieldtype. esrifieldtypedouble; fieldsedit. set_field (2, fielduserdefined ); // Create a feature class description object to use for specifying the CLSID and extclsid. Ifeatureclassdescription fcdesc = New Featureclassdescriptionclass (); iobjectclassdescription ocdesc = (iobjectclassdescription) fcdesc; Return Featuredataset. createfeatureclass (nameoffeatureclass, fields, ocdesc. instanceclsid, ocdesc. classextensionclsid, esrifeaturetype. esriftsimple, "Shape" , "" );}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.