Skip to content

Instantly share code, notes, and snippets.

@javisantana
Last active August 29, 2015 14:17
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save javisantana/37ddfe3a410a347a2a68 to your computer and use it in GitHub Desktop.
Save javisantana/37ddfe3a410a347a2a68 to your computer and use it in GitHub Desktop.
test_postgis=# select count(*) from sigpac_47_valladolid_parfe;
count
--------
342691
test_postgis=# select sum(st_memsize(the_geom_webmercator)) from sigpac_47_valladolid_parfe;
sum
-----------
254827296
(1 row)
test_postgis=# copy (
with a as (
select CDB_XYZ_resolution(0) as res, ceil(log(CDB_XYZ_resolution(0)))::int as decimals
)
select ST_AsTWKB(
ST_ClipByBox2d(
st_snaptogrid(the_geom_webmercator, res/10, res/10),
CDB_XYZ_Extent(0, 0, 0)
),
decimals
) from sigpac_47_valladolid_parfe, a) to '/tmp/tile.test.bin';
➜ postgis git:(quadtree) ✗ ls -lh /tmp/tile.test.bin
-rw-r--r-- 1 j wheel 3.3M Mar 14 10:19 /tmp/tile.test.bin
➜ postgis git:(quadtree) ✗ ls -lh /tmp/tile.test.bin
-rw-r--r-- 1 j wheel 3.3M Mar 14 10:19 /tmp/tile.test.bin
➜ postgis git:(quadtree) ✗ gzip /tmp/tile.test.bin
➜ postgis git:(quadtree) ✗ ls -lh /tmp/tile.test.bin.gz
-rw-r--r-- 1 j wheel 17K Mar 14 10:19 /tmp/tile.test.bin.gz
with a as (
select CDB_XYZ_resolution(0) as res, ceil(log(CDB_XYZ_resolution(0)))::int as decimals
)
select ST_AsTWKB(
ST_ClipByBox2d(
st_snaptogrid(the_geom_webmercator, res/10, res/10),
CDB_XYZ_Extent(0, 0, 0)
),
decimals
) from sigpac_47_valladolid_parfe, a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment