Computing the spatial autocorrelation of POIs locations in Berlin

Last updated
Was this helpful?
Was this helpful?
-- Create table with POI counts by grid cell
CREATE OR REPLACE TABLE project.dataset.berlin_poi_count_grid AS
SELECT
h3, COUNT(*) AS n_pois
FROM (
SELECT `carto-un`.carto.H3_FROMGEOGPOINT(geom, 9) AS h3
FROM cartobq.docs.osm_pois_berlin )
GROUP BY h3;
-- Compute Moran's I
CALL `carto-un`.carto.MORANS_I_H3_TABLE(
'project.dataset.berlin_poi_count_grid',
'project.dataset.berlin_poi_count_grid_mi',
'h3',
'n_pois',
1,
'exponential'
);
-- Read computed value
SELECT * FROM project.dataset.berlin_poi_count_grid_mi;-- Create table with POI counts by grid cell
CREATE OR REPLACE TABLE project.dataset.berlin_poi_count_grid AS
SELECT
h3, COUNT(*) AS n_pois
FROM (
SELECT `carto-un-eu`.carto.H3_FROMGEOGPOINT(geom, 9) AS h3
FROM cartobq.docs.osm_pois_berlin )
GROUP BY h3;
-- Compute Moran's I
CALL `carto-un-eu`.carto.MORANS_I_H3_TABLE(
'project.dataset.berlin_poi_count_grid',
'project.dataset.berlin_poi_count_grid_mi',
'h3',
'n_pois',
1,
'exponential'
);
-- Read computed value
SELECT * FROM project.dataset.berlin_poi_count_grid_mi;-- Create table with POI counts by grid cell
CREATE OR REPLACE TABLE project.dataset.berlin_poi_count_grid AS
SELECT
h3, COUNT(*) AS n_pois
FROM (
SELECT carto.H3_FROMGEOGPOINT(geom, 9) AS h3
FROM cartobq.docs.osm_pois_berlin )
GROUP BY h3;
-- Compute Moran's I
CALL carto.MORANS_I_H3_TABLE(
'project.dataset.berlin_poi_count_grid',
'project.dataset.berlin_poi_count_grid_mi',
'h3',
'n_pois',
1,
'exponential'
);
-- Read computed value
SELECT * FROM project.dataset.berlin_poi_count_grid_mi;