wjssong
路人甲
路人甲
  • 注册日期2005-03-10
  • 发帖数37
  • QQ
  • 铜币313枚
  • 威望0点
  • 贡献值0点
  • 银元0个
阅读:1270回复:1

怎样在arcMap里用程序创建一个新层啊?

楼主#
更多 发布于:2005-07-08 11:33
<P>在arcMap里用程序创建一个层,并把这个层保存为一个新的层文件?</P>
<P>用程序怎么实现?</P>
喜欢0 评分0
wjssong
gis
gis
管理员
管理员
  • 注册日期2003-07-16
  • 发帖数15947
  • QQ554730525
  • 铜币25339枚
  • 威望15364点
  • 贡献值0点
  • 银元0个
  • GIS帝国居民
  • 帝国沙发管家
  • GIS帝国明星
  • GIS帝国铁杆
1楼#
发布于:2005-07-08 15:13
<P>Public Function CreateShapefile(strFolder As String, strName As String, _<BR>  geomType As esriGeometryType) As esriGeoDatabase.IFeatureClass</P>
<P>'' 在目录里建立一个shp图层.<BR>'' 注意: shapefile的名字不包括 .shp 扩展名<BR>'' 作者:<BR>'' 修改时间</P>
<P>  Const strShapeFieldName As String = "Shape"</P>
<P>  On Error GoTo EH<BR>  Set CreateShapefile = Nothing<BR>  If strFolder = "" Then Exit Function</P>
<P>  ' Open the folder to contain the shapefile as a workspace<BR>  Dim pFWS As esriGeoDatabase.IFeatureWorkspace<BR>  Dim pWorkspaceFactory As esriGeoDatabase.IWorkspaceFactory<BR>  Set pWorkspaceFactory = New esriDataSourcesFile.ShapefileWorkspaceFactory<BR>  Set pFWS = pWorkspaceFactory.OpenFromFile(strFolder, 0)</P>
<P>  ' Set up a simple fields collection<BR>  Dim pFields As esriGeoDatabase.IFields<BR>  Dim pFieldsEdit As esriGeoDatabase.IFieldsEdit<BR>  Set pFields = New esriGeoDatabase.Fields<BR>  Set pFieldsEdit = pFields</P>
<P>  Dim pField As esriGeoDatabase.IField<BR>  Dim pFieldEdit As esriGeoDatabase.IFieldEdit</P>
<P>  ' Make the shape field<BR>  ' it will need a geometry definition, with a spatial reference<BR>  Set pField = New esriGeoDatabase.Field<BR>  Set pFieldEdit = pField<BR>  pFieldEdit.Name = strShapeFieldName<BR>  pFieldEdit.Type = esriFieldTypeGeometry</P>
<P>  Dim pGeomDef As esriGeoDatabase.IGeometryDef<BR>  Dim pGeomDefEdit As esriGeoDatabase.IGeometryDefEdit<BR>  Set pGeomDef = New esriGeoDatabase.GeometryDef<BR>  Set pGeomDefEdit = pGeomDef<BR>  With pGeomDefEdit<BR>    .GeometryType = geomType<BR>    Set .SpatialReference = New esriGeometry.UnknownCoordinateSystem<BR>  End With<BR>  Set pFieldEdit.GeometryDef = pGeomDef<BR>  pFieldsEdit.AddField pField</P>
<P>  ' Create the shapefile<BR>  ' (some parameters apply to geodatabase options and can be defaulted as Nothing)</P>
<P>  Set CreateShapefile = pFWS.CreateFeatureClass(strName, pFields, Nothing, _<BR>                                           Nothing, esriFTSimple, strShapeFieldName, "")<BR>  Exit Function<BR>EH:<BR>    MsgBox Err.Description, vbInformation, "createShapefile"<BR>End Function</P>
举报 回复(0) 喜欢(0)     评分
游客

返回顶部