create_spatial_lag
The following code calculates the spatial lag of a specific column according
to given spatial weights. For each row, it calculates the average value of a particular
column from neighboring locations. It uses the median_income
column and
spatial weights from a datastore.
select *
from table(
pyqEval(
'{
"oml_connect": true,
"table": "oml_user.la_block_groups",
"key_column": "geoid",
"column": "median_income",
"weights": {"ds_name":"spatial", "obj_name": "la_bg_knn4"}
}',
'{ "geoid": "VARCHAR2(50)", "MEDIAN_INCOME_SLAG": "NUMBER" }',
'create_spatial_lag'
)
);
The result contains the average income from neighboring locations for each row. Note that
the index comes from the key_column
parameter, which is the
geoid
column in this case.