AE creates a blank Shapefile

Source: Internet
Author: User

1. Differences between IField and IFieldEdit:

IFieldEdit inherits IField, because most IField attributes are read-only. Therefore, IFieldEdit has multiple write-only Attributes Based on IField. This is why Name_2 and Length_2 may occur. The same is true for IFields and IFieldsEdit.

2. Differences between IField and IFields

IFields is a set of IField. You can use the AddField () method or the set_Field () method to add a Field. The set_Field can use the index to add a Field at the specified position;

3.
EsriFieldType field type. Besides common types such as int, string, and double, esriFieldTypeGeometry can be queried.

Ms-help: // MS. VSCC. v80/MS. VSIPCC. v80/ESRI. EDNv9.2/esriGeoDatabase/html/esriFieldType.htm;
EsriGeometryType: Specifies the geometric type, such as ing, line, and plane. If you cannot remember it clearly, you can query it.

Ms-help: // MS. VSCC. v80/MS. VSIPCC. v80/ESRI. EDNv9.2/esriGeometry/html/esriGeometryType.htm;
EsriFeatureType element types, including simple element classes, complex elements, notes, multidimensional elements, Covering, Raster, etc.

Ms-help: // MS. VSCC. v80/MS. VSIPCC. v80/ESRI. EDNv9.2/esriGeoDatabase/html/esriFeatureType.htm.

I found an error today to correct it. Length_2 = 10 was previously written. An error was found during editing. Length is only for the String field. The Length of the Numeric field should be set to the Precision value. If it is Double, you can also use Scale to set the number of decimal places to be retained.

Add a description of several parameters of CreateFeatureClass (). I just checked it online:

CLSID and EXTCLSID have interesting meanings. As we know, each object in GeoDatabase has a unique identifier UID. The system authenticates this 64-bit random value to distinguish different objects. Likewise, the extension part of the element class and element class also has such an identifier, but in general we cannot see this UID value. How to generate these two values is also very simple. Use:
CLSID = pOCDesc. InstanceCLSID;
EXTCLSID = pOCDesc. ClassExtensionCLSID;
The CLSID property of a Table determines the type of row object returned by the Table; original
ShapeFieldName refers to the Shape field name of an element class, generally "SHAPE ". ---- It seems that it cannot be changed. After the changes are completed, the Shape is displayed.
You do not need to set ConfigKeyword. You can set it to an empty string.

View plaincopy to clipboardprint?
/// <Summary>
/// Create an empty Shapefile with the specified name in the specified path
/// </Summary>
/// <Param name = "strShapeFolder"> specify the path </param>
/// <Param name = "strShapeName"> file name </param>

Public void CreateShapefile (string strShapeFolder)
{
// Open the Workspace
Const string strShapeFieldName = "shape ";
IWorkspaceFactory pWSF = new ShapefileWorkspaceFactoryClass ();
IFeatureWorkspace pWS = (IFeatureWorkspace) pWSF. OpenFromFile (strShapeFolder, 0 );

// Set the field set
IFields pFields = new FieldsClass ();
IFieldsEdit pFieldsEdit = (IFieldsEdit) pFields;

// Set Fields
IField pField = new FieldClass ();
IFieldEdit pFieldEdit = (IFieldEdit) pField;

// Create a field of the geometric type
PFieldEdit. Name_2 = strShapeFieldName;
PFieldEdit. Type_2 = esriFieldType. esriFieldTypeGeometry;

// Create a geometric definition for fields of the esriFieldTypeGeometry type, including the type and space references.
IGeometryDef pGeoDef = new GeometryDefClass (); // The geometry definition for the field if IsGeometry is TRUE.
IGeometryDefEdit pGeoDefEdit = (IGeometryDefEdit) pGeoDef;
PGeoDefEdit. GeometryType_2 = esriGeometryType. esriGeometryPoint;
PGeoDefEdit. SpatialReference_2 = new UnknownCoordinateSystemClass ();

PFieldEdit. GeometryDef_2 = pGeoDef;
PFieldsEdit. AddField (pField );

// Add other fields
PField = new FieldClass ();
PFieldEdit = (IFieldEdit) pField;
PFieldEdit. Name_2 = "WaterLevel ";
PFieldEdit. Type_2 = esriFieldType. esriFieldTypeDouble;
PFieldEdit. Precision_2 = 7; // numerical accuracy
PFieldEdit. Scale_2 = 3; // number of decimal places
PFieldsEdit. AddField (pField );

// Create a shapefile
PWS. CreateFeatureClass (strShapeName, pFields, null, null, esriFeatureType. esriFTSimple, strShapeFieldName ,"");
}

This article from the CSDN blog, reproduced please indicate the source: http://blog.csdn.net/jingss_3/archive/2009/12/28/5092230.aspx

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.