adding the spatial lag function

This commit is contained in:
mehak-sachdeva
2017-03-09 09:39:22 -05:00
parent d500212426
commit d764f7446f
2 changed files with 3 additions and 4 deletions

View File

@@ -7,11 +7,10 @@ CREATE OR REPLACE FUNCTION
num_ngbrs INT,
geom_col TEXT,
id_col TEXT)
RETURNS TABLE (lag NUMERIC, rowid INT)
RETURNS TABLE (spatial_lag NUMERIC, rowid INT)
AS $$
from crankshaft.spatial_lag import Spatial
spatial = Spatial()
# TODO: use named parameters or a dictionary
return spatial.spatial_lag(subquery, column_name, w_type,
num_ngbrs, geom_col, id_col)
$$ LANGUAGE plpythonu;

View File

@@ -41,6 +41,6 @@ class Spatial:
# calculate spatial_lag values
lag = ps.weights.spatial_lag.lag_spatial(weight, attr_vals)
spatial_lag = ps.weights.spatial_lag.lag_spatial(weight, attr_vals)
return zip(lag, weight.id_order)
return zip(spatial_lag, weight.id_order)