Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I would like to know if a tiny stat/discretization js library ready to use exists.

I do know about the existence of jStat (which I may explore a little bit more thoroughly), and I know that mapfish has a geostats module/widget to create choropleth map - I found the code here. But it relies on openlayers and I would like to have a standalone lib and eventually be free to communicate with openlayers.

I would like to have few basics methods:

  • min
  • max
  • mean
  • median

and be able to implement the following discretization with the ability to specify the number of classes and the precision (decimal):

  • Quantile
  • Equal Interval
  • Natural Breaks (Jenks)

If it does not exist yet, I will probably code something myself and release it on github under free license. Any resource and advice is welcome.

share|improve this question
1  
This looks similar - code.google.com/p/pseudosavant/source/browse/trunk/mathStats/… Any reason for not going with jStat? –  geographika Jun 17 '11 at 16:21
    
Indeed the library you mentioned could have been a good start. Why not jstat? Because I haven't see discretization methods and that's what I was actually looking for in priority - stats methods are kind of bonus –  simo Jun 17 '11 at 19:38
add comment

3 Answers 3

up vote 12 down vote accepted

Well, I coded something yesterday and released it under MIT License.

The library, named geostats is available on github. The package includes examples. You will also be able to see it in action on http://www.empreinte-urbaine.eu/mapping/geostats/ (with a concrete choropleth representation sample).

It supports the 8 methods listed above :

  • Quantile
  • Equal Intervals
  • Standard deviation
  • Arithmetic progression
  • Geometric progression
  • Natural Breaks (Jenks) : The Jenks classification code has been taken from Doug Curl.
  • Unique values
  • User defined classification

The library also includes a method to render a legend in HTML format. See HTML legend samples to see available options (continuous, discontinuous, distinct classes).

Quantile classification sample :

quantile classification and legend

Unique Values classification sample : enter image description here

See a demo reading values directly from shapefile (using Marc Harter library).

If you want to make a try by yourself in 2 steps, using the jsconsole :

Do copy/paste into the console, first :

load("https://raw.github.com/simogeo/geostats/master/lib/geostats.js");

Then, do copy/paste :

var data = Array(12, 22, 5, 8, 43, 2, 34, 12, 34, 36, 5, 21, 23, 45, 12, 31, 38); 
serie = new geostats(data); 
serie.getEqInterval(4);
alert('Classification method : ' + serie.method + "\n\nClasses : " + serie.ranges.join(' | '));

Please, let me know if you discover any bug. Once again, any idea or suggestion is welcome to enhance the library.

That's all! Hope it will also be useful to you.

share|improve this answer
    
+1 very nice demo/samples –  geographika Jun 17 '11 at 16:22
add comment

science.js is a well-implemented collection of stats & linear algebra functionality with no dependencies.

share|improve this answer
    
interesting, but I haven't seen classification methods. Are they? –  simo Apr 23 '12 at 17:06
    
There are a few, like github.com/jasondavies/science.js/blob/master/src/stats/… –  tmcw Apr 24 '12 at 14:38
    
indeed, thanks! –  simo Apr 24 '12 at 15:48
add comment

Zachary Forest Johnson has done a really great job to provide thematic analysis on openlayers.

The library is under BSD license, available on github. More explanations on the project and samples are available on his blog.

share|improve this answer
add comment

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.