From bbdd4de6ee305308d2d131d8bf5dc5e8f475a068 Mon Sep 17 00:00:00 2001 From: abelvm Date: Fri, 2 Sep 2016 12:23:47 +0200 Subject: [PATCH 01/14] smart guessing optional --- doc/19_contour.md | 2 +- src/pg/sql/19_contour.sql | 23 ++++++++++------------- src/pg/test/sql/19_contour_test.sql | 2 +- 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/doc/19_contour.md b/doc/19_contour.md index d6629e4..1463918 100644 --- a/doc/19_contour.md +++ b/doc/19_contour.md @@ -18,7 +18,7 @@ Function to generate a contour map from an scatter dataset of points, using one | method | integer | 0:nearest neighbor, 1: barycentric, 2: IDW| | classmethod | integer | 0:equals, 1: heads&tails, 2:jenks, 3:quantiles | | steps | integer | Number of steps in the classification| -| max_time | integer | Max time in millisecons for processing time +| resolution | integer | if <= 0: max processing time in seconds (smart resolution) , if >0: resolution in meters ### Returns Returns a table object diff --git a/src/pg/sql/19_contour.sql b/src/pg/sql/19_contour.sql index 759b151..2dd9f62 100644 --- a/src/pg/sql/19_contour.sql +++ b/src/pg/sql/19_contour.sql @@ -5,7 +5,7 @@ CREATE OR REPLACE FUNCTION CDB_Contour( IN intmethod integer, IN classmethod integer, IN steps integer, - IN max_time integer DEFAULT 60000 + IN resolution integer DEFAULT -90 ) RETURNS TABLE( the_geom geometry, @@ -17,18 +17,11 @@ RETURNS TABLE( DECLARE cell_count integer; tin geometry[]; + max_time integer; BEGIN - -- calc the cell size in web mercator units - -- WITH center as ( - -- SELECT ST_centroid(ST_Collect(geomin)) as c - -- ) - -- SELECT - -- round(resolution / cos(ST_y(c) * pi()/180)) - -- INTO cell - -- FROM center; - -- raise notice 'Resol: %', cell; -- calc the optimal number of cells for the current dataset + max_time := -1 * resolution; SELECT CASE intmethod WHEN 0 THEN round(3.7745903782 * max_time - 9.4399210051 * array_length(geomin,1) - 1350.8778213073) @@ -70,9 +63,13 @@ BEGIN ), resolution as( SELECT - round(|/ ( - ST_area(geom) / cell_count - )) as cell + CASE WHEN resolution <= 0 THEN + round(|/ ( + ST_area(geom) / abs(cell_count) + )) + ELSE + resolution + END AS cell FROM envelope3857 ), grid as( diff --git a/src/pg/test/sql/19_contour_test.sql b/src/pg/test/sql/19_contour_test.sql index 70e5cf9..9225612 100644 --- a/src/pg/test/sql/19_contour_test.sql +++ b/src/pg/test/sql/19_contour_test.sql @@ -12,6 +12,6 @@ SELECT foo.* FROM a, - cdb_crankshaft.CDB_contour(a.g, a.vals, 0.0, 1, 3, 5, 60) foo + cdb_crankshaft.CDB_contour(a.g, a.vals, 0.0, 1, 3, 5, -60) foo ) SELECT bin, avg_value from b order by bin; From 90f36b40585835c1b60ad4491c52a2af8a0a9af9 Mon Sep 17 00:00:00 2001 From: abelvm Date: Fri, 2 Sep 2016 12:35:54 +0200 Subject: [PATCH 02/14] drop --- src/pg/sql/19_contour.sql | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/pg/sql/19_contour.sql b/src/pg/sql/19_contour.sql index 2dd9f62..784779e 100644 --- a/src/pg/sql/19_contour.sql +++ b/src/pg/sql/19_contour.sql @@ -1,3 +1,5 @@ +DROP FUNCTION cdb_contour(geometry[],numeric[],numeric,integer,integer,integer,integer); + CREATE OR REPLACE FUNCTION CDB_Contour( IN geomin geometry[], IN colin numeric[], From 036a33aceddb3bfa041f1cb405d72b467653d3e1 Mon Sep 17 00:00:00 2001 From: abelvm Date: Fri, 2 Sep 2016 12:58:13 +0200 Subject: [PATCH 03/14] drop --- src/pg/sql/19_contour.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pg/sql/19_contour.sql b/src/pg/sql/19_contour.sql index 784779e..ae48eb5 100644 --- a/src/pg/sql/19_contour.sql +++ b/src/pg/sql/19_contour.sql @@ -1,4 +1,4 @@ -DROP FUNCTION cdb_contour(geometry[],numeric[],numeric,integer,integer,integer,integer); +DROP FUNCTION IF EXISTS cdb_contour(geometry[],numeric[],numeric,integer,integer,integer,integer); CREATE OR REPLACE FUNCTION CDB_Contour( IN geomin geometry[], From b8ce37eb60c5da80d966330982d2dd952562464d Mon Sep 17 00:00:00 2001 From: abelvm Date: Fri, 2 Sep 2016 14:37:52 +0200 Subject: [PATCH 04/14] back to the original signature --- src/pg/sql/19_contour.sql | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/pg/sql/19_contour.sql b/src/pg/sql/19_contour.sql index ae48eb5..5c2cfc2 100644 --- a/src/pg/sql/19_contour.sql +++ b/src/pg/sql/19_contour.sql @@ -1,5 +1,3 @@ -DROP FUNCTION IF EXISTS cdb_contour(geometry[],numeric[],numeric,integer,integer,integer,integer); - CREATE OR REPLACE FUNCTION CDB_Contour( IN geomin geometry[], IN colin numeric[], @@ -7,7 +5,7 @@ CREATE OR REPLACE FUNCTION CDB_Contour( IN intmethod integer, IN classmethod integer, IN steps integer, - IN resolution integer DEFAULT -90 + IN max_time integer DEFAULT -90 ) RETURNS TABLE( the_geom geometry, @@ -19,11 +17,14 @@ RETURNS TABLE( DECLARE cell_count integer; tin geometry[]; - max_time integer; + resolution integer; BEGIN - -- calc the optimal number of cells for the current dataset + -- nasty trick to override issue #121 + resolution := max_time; max_time := -1 * resolution; + + -- calc the optimal number of cells for the current dataset SELECT CASE intmethod WHEN 0 THEN round(3.7745903782 * max_time - 9.4399210051 * array_length(geomin,1) - 1350.8778213073) From 139e86d414ce7b227ecb806862c0f45c1fd6b6bb Mon Sep 17 00:00:00 2001 From: abelvm Date: Fri, 2 Sep 2016 14:43:48 +0200 Subject: [PATCH 05/14] back to the original signature --- src/pg/sql/19_contour.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pg/sql/19_contour.sql b/src/pg/sql/19_contour.sql index 5c2cfc2..18430c0 100644 --- a/src/pg/sql/19_contour.sql +++ b/src/pg/sql/19_contour.sql @@ -5,7 +5,7 @@ CREATE OR REPLACE FUNCTION CDB_Contour( IN intmethod integer, IN classmethod integer, IN steps integer, - IN max_time integer DEFAULT -90 + IN max_time integer DEFAULT 60000 ) RETURNS TABLE( the_geom geometry, From a530de80f106ab1ff1eef56272c8c1005aec9530 Mon Sep 17 00:00:00 2001 From: abelvm Date: Fri, 2 Sep 2016 14:57:21 +0200 Subject: [PATCH 06/14] back to the original signature --- doc/19_contour.md | 2 +- src/pg/sql/19_contour.sql | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/doc/19_contour.md b/doc/19_contour.md index b29ed89..fdee52e 100644 --- a/doc/19_contour.md +++ b/doc/19_contour.md @@ -18,7 +18,7 @@ Function to generate a contour map from an scatter dataset of points, using one | method | integer | 0:nearest neighbor, 1: barycentric, 2: IDW| | classmethod | integer | 0:equals, 1: heads&tails, 2:jenks, 3:quantiles | | steps | integer | Number of steps in the classification| -| resolution | integer | if <= 0: max processing time in seconds (smart resolution) , if >0: resolution in meters +| max_time | integer | if <= 0: max processing time in seconds (smart resolution) , if >0: resolution in meters ### Returns Returns a table object diff --git a/src/pg/sql/19_contour.sql b/src/pg/sql/19_contour.sql index 18430c0..78f0cfd 100644 --- a/src/pg/sql/19_contour.sql +++ b/src/pg/sql/19_contour.sql @@ -21,6 +21,9 @@ DECLARE BEGIN -- nasty trick to override issue #121 + IF max_time = 0 THEN + max_time = -90; + END IF; resolution := max_time; max_time := -1 * resolution; From a6440f2ef7d98c7f2477806b9c8ce5efb9b165b8 Mon Sep 17 00:00:00 2001 From: Andy Eschbacher Date: Fri, 2 Sep 2016 16:39:35 -0400 Subject: [PATCH 07/14] reports error string --- .../crankshaft/crankshaft/clustering/moran.py | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/py/crankshaft/crankshaft/clustering/moran.py b/src/py/crankshaft/crankshaft/clustering/moran.py index 3282f5f..a524892 100644 --- a/src/py/crankshaft/crankshaft/clustering/moran.py +++ b/src/py/crankshaft/crankshaft/clustering/moran.py @@ -38,10 +38,9 @@ def moran(subquery, attr_name, if len(result) == 0: return pu.empty_zipped_array(2) plpy.notice('** Query returned with %d rows' % len(result)) - except plpy.SPIError: - plpy.error('Error: areas of interest query failed, check input parameters') + except plpy.SPIError, e: + plpy.error('Query failed: %s' % e) plpy.notice('** Query failed: "%s"' % query) - plpy.notice('** Error: %s' % plpy.SPIError) return pu.empty_zipped_array(2) ## collect attributes @@ -79,8 +78,8 @@ def moran_local(subquery, attr, # if there are no neighbors, exit if len(result) == 0: return pu.empty_zipped_array(5) - except plpy.SPIError: - plpy.error('Error: areas of interest query failed, check input parameters') + except plpy.SPIError, e: + plpy.error('Query failed: %s' % e) plpy.notice('** Query failed: "%s"' % query) return pu.empty_zipped_array(5) @@ -119,10 +118,9 @@ def moran_rate(subquery, numerator, denominator, if len(result) == 0: return pu.empty_zipped_array(2) plpy.notice('** Query returned with %d rows' % len(result)) - except plpy.SPIError: - plpy.error('Error: areas of interest query failed, check input parameters') + except plpy.SPIError, e: + plpy.error('Query failed: %s' % e) plpy.notice('** Query failed: "%s"' % query) - plpy.notice('** Error: %s' % plpy.SPIError) return pu.empty_zipped_array(2) ## collect attributes @@ -160,10 +158,9 @@ def moran_local_rate(subquery, numerator, denominator, # if there are no neighbors, exit if len(result) == 0: return pu.empty_zipped_array(5) - except plpy.SPIError: - plpy.error('Error: areas of interest query failed, check input parameters') + except plpy.SPIError, e: + plpy.error('Query failed: %s' % e) plpy.notice('** Query failed: "%s"' % query) - plpy.notice('** Error: %s' % plpy.SPIError) return pu.empty_zipped_array(5) ## collect attributes From feab6f177e44eea131f421345505431ee756e414 Mon Sep 17 00:00:00 2001 From: Andy Eschbacher Date: Fri, 2 Sep 2016 17:52:41 -0400 Subject: [PATCH 08/14] clearer error message --- src/py/crankshaft/crankshaft/clustering/moran.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/py/crankshaft/crankshaft/clustering/moran.py b/src/py/crankshaft/crankshaft/clustering/moran.py index a524892..8c5d909 100644 --- a/src/py/crankshaft/crankshaft/clustering/moran.py +++ b/src/py/crankshaft/crankshaft/clustering/moran.py @@ -39,7 +39,7 @@ def moran(subquery, attr_name, return pu.empty_zipped_array(2) plpy.notice('** Query returned with %d rows' % len(result)) except plpy.SPIError, e: - plpy.error('Query failed: %s' % e) + plpy.error('Analysis failed: %s' % e) plpy.notice('** Query failed: "%s"' % query) return pu.empty_zipped_array(2) @@ -79,7 +79,7 @@ def moran_local(subquery, attr, if len(result) == 0: return pu.empty_zipped_array(5) except plpy.SPIError, e: - plpy.error('Query failed: %s' % e) + plpy.error('Analysis failed: %s' % e) plpy.notice('** Query failed: "%s"' % query) return pu.empty_zipped_array(5) @@ -119,7 +119,7 @@ def moran_rate(subquery, numerator, denominator, return pu.empty_zipped_array(2) plpy.notice('** Query returned with %d rows' % len(result)) except plpy.SPIError, e: - plpy.error('Query failed: %s' % e) + plpy.error('Analysis failed: %s' % e) plpy.notice('** Query failed: "%s"' % query) return pu.empty_zipped_array(2) @@ -159,7 +159,7 @@ def moran_local_rate(subquery, numerator, denominator, if len(result) == 0: return pu.empty_zipped_array(5) except plpy.SPIError, e: - plpy.error('Query failed: %s' % e) + plpy.error('Analysis failed: %s' % e) plpy.notice('** Query failed: "%s"' % query) return pu.empty_zipped_array(5) From 6d6d7ef2ba56af7fa7cff77c4c25f2f59602ab9b Mon Sep 17 00:00:00 2001 From: Andy Eschbacher Date: Fri, 2 Sep 2016 17:58:19 -0400 Subject: [PATCH 09/14] removing notices --- src/py/crankshaft/crankshaft/clustering/moran.py | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/src/py/crankshaft/crankshaft/clustering/moran.py b/src/py/crankshaft/crankshaft/clustering/moran.py index 8c5d909..7a97233 100644 --- a/src/py/crankshaft/crankshaft/clustering/moran.py +++ b/src/py/crankshaft/crankshaft/clustering/moran.py @@ -30,17 +30,13 @@ def moran(subquery, attr_name, query = pu.construct_neighbor_query(w_type, qvals) - plpy.notice('** Query: %s' % query) - try: result = plpy.execute(query) # if there are no neighbors, exit if len(result) == 0: return pu.empty_zipped_array(2) - plpy.notice('** Query returned with %d rows' % len(result)) except plpy.SPIError, e: plpy.error('Analysis failed: %s' % e) - plpy.notice('** Query failed: "%s"' % query) return pu.empty_zipped_array(2) ## collect attributes @@ -80,7 +76,6 @@ def moran_local(subquery, attr, return pu.empty_zipped_array(5) except plpy.SPIError, e: plpy.error('Analysis failed: %s' % e) - plpy.notice('** Query failed: "%s"' % query) return pu.empty_zipped_array(5) attr_vals = pu.get_attributes(result) @@ -110,17 +105,13 @@ def moran_rate(subquery, numerator, denominator, query = pu.construct_neighbor_query(w_type, qvals) - plpy.notice('** Query: %s' % query) - try: result = plpy.execute(query) # if there are no neighbors, exit if len(result) == 0: return pu.empty_zipped_array(2) - plpy.notice('** Query returned with %d rows' % len(result)) except plpy.SPIError, e: plpy.error('Analysis failed: %s' % e) - plpy.notice('** Query failed: "%s"' % query) return pu.empty_zipped_array(2) ## collect attributes @@ -160,7 +151,6 @@ def moran_local_rate(subquery, numerator, denominator, return pu.empty_zipped_array(5) except plpy.SPIError, e: plpy.error('Analysis failed: %s' % e) - plpy.notice('** Query failed: "%s"' % query) return pu.empty_zipped_array(5) ## collect attributes @@ -183,7 +173,6 @@ def moran_local_bv(subquery, attr1, attr2, """ Moran's I (local) Bivariate (untested) """ - plpy.notice('** Constructing query') qvals = OrderedDict([("id_col", id_col), ("attr1", attr1), @@ -202,7 +191,6 @@ def moran_local_bv(subquery, attr1, attr2, except plpy.SPIError: plpy.error("Error: areas of interest query failed, " \ "check input parameters") - plpy.notice('** Query failed: "%s"' % query) return pu.empty_zipped_array(4) ## collect attributes @@ -216,13 +204,9 @@ def moran_local_bv(subquery, attr1, attr2, lisa = ps.esda.moran.Moran_Local_BV(attr1_vals, attr2_vals, weight, permutations=permutations) - plpy.notice("len of Is: %d" % len(lisa.Is)) - # find clustering of significance lisa_sig = quad_position(lisa.q) - plpy.notice('** Finished calculations') - return zip(lisa.Is, lisa_sig, lisa.p_sim, weight.id_order) # Low level functions ---------------------------------------- From c229a8549101a127fa0abdcdde6c53833874d00a Mon Sep 17 00:00:00 2001 From: Andy Eschbacher Date: Fri, 2 Sep 2016 18:02:56 -0400 Subject: [PATCH 10/14] adding better reporting to markov --- src/py/crankshaft/crankshaft/space_time_dynamics/markov.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/py/crankshaft/crankshaft/space_time_dynamics/markov.py b/src/py/crankshaft/crankshaft/space_time_dynamics/markov.py index bbf524d..ae788d7 100644 --- a/src/py/crankshaft/crankshaft/space_time_dynamics/markov.py +++ b/src/py/crankshaft/crankshaft/space_time_dynamics/markov.py @@ -56,9 +56,9 @@ def spatial_markov_trend(subquery, time_cols, num_classes=7, ) if len(query_result) == 0: return zip([None], [None], [None], [None], [None]) - except plpy.SPIError, err: + except plpy.SPIError, e: plpy.debug('Query failed with exception %s: %s' % (err, pu.construct_neighbor_query(w_type, qvals))) - plpy.error('Query failed, check the input parameters') + plpy.error('Analysis failed: %s' % e) return zip([None], [None], [None], [None], [None]) ## build weight From 2ff20e596ee8f8ec0dbc30b53a25777262b27694 Mon Sep 17 00:00:00 2001 From: abelvm Date: Tue, 20 Sep 2016 12:57:41 +0200 Subject: [PATCH 11/14] add NN(s) support --- doc/08_interpolation.md | 6 +++--- src/pg/sql/08_interpolation.sql | 17 ++++++++++++++--- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/doc/08_interpolation.md b/doc/08_interpolation.md index 22fc1bc..87b5124 100644 --- a/doc/08_interpolation.md +++ b/doc/08_interpolation.md @@ -2,7 +2,7 @@ Function to interpolate a numeric attribute of a point in a scatter dataset of points, using one of three methos: -* [Nearest neighbor](https://en.wikipedia.org/wiki/Nearest-neighbor_interpolation) +* [Nearest neighbor(s)](https://en.wikipedia.org/wiki/Nearest-neighbor_interpolation) * [Barycentric](https://en.wikipedia.org/wiki/Barycentric_coordinate_system) * [IDW](https://en.wikipedia.org/wiki/Inverse_distance_weighting) @@ -15,7 +15,7 @@ Function to interpolate a numeric attribute of a point in a scatter dataset of p | query | text | query that returns at least `the_geom` and a numeric value as `attrib` | | point | geometry | The target point to calc the value | | method | integer | 0:nearest neighbor, 1: barycentric, 2: IDW| -| p1 | integer | IDW: limit the number of neighbors, 0->no limit| +| p1 | integer | limit the number of neighbors, IDW: 0->no limit, NN: 0-> closest one| | p2 | integer | IDW: order of distance decay, 0-> order 1| ### CDB_SpatialInterpolation (geom geometry[], values numeric[], point geometry, method integer DEFAULT 1, p1 integer DEFAULT 0, ps integer DEFAULT 0) @@ -28,7 +28,7 @@ Function to interpolate a numeric attribute of a point in a scatter dataset of p | values | numeric[] | Array of points' values for the param under study| | point | geometry | The target point to calc the value | | method | integer | 0:nearest neighbor, 1: barycentric, 2: IDW| -| p1 | integer | IDW: limit the number of neighbors, 0->no limit| +| p1 | integer | limit the number of neighbors, IDW: 0->no limit, NN: 0-> closest one| | p2 | integer | IDW: order of distance decay, 0-> order 1| ### Returns diff --git a/src/pg/sql/08_interpolation.sql b/src/pg/sql/08_interpolation.sql index 0937f09..608583d 100644 --- a/src/pg/sql/08_interpolation.sql +++ b/src/pg/sql/08_interpolation.sql @@ -1,4 +1,4 @@ --- 0: nearest neighbor +-- 0: nearest neighbor (s) -- 1: barymetric -- 2: IDW @@ -51,11 +51,17 @@ DECLARE output numeric; BEGIN output := -999.999; - -- nearest + + -- nearest neighbors + -- p1: limit the number of neighbors, 0-> closest one IF method = 0 THEN + IF p1 = 0 THEN + p1 := 1; + END IF; + WITH a as (SELECT unnest(geomin) as g, unnest(colin) as v) - SELECT a.v INTO output FROM a ORDER BY point<->a.g LIMIT 1; + SELECT avg(a.v) INTO output FROM a ORDER BY point<->a.g LIMIT p1::integer; RETURN output; -- barymetric @@ -121,6 +127,11 @@ BEGIN SELECT sum(b.f)/sum(b.k) INTO output FROM b; RETURN output; + -- krigin + ELSIF method = 3 THEN + + + END IF; RETURN -777.777; From 4902f6a9d487f9f9754c54353fec83741e7a8f4a Mon Sep 17 00:00:00 2001 From: abelvm Date: Tue, 20 Sep 2016 13:37:50 +0200 Subject: [PATCH 12/14] add NN(s) support --- src/pg/sql/08_interpolation.sql | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/pg/sql/08_interpolation.sql b/src/pg/sql/08_interpolation.sql index 608583d..d13d8e7 100644 --- a/src/pg/sql/08_interpolation.sql +++ b/src/pg/sql/08_interpolation.sql @@ -1,6 +1,8 @@ --- 0: nearest neighbor (s) +-- 0: nearest neighbor(s) -- 1: barymetric -- 2: IDW +-- 3: krigin + CREATE OR REPLACE FUNCTION CDB_SpatialInterpolation( IN query text, @@ -60,8 +62,9 @@ BEGIN p1 := 1; END IF; - WITH a as (SELECT unnest(geomin) as g, unnest(colin) as v) - SELECT avg(a.v) INTO output FROM a ORDER BY point<->a.g LIMIT p1::integer; + WITH a as (SELECT unnest(geomin) as g, unnest(colin) as v), + b as (SELECT a.v as v FROM a ORDER BY point<->a.g LIMIT p1::integer) + SELECT avg(b.v) INTO output FROM b; RETURN output; -- barymetric From 37e4fc7cad6510a80281832ee25513387a1f85aa Mon Sep 17 00:00:00 2001 From: abelvm Date: Tue, 20 Sep 2016 13:57:58 +0200 Subject: [PATCH 13/14] add NN(s) support --- src/pg/test/expected/08_interpolation_test.out | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pg/test/expected/08_interpolation_test.out b/src/pg/test/expected/08_interpolation_test.out index 1e4502a..e2c9287 100644 --- a/src/pg/test/expected/08_interpolation_test.out +++ b/src/pg/test/expected/08_interpolation_test.out @@ -1,7 +1,7 @@ SET client_min_messages TO WARNING; \set ECHO none - nn | nni | idw ------+--------------------------+----------------- - 200 | 238.41059602632179224595 | 341.46260750526 + nn | nni | idw +----------------------+--------------------------+----------------- + 200.0000000000000000 | 238.41059602632179224595 | 341.46260750526 (1 row) From 754e66c02cc4159be161098cc8389da7d48179f6 Mon Sep 17 00:00:00 2001 From: abelvm Date: Wed, 21 Sep 2016 14:24:35 +0200 Subject: [PATCH 14/14] leftovers and docs --- doc/08_interpolation.md | 3 +++ src/pg/sql/08_interpolation.sql | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/doc/08_interpolation.md b/doc/08_interpolation.md index 87b5124..c17269e 100644 --- a/doc/08_interpolation.md +++ b/doc/08_interpolation.md @@ -37,6 +37,9 @@ Function to interpolate a numeric attribute of a point in a scatter dataset of p |-------------|------|-------------| | value | numeric | Interpolated value at the given point, `-888.888` if the given point is out of the boundaries of the source points set | +Default values: +* -888.888: when using Barycentric, the target point is out of the realm of the input points +* -777.777: asking for a method not available #### Example Usage diff --git a/src/pg/sql/08_interpolation.sql b/src/pg/sql/08_interpolation.sql index d13d8e7..cb0a20a 100644 --- a/src/pg/sql/08_interpolation.sql +++ b/src/pg/sql/08_interpolation.sql @@ -1,7 +1,7 @@ -- 0: nearest neighbor(s) -- 1: barymetric -- 2: IDW --- 3: krigin +-- 3: krigin ---> TO DO CREATE OR REPLACE FUNCTION CDB_SpatialInterpolation( @@ -52,7 +52,7 @@ DECLARE vc numeric; output numeric; BEGIN - output := -999.999; + -- output := -999.999; -- nearest neighbors -- p1: limit the number of neighbors, 0-> closest one @@ -133,7 +133,7 @@ BEGIN -- krigin ELSIF method = 3 THEN - + -- TO DO END IF;