阅读:1397回复:3
[求助]那位大侠有读取shp文件的程序
<P>那位大侠有读取shp文件的程序,请共享一下</P><br><br>
|
|
1楼#
发布于:2006-08-15 08:58
在帮助例子中找一个改改就行。
|
|
2楼#
发布于:2006-09-05 15:30
<BR> '加载shapefile文件<BR> Private Sub AddShape()<BR> OpenFileDialog1.Filter = "Shape file (*.shp)|*.shp"<BR> OpenFileDialog1.Title = "Open Shape files"<BR> OpenFileDialog1.ShowDialog()<BR> Dim filename, fpath, fname As String<BR> filename = OpenFileDialog1.FileName<BR> Dim n, L As Integer<BR> L = Len(filename)<BR> Dim lngStartPos As Long<BR> Dim lngNextPos As Long<BR> Dim str As String<BR> str = "\"<BR> lngStartPos = 1<BR> If filename <> "" Then<BR> Do<BR> lngNextPos = InStr(lngStartPos, filename, str, CompareMethod.Text)<BR> If lngNextPos = 0 Then<BR> fname = Mid$(filename, lngStartPos, L - lngNextPos + 1)<BR> fpath = Mid$(filename, 1, L - Len(fname))<BR> End If<BR> lngStartPos = lngNextPos + 1<BR> Loop Until lngNextPos = 0<BR> lngStartPos = 1<BR> axMapControl.AddShapeFile(fpath, fname)<BR> axMapControl.Extent = axMapControl.FullExtent<BR> LayerAxTOCControl.SetBuddyControl(axMapControl)<BR> '缩略图随之加载<BR> OverviewaxMapControl.AddShapeFile(fpath, fname)<BR> OverviewaxMapControl.Extent = OverviewaxMapControl.FullExtent<BR> End If<BR> End Sub
|
|
3楼#
发布于:2006-09-05 17:02
<P>c#:</P>
<P>private void AddShpFile()<BR> {<BR> string FilePath ;//定义文件路径 <BR> OpenFileDialog openShpFile = new OpenFileDialog();<BR> openShpFile.Multiselect=true;<BR> openShpFile.Title="Open Shape File";<BR> openShpFile.Filter="shp文件(*.shp)|*.shp";<BR> openShpFile.RestoreDirectory=true;</P> <P> if( openShpFile.ShowDialog() == DialogResult.OK )<BR> {<BR> if(( openShpFile.OpenFile()) != null )<BR> {<BR> string[] fileNames=openShpFile.FileNames; <BR> FilePath=System.IO.Path.GetDirectoryName(fileNames[0]);<BR> <BR> foreach( string shpFileWithPath in fileNames )<BR> { <BR> axMapControl.AddShapeFile(FilePath,System.IO.Path.GetFileNameWithoutExtension(shpFileWithPath)); <BR> } <BR> }<BR> } <BR> }</P> |
|