1 /// <summary>Create a point shapefile2 /// </summary>3 /// <param name= "FilePath" >Target Point Shapefile path</param>4 /// <param name= "FileName" >Target Point shapefile name</param>5 Public Static voidCreatepointshapefile (IMap map,stringFilePath,stringfileName)6 {7 //Create a shape field8Ifields Pfields =NewFieldsclass ();9Ifieldsedit Pfieldsedit = Pfields asIfieldsedit;TenIfield Pfield =NewFieldclass (); OneIfieldedit Pfieldedit = Pfield asIfieldedit; Apfieldedit.name_2 ="Shape"; -pfieldedit.type_2 =Esrifieldtype.esrifieldtypegeometry; - the //setting Geometry definition -Igeometrydef Pgeometrydef =NewGeometrydefclass (); -Igeometrydefedit Pgeometrydefedit = Pgeometrydef asIgeometrydefedit; -pgeometrydefedit.geometrytype_2 = Esrigeometrytype.esrigeometrypoint;//point, line, Polygon +pgeometrydefedit.spatialreference_2 =map. spatialreference; -Pfieldedit.geometrydef_2 =Pgeometrydef; +Pfieldsedit.addfield (Pfield); A at //new Field -Pfield =NewFieldclass (); -Pfieldedit = Pfield asIfieldedit; -pfieldedit.length_2 =Ten; -pfieldedit.name_2 ="ID"; -pfieldedit.aliasname_2 ="ID"; inpfieldedit.type_2 =Esrifieldtype.esrifieldtypesmallinteger; -Pfieldsedit.addfield (Pfield); to //continue to add additional fields + -Iworkspacefactory pworkspacefactory =Newshapefileworkspacefactory (); theIfeatureworkspace pfeatureworkspace = Pworkspacefactory.openfromfile (FilePath,0) asIfeatureworkspace; * $ //iworkspacefactory pworkspacefactory = new Filegdbworkspacefactoryclass ();Panax Notoginseng //ifeatureworkspace pfeatureworkspace = pworkspacefactory.openfromfile (FilePath, 0) as Ifeatureworkspace; - the inti = Filename.indexof (". SHP"); + if(i = =-1) APfeatureworkspace.createfeatureclass (FileName +". SHP", Pfields,NULL,NULL, Esrifeaturetype.esriftsimple,"Shape",""); the Else +Pfeatureworkspace.createfeatureclass (FileName, Pfields,NULL,NULL, Esrifeaturetype.esriftsimple,"Shape",""); - $ //MessageBox.Show ("OK"); $ -}
New shape file--Create a Featureclass store as a shape file