22

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.

PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked Mar 11, 2011 at 23:22

8 Answers 8

25

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.

vinayan
7,3403 gold badges38 silver badges76 bronze badges
answered Sep 9, 2011 at 12:38
0
16

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

answered Mar 12, 2011 at 16:38
1
  • 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? =) Commented Mar 12, 2011 at 17:54
2

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

answered Mar 12, 2011 at 11:24
0
1

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/

answered Mar 13, 2011 at 4:20
1

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.

answered Aug 27, 2015 at 13:21
0
0

As of 2022, for reference on similar questions, there is also the Geometry.js library (first release in 2019) that could fit for some needs, complementary with the nice JSTS library. It is pretty straight-forward for getting the area of polygons, calculating angles and scaling operations.

Kadir Şahbaz
78.6k57 gold badges260 silver badges407 bronze badges
answered May 11, 2022 at 13:31
-1

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

GIS-Jonathan
6,7855 gold badges31 silver badges58 bronze badges
answered May 17, 2012 at 19:49
-1

You can refer to opensource javascript geometry library @ geoJs.

answered Aug 9, 2014 at 12:27

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.