文档详情

GIS设计与实现实验报告二.doc

发布:2018-05-27约1.25万字共9页下载文档
文本预览下载声明
西北师范大学学生实验报告 学院 地环学院 专业 地理信息系统 年级、班 2008级 学号 苏有才 姓名 200875000131 同组者 课程名称 GIS设计与实现 实验题目 生成矢量数据 成绩 一、实验目的: 熟练掌握Shapefile格式数据的创建。 二、实验准备: 了解Shapefile文件类型及属性表格式;熟悉VBA编程环境;掌握创建Shapefile文件所用到的类:WorkSpaceFactory、WorkSpace、Fields、Field、GeometryDef。 三、实验内容: (1)利用ArcMap提供的Customize功能创建三个按钮,名称分别为CreatePoint、CreateLine和CreatePolygon;(2)在VBA环境下编写宏,实现创建点图层、线图层和多边形图层,要求①每个图层属性表均包含FID、Shape、Name(String, 10)和Code(String, 10)四个字段;②图层名和路径均由用户输入;③单击按钮后,自动将创建好的图层添加到ArcMap当前窗口;(3)在高级编程语言环境下(如.net, VB6.0),实现上述功能,并编译成DLL文件发布。 四、实验过程及步骤: (1)利用ArcMap提供的Customize功能创建三个按钮,名称分别为CreatePoint、CreateLine和CreatePolygon 程序代码如下: Sub Create_ShapeFile() Dim wsf As IWorkspaceFactory Set wsf = New ShapefileWorkspaceFactory Dim wsn As IWorkspaceName Set wsn = wsf.Create(f:, GIS二次开发, Nothing, 0) Dim pN As IName Set pN = wsn Dim ws As IFeatureWorkspace Set ws = pN.Open Dim fs As IFields Set fs = New Fields Dim fse As IFieldsEdit Set fse = fs Dim f1 As IField Set f1 = New Field Dim fe1 As IFieldEdit Set fe1 = f1 With fe1 .Name = FID .Type = esriFieldTypeOID .Length = 4 End With fse.AddField f1 Dim f2 As IField Set f2 = New Field Dim fe2 As IFieldEdit Set fe2 = f2 With fe2 .Name = shape .Type = esriFieldTypeGeometry End With Dim geod As IGeometryDef Set geod = New GeometryDef Dim geode As IGeometryDefEdit Set geode = geod geode.GeometryType = esriGeometryPoint Set geode.SpatialReference = New UnknownCoordinateSystem Set fe2.GeometryDef = geod fse.AddField f2 Dim f3 As IField Set f3 = New Field Dim fe3 As IFieldEdit Set fe3 = f3 With fe3 .Name = Type .Type = esriFieldTypeString .Length = 4 End With fse.AddField f3 Dim f4 As IField Set f4 = New Field Dim fe4 As IFieldEdit Set fe4 = f4 With fe4 .Name = Name .Type = esriFieldTypeString .Length = 10 End With fse.AddField f4 Dim f5 As IField Set f5 = New Field Dim fe5 As IFieldEdit Set fe5 = f5 With fe5 .Name = code .Type = esriFieldTypeString .Length = 10 End With fse.AddField f5 Dim t As ITable Set t = ws.CreateTa
显示全部
相似文档