changed name of functions for observatory
This commit is contained in:
parent
eecbe39547
commit
bc67ae8f69
@ -1,6 +1,6 @@
|
||||
-- Moran's I (global)
|
||||
CREATE OR REPLACE FUNCTION
|
||||
cdb_moran (
|
||||
CDB_AreasOfInterest_Global (
|
||||
subquery TEXT,
|
||||
attr_name TEXT,
|
||||
permutations INT DEFAULT 99,
|
||||
@ -17,7 +17,7 @@ $$ LANGUAGE plpythonu;
|
||||
|
||||
-- Moran's I Local
|
||||
CREATE OR REPLACE FUNCTION
|
||||
cdb_moran_local (
|
||||
CDB_AreasOfInterest_Local(
|
||||
subquery TEXT,
|
||||
attr TEXT,
|
||||
permutations INT DEFAULT 99,
|
||||
@ -34,7 +34,7 @@ $$ LANGUAGE plpythonu;
|
||||
|
||||
-- Moran's I Rate (global)
|
||||
CREATE OR REPLACE FUNCTION
|
||||
cdb_moran_rate (
|
||||
CDB_AreasOfInterest_Global_Rate(
|
||||
subquery TEXT,
|
||||
numerator TEXT,
|
||||
denominator TEXT,
|
||||
@ -53,7 +53,7 @@ $$ LANGUAGE plpythonu;
|
||||
|
||||
-- Moran's I Local Rate
|
||||
CREATE OR REPLACE FUNCTION
|
||||
cdb_moran_local_rate(
|
||||
CDB_AreasOfInterest_Local_Rate(
|
||||
subquery TEXT,
|
||||
numerator TEXT,
|
||||
denominator TEXT,
|
||||
|
@ -110,7 +110,7 @@ INSERT INTO ppoints2 VALUES
|
||||
(24,'0101000020E61000009C5F91C5095C17C0C78784B15A4F4540'::geometry,'24','07',0.3, 1.0),
|
||||
(29,'0101000020E6100000C34D4A5B48E712C092E680892C684240'::geometry,'29','01',0.3, 1.0),
|
||||
(52,'0101000020E6100000406A545EB29A07C04E5F0BDA39A54140'::geometry,'52','19',0.0, 1.01)
|
||||
-- Moral functions perform some nondeterministic computations
|
||||
-- Areas of Interest functions perform some nondeterministic computations
|
||||
-- (to estimate the significance); we will set the seeds for the RNGs
|
||||
-- that affect those results to have repeateble results
|
||||
SELECT cdb_crankshaft._cdb_random_seeds(1234);
|
||||
@ -121,15 +121,15 @@ SELECT cdb_crankshaft._cdb_random_seeds(1234);
|
||||
|
||||
SELECT ppoints.code, m.quads
|
||||
FROM ppoints
|
||||
JOIN cdb_crankshaft.cdb_moran_local('SELECT * FROM ppoints', 'value') m
|
||||
JOIN cdb_crankshaft.CDB_AreasOfInterest_Local('SELECT * FROM ppoints', 'value') m
|
||||
ON ppoints.cartodb_id = m.ids
|
||||
ORDER BY ppoints.code;
|
||||
NOTICE: ** Constructing query
|
||||
CONTEXT: PL/Python function "cdb_moran_local"
|
||||
CONTEXT: PL/Python function "cdb_areasofinterest_local"
|
||||
NOTICE: ** Query returned with 52 rows
|
||||
CONTEXT: PL/Python function "cdb_moran_local"
|
||||
CONTEXT: PL/Python function "cdb_areasofinterest_local"
|
||||
NOTICE: ** Finished calculations
|
||||
CONTEXT: PL/Python function "cdb_moran_local"
|
||||
CONTEXT: PL/Python function "cdb_areasofinterest_local"
|
||||
code | quads
|
||||
------+-------
|
||||
01 | HH
|
||||
@ -194,15 +194,15 @@ SELECT cdb_crankshaft._cdb_random_seeds(1234);
|
||||
|
||||
SELECT ppoints2.code, m.quads
|
||||
FROM ppoints2
|
||||
JOIN cdb_crankshaft.cdb_moran_local_rate('SELECT * FROM ppoints2', 'numerator', 'denominator') m
|
||||
JOIN cdb_crankshaft.CDB_AreasOfInterest_Local_Rate('SELECT * FROM ppoints2', 'numerator', 'denominator') m
|
||||
ON ppoints2.cartodb_id = m.ids
|
||||
ORDER BY ppoints2.code;
|
||||
NOTICE: ** Constructing query
|
||||
CONTEXT: PL/Python function "cdb_moran_local_rate"
|
||||
CONTEXT: PL/Python function "cdb_areasofinterest_local_rate"
|
||||
NOTICE: ** Query returned with 51 rows
|
||||
CONTEXT: PL/Python function "cdb_moran_local_rate"
|
||||
CONTEXT: PL/Python function "cdb_areasofinterest_local_rate"
|
||||
NOTICE: ** Finished calculations
|
||||
CONTEXT: PL/Python function "cdb_moran_local_rate"
|
||||
CONTEXT: PL/Python function "cdb_areasofinterest_local_rate"
|
||||
code | quads
|
||||
------+-------
|
||||
01 | LL
|
||||
|
@ -1,14 +1,14 @@
|
||||
\i test/fixtures/ppoints.sql
|
||||
\i test/fixtures/ppoints2.sql
|
||||
|
||||
-- Moral functions perform some nondeterministic computations
|
||||
-- Areas of Interest functions perform some nondeterministic computations
|
||||
-- (to estimate the significance); we will set the seeds for the RNGs
|
||||
-- that affect those results to have repeateble results
|
||||
SELECT cdb_crankshaft._cdb_random_seeds(1234);
|
||||
|
||||
SELECT ppoints.code, m.quads
|
||||
FROM ppoints
|
||||
JOIN cdb_crankshaft.cdb_moran_local('SELECT * FROM ppoints', 'value') m
|
||||
JOIN cdb_crankshaft.CDB_AreasOfInterest_Local('SELECT * FROM ppoints', 'value') m
|
||||
ON ppoints.cartodb_id = m.ids
|
||||
ORDER BY ppoints.code;
|
||||
|
||||
@ -16,6 +16,6 @@ SELECT cdb_crankshaft._cdb_random_seeds(1234);
|
||||
|
||||
SELECT ppoints2.code, m.quads
|
||||
FROM ppoints2
|
||||
JOIN cdb_crankshaft.cdb_moran_local_rate('SELECT * FROM ppoints2', 'numerator', 'denominator') m
|
||||
JOIN cdb_crankshaft.CDB_AreasOfInterest_Local_Rate('SELECT * FROM ppoints2', 'numerator', 'denominator') m
|
||||
ON ppoints2.cartodb_id = m.ids
|
||||
ORDER BY ppoints2.code;
|
||||
|
@ -9,7 +9,7 @@ SET search_path TO public,cartodb,cdb_crankshaft;
|
||||
-- Exercise public functions
|
||||
SELECT ppoints.code, m.quads
|
||||
FROM ppoints
|
||||
JOIN cdb_moran_local('ppoints', 'value') m
|
||||
JOIN CDB_AreasOfInterest_Local('ppoints', 'value') m
|
||||
ON ppoints.cartodb_id = m.ids
|
||||
ORDER BY ppoints.code;
|
||||
SELECT round(cdb_overlap_sum(
|
||||
|
@ -14,6 +14,7 @@ import plpy
|
||||
def moran(subquery, attr_name, permutations, geom_col, id_col, w_type, num_ngbrs):
|
||||
"""
|
||||
Moran's I (global)
|
||||
Implementation building neighors with a PostGIS database and Moran's I core clusters with PySAL.
|
||||
Andy Eschbacher
|
||||
"""
|
||||
qvals = {"id_col": id_col,
|
||||
@ -172,8 +173,6 @@ def moran_local_rate(subquery, numerator, denominator, permutations, geom_col, i
|
||||
plpy.notice('** Exiting function')
|
||||
return zip([None], [None], [None], [None], [None])
|
||||
|
||||
plpy.notice('r.nrows() = %d' % r.nrows())
|
||||
|
||||
## collect attributes
|
||||
numer = get_attributes(r, 1)
|
||||
denom = get_attributes(r, 2)
|
||||
|
Loading…
Reference in New Issue
Block a user