How to parse shapefile for golang?

Please refer to https://github.com/jonas-p/go-shp

Examples

Reading a shapefile

// open a shapefile for reading
shape, err := shp.Open("points.shp")
if err != nil { log.Fatal(err) } 
defer shape.Close()
    
// fields from the attribute table (DBF)
fields := shape.Fields()
    
// loop through all features in the shapefile
for shape.Next() {
    n, p := shape.Shape()
    
    // print feature
    fmt.Println(reflect.TypeOf(p).Elem(), p.BBox())
    
    // print attributes
    for k, f := range fields {
        val := shape.ReadAttribute(n, k)
        fmt.Printf("\t%v: %v\n", f, val)
    }
    fmt.Println()
}
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • afinalAfinal是一个android的ioc,orm框架 https://github.com/yangf...
    passiontim阅读 15,642评论 2 45
  • 1、夜晚的小村几乎比白天更热闹 演示一 唢呐声、锣鼓声以及人们嬉笑怒骂声 把小村涂抹得五颜六色多姿多彩 演示二 热...
    浪漫冰花阅读 317评论 0 0