Skip to content

Instantly share code, notes, and snippets.

@ajashton
Created April 1, 2014 21:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ajashton/9923452 to your computer and use it in GitHub Desktop.
Save ajashton/9923452 to your computer and use it in GitHub Desktop.
-- ZRES
-- Takes a web mercator zoom level and returns the pixel resolution for that
-- scale, assuming 256x256 pixel tiles. Non-integer zoom levels are accepted.
-- For databases with the PostGIS extension enabled.
create or replace function zres(z float)
returns float
language plpgsql immutable
as $func$
begin
return (40075016.6855785/(256*2^z));
end;
$func$;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment