|
阅读:1337回复:2
求教斑竹(看了您的关于shapefile文件生成的文章后)
<P> 我也是想实现打点以后保存成shape文件的问题,以前您也发过很多关于shape文件的生成、多边形保存,将点投影到图层上的帖子。将点投影到图层上的那段源程序,看不太懂,后来只得试着将多边形保存的那段程序关于多边形的全改成关于点的, 改后的程序如下:</P>
<P>Dim mosymbol As New MapObjects2.Symbol Dim mopoints As New Collection</P> <P>Private Sub mnuSaveAs_Click() Dim gds As MapObjects2.GeoDataset Dim sname As String Dim desc As New TableDesc Dim dc As New DataConnection Dim lyr As New MapObjects2.MapLayer Dim lpoin As Long</P> <P>If mopoints.Count < 1 Then MsgBox "先在地图上画点" Exit Sub End If With File_Operation .FileName = "" .DialogTitle = "Save layers to shape files..." .Filter = "ESRI Shapefiles(*.shp)|*.shp" .DefaultExt = ".shp" .ShowSave If Len(.FileName) = 0 Then Exit Sub dc.Database = CurDir If Not dc.Connect Then Exit Sub sname = Left(.FileTitle, Len(.FileTitle) - 4) End With With desc .FieldCount = 3 .FieldName(0) = "Name" .FieldName(1) = "Area" .FieldName(2) = "Perimeter" .FieldType(0) = moString .FieldType(1) = moDouble .FieldType(2) = moDouble .FieldLength(0) = 16 .FieldPrecision(1) = 15 .FieldScale(1) = 3 .FieldPrecision(2) = 15 .FieldScale(2) = 3 End With Set gds = dc.AddGeoDataset(sname, moPoint, desc) If gds Is Nothing Then Exit Sub Set lyr.GeoDataset = gds Map1.Layers.Add lyr Map1.Refresh For lpoin = 1 To mopoints.Count With lyr.Records .AddNew .Fields("Shape").Value = mopoints(lpoin) .Fields("Name").Value = "Name" ; lpoin .Fields("area").Value = mopoints(lpoin).Area .Fields("perimeter").Value = mopoints(lpoin).Perimeter .Update End With Next lyr.Records.StopEditing End Sub</P> <P>打点用mopoints.add pts 实现(省略了)</P> <P>运行以后出现object doesn't support this property or method 错误 指向: .Fields("area").Value = mopoints(lpoin).Area 结果中shape文件是生成了,载入后却没图形(点),求教斑竹该怎么解决啊,或者有其他什么法子?谢谢了</P> |
|
|
|
1楼#
发布于:2004-08-05 08:38
<P> .Fields("Shape").Value = mopoints(lpoin) 应改为</P><P>set .Fields("Shape").Value = mopoints(lpoin) </P><P>请试试!</P><img src="images/post/smile/dvbbs/em07.gif" />
|
|
|
2楼#
发布于:2004-08-05 09:18
<P>刚才试了一下,不行啊</P><img src="images/post/smile/dvbbs/em08.gif" />
|
|
|