+-- This file contains functions (see `mz_SplitIntoTiles()`) for splitting a
+-- table of polygons into uniform tiles.
+
+-- A function that creates a table containing a grid of cells, taken from here:
+-- http://gis.stackexchange.com/questions/16374/how-to-create-a-regular-polygon-grid-in-postgis
 create or replace function mz_CreateGrid(
 	nrow integer,
 	ncol integer,

			);',
			table_name, grid_table_name
		);
		execute format(
			'drop table %1$s;
			alter table %1$s_intersected rename to %1$s;',
			grid_table_name
		);
	end
$$ language plpgsql;

			(st_ymax(table_bbox) - st_ymin(table_bbox)) / (tile_size_meters :: float)
		);

		-- Create a table containing a grid with cells of length/width
		-- `tile_size_meters`, covering the entire extent of `table_name`.
		execute format(
			'create table %s as
			select *
