spatial_stats 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +25 -43
- data/ext/spatial_stats/csr_matrix.c +7 -11
- data/lib/spatial_stats/global/bivariate_moran.rb +0 -1
- data/lib/spatial_stats/global/moran.rb +0 -1
- data/lib/spatial_stats/global/stat.rb +9 -0
- data/lib/spatial_stats/local/bivariate_moran.rb +0 -1
- data/lib/spatial_stats/local/geary.rb +0 -1
- data/lib/spatial_stats/local/moran.rb +0 -1
- data/lib/spatial_stats/local/stat.rb +9 -0
- data/lib/spatial_stats/spatial_stats.so +0 -0
- data/lib/spatial_stats/version.rb +1 -1
- metadata +5 -5
- data/MIT-LICENSE +0 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3e79499aff738642d7e50a0255239de6627e68b3e1553f8aa6fa21364c3b5acb
|
4
|
+
data.tar.gz: 26a98ee5cb279af10e2cc324663e06ddfc7217eb6a6adc3d4052cc6469b5b6be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a184a7e6561ec950ecc97e08840c8e88ba7bb20567d140036c34e0552a0e11a339885094fa5380e59f1a7ebe4eee0cb371368e6a7384531c7704e9894c8c1948
|
7
|
+
data.tar.gz: cd971928ff328e8daca3b0176b01903bdc98d7fcf1109cdbf9937dd84ff737d2d8072b7437e21dc0c2f26c73738c7c7f30c9a7bdca30b5cfd655ef5f3f760df1
|
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
[![Build Status](https://travis-ci.com/keithdoggett/spatial_stats.svg?branch=master)](https://travis-ci.com/keithdoggett/spatial_stats)
|
2
2
|
|
3
|
+
![Spatial Stats](/assets/ruby.svg)
|
4
|
+
|
3
5
|
# SpatialStats
|
4
6
|
|
5
7
|
SpatialStats is an ActiveRecord plugin that utilizes PostGIS and Ruby to compute weights/statistics of spatial data sets in Rails Apps.
|
@@ -138,8 +140,8 @@ field = nil
|
|
138
140
|
moran = SpatialStats::Global::Moran.new(scope, field, weights)
|
139
141
|
# => <SpatialStats::Global::Moran>
|
140
142
|
|
141
|
-
#
|
142
|
-
data = [1,2,3,4,5,6]
|
143
|
+
# data is automatically standardized on input
|
144
|
+
data = [1,2,3,4,5,6]
|
143
145
|
moran.x = data
|
144
146
|
|
145
147
|
moran.stat
|
@@ -219,8 +221,8 @@ field = nil
|
|
219
221
|
moran = SpatialStats::Local::Moran.new(scope, field, weights)
|
220
222
|
# => <SpatialStats::Local::Moran>
|
221
223
|
|
222
|
-
#
|
223
|
-
data = [1,2,3,4,5,6]
|
224
|
+
# data is automatically standardized on input
|
225
|
+
data = [1,2,3,4,5,6]
|
224
226
|
moran.x = data
|
225
227
|
|
226
228
|
moran.stat
|
@@ -310,50 +312,30 @@ RGeo::Geos.supported?
|
|
310
312
|
# => true
|
311
313
|
```
|
312
314
|
|
313
|
-
##
|
314
|
-
|
315
|
-
- ~~Memoize expensive functions within classes~~
|
316
|
-
- ~~Make star a parameter to getis-ord class~~
|
317
|
-
- ~~Add examples/usage to docs~~
|
318
|
-
- ~~Create RDocs~~
|
319
|
-
- ~~Refactor Global Moran and BVMoran~~
|
320
|
-
- ~~Support non-numeric keys in WeightsMatrix/General refactor~~
|
321
|
-
- ~~Write SparseMatrix C ext~~
|
322
|
-
- ~~Change instances of `standardized` and `windowed` to `standardize` and `window`, respectively.~~
|
323
|
-
- ~~Add `positive` and `negative` groups for `GetisOrd` and `Geary`, similar to how `#quads` is implemented.~~
|
324
|
-
- ~~Add `#summary` method to statistics that will combine stat vals with p-vals, and quads or hot/cold spot info.~~
|
325
|
-
- ~~Add ability to assign `x` or `z` on stat classes so users are not forced to query data to input it into models. Add example to README.~~
|
326
|
-
|
327
|
-
## Future Work
|
328
|
-
|
329
|
-
#### General
|
330
|
-
|
331
|
-
- ~~Refactor stats to inherit an abstract class.~~
|
332
|
-
- ~~Change WeightsMatrix class and Stat classes to utilize sparse matrix methods.~~
|
333
|
-
- Split into two separate gems spatial_stats and spatial_stats-activerecord
|
334
|
-
|
335
|
-
#### Weights
|
336
|
-
|
337
|
-
- Add Kernel based weighting
|
338
|
-
|
339
|
-
#### Utils
|
340
|
-
|
341
|
-
- Rate smoothing
|
342
|
-
- Bayes smoothing
|
343
|
-
|
344
|
-
#### Global
|
315
|
+
## Path Forward
|
345
316
|
|
346
|
-
|
347
|
-
- GetisOrd class
|
317
|
+
Summaries of milestones for v1.x and v2.0. These lists are subject to change. If you have an additional feature you want to see for either milestone, open up an issue or PR.
|
348
318
|
|
349
|
-
|
319
|
+
### v1.x
|
350
320
|
|
351
|
-
|
321
|
+
1. Global Measurements
|
322
|
+
- `Geary`'s C
|
323
|
+
- `GetisOrd`
|
324
|
+
2. Local Measurements
|
325
|
+
- `Join Count`
|
326
|
+
3. Utilities
|
327
|
+
- Add support for .gal/.swm file imports
|
328
|
+
- Add support for Rate variables
|
329
|
+
- Add support for Bayes smoothing
|
330
|
+
4. General
|
331
|
+
- Point Pattern Analysis Module
|
332
|
+
- Regression Module
|
352
333
|
|
353
|
-
|
334
|
+
### v2.0
|
354
335
|
|
355
|
-
-
|
336
|
+
- Break gem into core `spatial_stats` that will not include queries module and `spatial_stats-activerecord`. This will remove the dependency on rails for the core gem.
|
337
|
+
- Create `spatial_stats-import/geojson/shp` gem that will allow importing files and generating a `WeightsMatrix`. Will likely rely on `RGeo` or another spatial lib.
|
356
338
|
|
357
339
|
## License
|
358
340
|
|
359
|
-
The gem is available as open source under the terms of the [
|
341
|
+
The gem is available as open source under the terms of the [BSD-3-Clause](https://opensource.org/licenses/BSD-3-Clause).
|
@@ -111,23 +111,19 @@ void mat_to_sparse(csr_matrix *csr, VALUE data, VALUE keys, VALUE num_rows)
|
|
111
111
|
|
112
112
|
/**
|
113
113
|
* A new instance of CSRMatrix.
|
114
|
-
* Uses a
|
114
|
+
* Uses a Dictionary of Keys (DOK) as input to represent a square matrix.
|
115
115
|
* @example
|
116
|
-
*
|
117
|
-
*
|
118
|
-
*
|
119
|
-
*
|
120
|
-
*
|
116
|
+
* weights = {
|
117
|
+
* 'a' => [{ id: 'c', weight: 1 }],
|
118
|
+
* 'b' => [{ id: 'b', weight: 1 }],
|
119
|
+
* 'c' => [{ id: 'a', weight: 1 }]
|
120
|
+
* }
|
121
121
|
* num_rows = 3
|
122
|
-
* num_cols = 3
|
123
|
-
* data = dummy_data.flatten
|
124
|
-
* # => [0, 1, 2, 3, 4, 5, 6, 7, 8]
|
125
122
|
*
|
126
|
-
* csr = CSRMatrix.new(data, num_rows
|
123
|
+
* csr = CSRMatrix.new(data, num_rows)
|
127
124
|
*
|
128
125
|
* @param [Array] data in 1-D format
|
129
126
|
* @param [Integer] num_rows in the 2-D representation
|
130
|
-
* @param [Integer] num_cols in the 2-D representation
|
131
127
|
*
|
132
128
|
* @return [CSRMatrix]
|
133
129
|
*/
|
@@ -39,6 +39,15 @@ module SpatialStats
|
|
39
39
|
(stat - expectation) / Math.sqrt(variance)
|
40
40
|
end
|
41
41
|
|
42
|
+
def x=(values)
|
43
|
+
@x = values.standardize
|
44
|
+
end
|
45
|
+
alias z= x=
|
46
|
+
|
47
|
+
def y=(values)
|
48
|
+
@y = values.standardize
|
49
|
+
end
|
50
|
+
|
42
51
|
def mc(permutations, seed)
|
43
52
|
rng = gen_rng(seed)
|
44
53
|
shuffles = []
|
@@ -28,6 +28,15 @@ module SpatialStats
|
|
28
28
|
raise NotImplementedError, 'method variance not implemented'
|
29
29
|
end
|
30
30
|
|
31
|
+
def x=(values)
|
32
|
+
@x = values.standardize
|
33
|
+
end
|
34
|
+
alias z= x=
|
35
|
+
|
36
|
+
def y=(values)
|
37
|
+
@y = values.standardize
|
38
|
+
end
|
39
|
+
|
31
40
|
##
|
32
41
|
# Z-score for each observation of the statistic.
|
33
42
|
#
|
Binary file
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spatial_stats
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Keith Doggett
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-05-
|
11
|
+
date: 2020-05-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: numo-narray
|
@@ -127,13 +127,12 @@ description: An ActiveRecord/PostGIS extension that provides statistical methods
|
|
127
127
|
weighting in PostGIS and performs statistical computations inside your rails app.
|
128
128
|
Supports contiguious and distance-based calculations.
|
129
129
|
email:
|
130
|
-
-
|
130
|
+
- kfdoggett@gmail.com
|
131
131
|
executables: []
|
132
132
|
extensions:
|
133
133
|
- ext/spatial_stats/extconf.rb
|
134
134
|
extra_rdoc_files: []
|
135
135
|
files:
|
136
|
-
- MIT-LICENSE
|
137
136
|
- README.md
|
138
137
|
- Rakefile
|
139
138
|
- ext/spatial_stats/csr_matrix.c
|
@@ -169,11 +168,12 @@ files:
|
|
169
168
|
- lib/tasks/spatial_stats_tasks.rake
|
170
169
|
homepage: https://www.github.com/keithdoggett/spatial_stats
|
171
170
|
licenses:
|
172
|
-
-
|
171
|
+
- BSD-3-Clause
|
173
172
|
metadata:
|
174
173
|
homepage_uri: https://www.github.com/keithdoggett/spatial_stats
|
175
174
|
source_code_uri: https://www.github.com/keithdoggett/spatial_stats
|
176
175
|
documentation_uri: https://keithdoggett.github.io/spatial_stats/
|
176
|
+
changelog_uri: https://www.github.com/keithdoggett/spatial_stats/CHANGELOG.md
|
177
177
|
post_install_message:
|
178
178
|
rdoc_options: []
|
179
179
|
require_paths:
|
data/MIT-LICENSE
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
Copyright 2020 Keith Doggett
|
2
|
-
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
-
a copy of this software and associated documentation files (the
|
5
|
-
"Software"), to deal in the Software without restriction, including
|
6
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
-
permit persons to whom the Software is furnished to do so, subject to
|
9
|
-
the following conditions:
|
10
|
-
|
11
|
-
The above copyright notice and this permission notice shall be
|
12
|
-
included in all copies or substantial portions of the Software.
|
13
|
-
|
14
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|