ldj
ldj
路人甲
路人甲
  • 注册日期2003-10-19
  • 发帖数161
  • QQ
  • 铜币737枚
  • 威望0点
  • 贡献值0点
  • 银元0个
阅读:1397回复:3

[求助]那位大侠有读取shp文件的程序

楼主#
更多 发布于:2006-08-02 08:55
<P>那位大侠有读取shp文件的程序,请共享一下</P><br><br>
喜欢0 评分0
chuanmm
路人甲
路人甲
  • 注册日期2006-03-22
  • 发帖数2
  • QQ
  • 铜币116枚
  • 威望0点
  • 贡献值0点
  • 银元0个
1楼#
发布于:2006-08-15 08:58
在帮助例子中找一个改改就行。
举报 回复(0) 喜欢(0)     评分
hobby666
路人甲
路人甲
  • 注册日期2005-04-18
  • 发帖数29
  • QQ
  • 铜币128枚
  • 威望0点
  • 贡献值0点
  • 银元0个
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
举报 回复(0) 喜欢(0)     评分
gisgeoboy
路人甲
路人甲
  • 注册日期2003-11-11
  • 发帖数73
  • QQ
  • 铜币377枚
  • 威望0点
  • 贡献值0点
  • 银元0个
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>
举报 回复(0) 喜欢(0)     评分
游客

返回顶部