Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Does anyone know of a pure JavaScript library for doing geometry operations such as buffer, union, intersects, etc? I want to play with doing these operations in the browser. It looks like GeoScriptJS has some dependencies.

share|improve this question
up vote 13 down vote accepted

You could look at the OpenLayers API, particularly the Geometry classes. You can check for intersects, and have access to vertices etc. I've implemented point buffers in the past just with OpenLayers. Unions may be trickier though.

For more complex operations you may want to do the processing server-side, and pass results back in WKT or GeoJSON, both of which OpenLayers can display. See this Union tutorial for an example.

Another possible option is Spatial Query a "JQuery like Javascript library for handling spatial maths." I'm not sure how well tested it is but as the source is available you should take a look.

Update

There is now a JavaScript port of the JTS Topology Suite - https://github.com/bjornharrtell/jsts

share|improve this answer
    
I looked at OpenLayers geometries, and I think that the resize method would allow me to scale the geometries to get buffer-like results. But you're right, doing unions and intersections would all have to be done manually. Alas. What I really need is a pure JS port of JTS. JSTS? =) – atogle Mar 12 '11 at 17:54
    
I've looked around a lot and I don't think that any comprehensive, mature, and pure JS solution really exists. Spatial Query really looks like the best thing out there for now, but I found a few other repos on GitHub that were helpful: github.com/shawnbot/geoff/blob/master/src/geoff.js and github.com/maxogden/geojson-js-utils – atogle Apr 1 '11 at 17:12
    
@atogle - there is talk of moving the geometry functionality in OpenLayers to a separate library - osgeo-org.1803224.n2.nabble.com/… – geographika Apr 1 '11 at 17:22
    
good to know! – atogle Apr 7 '11 at 16:27

I'm pretty much done with my port of JTS which is a pure JS port and it's available at https://github.com/bjornharrtell/jsts

At the current version (0.9.1) it supports the core functionality of JTS by which I mean predicates and overlays.

share|improve this answer
    
+1 thanks for posting this. – Kirk Kuykendall Sep 9 '11 at 18:58
1  
+1 too, great work! – unicoletti Sep 9 '11 at 20:11
    
Hey I recently finished JSTS 1.0 which is a complete and up to date port of JTS in modern JavaScript. Available at the same place as the 0.x version. – Björn Harrtell Feb 29 at 20:07

You could have a look on geoscript (implemented in severals langauages including JS)

share|improve this answer
2  
I'm pretty sure that GeoScript JS is not meant to be run on the client/browser. The site says it's designed for RingoJS. It also appears to have JTS dependencies. – atogle Mar 12 '11 at 17:51

If you need this for Google AppEngine, from what I read, JTS is officially compatible with Google App Engine. There is a basic demo at http://giscloud.appspot.com/

share|improve this answer

You can use ArcGIS server REST API regardless of which API/language you are using. It provides all the methods exposed....

share|improve this answer

You can refer to opensource javascript geometry library @ geoJs.

share|improve this answer

Turf is a javascript library providing a lot of spatial operations. It is also modular, so you can only include the functions you need in the final script.

share|improve this answer
    
Unfortunately it is seriously limited in terms of geometries and available operations. You can do point in polygon stuff but that seems to be basically it. – bugmenot123 Feb 11 at 10:40
    
Turf actually uses my own JSTS (but an older version) for many of its operations. If you use JSTS directly you have access to a more detailed API that can do alot more than Turf. See github.com/bjornharrtell/jsts. – Björn Harrtell Feb 29 at 20:05

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.