[postgis-users] How to generate polygon grid for tiled map services
Pierre Racine
Pierre.Racine at sbf.ulaval.ca
Fri Mar 30 07:05:26 PDT 2012
> I'm wondering if there is a formula to generate 20 tables (one for each zoom
> level) of square polygons, representing a tile grid of popular TMS like OSM or
> MapQuest?
> I guess there shoud be a way to convert x,y,z tile coordinates to lat/lon
> coordinates in PostGIS.
With PostGIS Raster you can now easily create a vector grid with ST_MakeEmptyRaster() and ST_PixelAsPolygons().
SELECT (gvxy).geom, (gvxy).x, (gvxy).y
FROM (SELECT ST_PixelAsPolygons(ST_MakeEmptyRaster(width, height, ulx, uly, scalex, scaley, 0, 0, srid)) gvxy) foo
Pierre
More information about the postgis-users
mailing list