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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c45774fe6829810899c98f75430ac47a135f839762663381e9621f983e7a0baa
4
- data.tar.gz: 719b2421748188426d1c44b73c00744d66a65b8ac5e23034a22d875da5fbfd61
3
+ metadata.gz: 3e79499aff738642d7e50a0255239de6627e68b3e1553f8aa6fa21364c3b5acb
4
+ data.tar.gz: 26a98ee5cb279af10e2cc324663e06ddfc7217eb6a6adc3d4052cc6469b5b6be
5
5
  SHA512:
6
- metadata.gz: 8ab6221b26cd81ab2af42d195349d188ec482d6cb346677a28d3a69c16e8472060645938f806df6f14ee76eabef11d0e7e12904513b47b005ebf75d6e898caac
7
- data.tar.gz: 2d0a3df4f22008bef642dcff5c74b2ae8c8c4590314ea110a58fedf8a4c949649ba649f8bca77016fb1a0cf49d0571eee7fecd007d610d873693f98a8fbab6b6
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
- # important to standardize the data!
142
- data = [1,2,3,4,5,6].standardize
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
- # important to standardize the data!
223
- data = [1,2,3,4,5,6].standardize
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
- ## TODO
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
- - Geary class
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
- #### Local
319
+ ### v1.x
350
320
 
351
- - Join Count Statistic
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
- #### PPA
334
+ ### v2.0
354
335
 
355
- - Add descriptive stat methods for point clusters.
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 [MIT License](https://opensource.org/licenses/MIT).
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 1-D representation of a 2-D array as input.
114
+ * Uses a Dictionary of Keys (DOK) as input to represent a square matrix.
115
115
  * @example
116
- * dummy_data = [
117
- * [0, 1, 2]
118
- * [3, 4, 5],
119
- * [6, 7, 8]
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, num_cols)
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
  */
@@ -21,7 +21,6 @@ module SpatialStats
21
21
  @y_field = y_field
22
22
  @weights = weights.standardize
23
23
  end
24
- attr_writer :x, :y
25
24
 
26
25
  ##
27
26
  # Computes the global spatial correlation of x against spatially lagged
@@ -18,7 +18,6 @@ module SpatialStats
18
18
  def initialize(scope, field, weights)
19
19
  super(scope, field, weights)
20
20
  end
21
- attr_writer :x
22
21
 
23
22
  ##
24
23
  # Computes the global spatial autocorrelation of x against a spatially
@@ -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 = []
@@ -22,7 +22,6 @@ module SpatialStats
22
22
  @weights = weights.standardize
23
23
  end
24
24
  attr_accessor :scope, :x_field, :y_field, :weights
25
- attr_writer :x, :y
26
25
 
27
26
  ##
28
27
  # Computes the local indicator of spatial correlation for
@@ -18,7 +18,6 @@ module SpatialStats
18
18
  def initialize(scope, field, weights)
19
19
  super(scope, field, weights)
20
20
  end
21
- attr_writer :x
22
21
 
23
22
  ##
24
23
  # Computes Geary's C for every observation in the +scoe+.
@@ -20,7 +20,6 @@ module SpatialStats
20
20
  def initialize(scope, field, weights)
21
21
  super(scope, field, weights)
22
22
  end
23
- attr_writer :x
24
23
 
25
24
  ##
26
25
  # Computes the local indicator of spatial autocorrelation (lisa) for
@@ -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
  #
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SpatialStats
4
- VERSION = '1.0.2'
4
+ VERSION = '1.0.3'
5
5
  end
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.2
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-08 00:00:00.000000000 Z
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
- - keith.doggett887@gmail.com
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
- - MIT
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:
@@ -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.