Coder Social home page Coder Social logo

broham / gogeos Goto Github PK

View Code? Open in Web Editor NEW

This project forked from spatially/gogeos

0.0 2.0 0.0 250 KB

Go library for spatial data operations and geometric algorithms (Go bindings for GEOS)

Home Page: http://paulsmith.github.io/gogeos/

License: MIT License

Makefile 0.33% Go 95.17% C 0.74% Python 3.76%

gogeos's Introduction

gogeos - Go library for spatial data operations and geometric algorithms

Build Status

gogeos is a library for Go that provides operations on spatial data and geometric algorithms.

It provides bindings to the GEOS C library.

Quick start

package main

import (
	"fmt"

	"github.com/paulsmith/gogeos/geos"
)

func main() {
	line, _ := geos.FromWKT("LINESTRING (0 0, 10 10, 20 20)")
	buf, _ := line.Buffer(2.5)
	fmt.Println(buf)
	// Output: POLYGON ((18.2322330470336311 21.7677669529663689, 18.61…
}

Overview

Functionality

  • Binary predicates - intersects, disjoint, etc.
  • Topology operations - difference, union, etc.
  • Polygonization, line merging, and simplification
  • Prepared geometries (for better performance for common binary predicates)
  • Validity checking
  • DE-9IM
  • Geometry info - area, length, distance, etc.
  • IO - WKT & WKB read/write

gogeos is an open source project.

Community

Installation

Requirements

  • GEOS 3.3.8 or 3.3.9

GEOS must be installed on your system to build gogeos.

Ubuntu

$ apt-get install libgeos-dev

OS X - homebrew

$ brew install geos

From source (all OSes)

$ wget http://download.osgeo.org/geos/geos-3.3.8.tar.bz2
$ tar xvfj geos-3.3.8.tar.bz2
$ cd geos-3.3.8
$ ./configure
$ make
$ sudo make install

Installing gogeos

$ go get github.com/paulsmith/gogeos/geos

Documentation

Example

Let’s say you have two polygons, A (blue) and B (orange).

One of the most common things to do with a spatial data library like gogeos is compute the intersection of two or more geometries. Intersection is just a method on geometry objects in gogeos, which takes one argument, the other geometry, and computes the intersection with the receiver. The result is a new geometry, C (magenta):

C := geos.Must(A.Intersection(B))

geos.Must is just a convenience function that takes the output of any gogeos function or method that returns a geometry and an error. It panics if the error is non-null, otherwise returning the geometry, making it more convenient to use in single-value contexts. In production code, though, you’ll want to check the error value.

(NB: these graphics weren't produced by gogeos directly - I used the excellent draw2d package to render the output of gogeos functions.)

License

MIT. See COPYING.

Copyright (c) 2013 Paul Smith

gogeos's People

Contributors

paulsmith avatar bdon avatar pmezard avatar

Watchers

Abe Miessler avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.