fix module call
This commit is contained in:
parent
60f52633fa
commit
ccccf68066
@ -4,13 +4,12 @@ CREATE OR REPLACE FUNCTION
|
||||
CDB_GetisOrdsG(
|
||||
subquery TEXT,
|
||||
column_name TEXT,
|
||||
w_type TEXT,
|
||||
num_ngbrs INT,
|
||||
permutations INT,
|
||||
geom_col TEXT,
|
||||
id_col TEXT)
|
||||
w_type TEXT DEFAULT 'knn',
|
||||
num_ngbrs INT DEFAULT 5,
|
||||
geom_col TEXT DEFAULT 'the_geom',
|
||||
id_col TEXT DEFAULT 'cartodb_id')
|
||||
RETURNS TABLE (z_val NUMERIC, p_val NUMERIC, rowid BIGINT)
|
||||
AS $$
|
||||
from crankshaft.clustering import getis
|
||||
return getis_ord(subquery, column_name, w_type, num_ngbrs, permutations, geom_col, id_col)
|
||||
from crankshaft.clustering import getis_ord
|
||||
return getis_ord(subquery, column_name, w_type, num_ngbrs, geom_col, id_col)
|
||||
$$ LANGUAGE plpythonu;
|
||||
|
@ -15,7 +15,7 @@ import crankshaft.pysal_utils as pu
|
||||
# High level interface ---------------------------------------
|
||||
|
||||
def getis_ord(subquery, attr,
|
||||
w_type, num_ngbrs, permutations, geom_col, id_col):
|
||||
w_type, num_ngbrs, geom_col, id_col):
|
||||
"""
|
||||
Getis-Ord's G
|
||||
Implementation building neighbors with a PostGIS database and Getis-Ord's G
|
||||
@ -39,13 +39,13 @@ def getis_ord(subquery, attr,
|
||||
# if there are no neighbors, exit
|
||||
if len(result) == 0:
|
||||
return pu.empty_zipped_array(3)
|
||||
except plpy.SPIError, e:
|
||||
plpy.error('Query failed: %s' % e)
|
||||
except plpy.SPIError, err:
|
||||
plpy.error('Query failed: %s' % err)
|
||||
|
||||
attr_vals = pu.get_attributes(result)
|
||||
weight = pu.get_weight(result, w_type, num_ngbrs)
|
||||
|
||||
# calculate LISA values
|
||||
getis = ps.esda.getisord(attr_vals, weight, star=True)
|
||||
getis = ps.esda.getisord.G_Local(attr_vals, weight, star=True)
|
||||
|
||||
return zip(getis.z_sim, getis.p_sim, weight.id_order)
|
||||
|
Loading…
Reference in New Issue
Block a user