import (
"fmt"
"github.com/jonas-p/go-shp"
"log"
"reflect"
)
func main() {
// open a shapefile for reading
reader, err := shp.Open("E:/example.shp")
if err != nil {
log.Fatal(err)
}
defer reader.Close()
// fields from the attribute table (DBF)
fields := reader.Fields()
//fmt.Println(reader.AttributeCount())
//for k, f := range fields {
// fmt.Println(k,f)
//}
////fmt.Println(reader.Attribute(0))
//loop through all features in the shapefile
for reader.Next() {
n, p := reader.Shape()
point := p.(*shp.Point)
x := point.X
y := point.Y
fmt.Println(x, y)
// print feature
fmt.Println(reflect.TypeOf(p).Elem(), p.BBox())
// print attributes
for k, f :=range fields {
val := reader.ReadAttribute(n, k)
fmt.Printf("\t%v: %v\n", f, val)
}
fmt.Println()
}
}
CFileFindffCStringszName=dirif(szName.Right(1)!="\\"){szName+="\\"}szName+="*.*"BOOLres=ff.FindFile(szName)while(res){res=ff.FindNextFile()if(!ff.IsDots())//目录是文件夹{//如果是一个子目录,用递归继续往深一层找TravelDir(dir+"\\"+ff.GetFileTitle())}elseif(!ff.IsDirectory()&&!ff.IsDots())//到达最低层的文件{CStringfileName=ff.GetFileName()}}}ff.Close()//关闭MessageBox(fileName)欢迎分享,转载请注明来源:内存溢出
评论列表(0条)