Skip to content

Instantly share code, notes, and snippets.

31719 function calls (30684 primitive calls) in 0.116 seconds
Ordered by: standard name
ncalls tottime percall cumtime percall filename:lineno(function)
1 0.000 0.000 0.000 0.000 <string>:1(<module>)
1 0.000 0.000 0.000 0.000 <string>:1(ArgInfo)
1 0.000 0.000 0.000 0.000 <string>:1(ArgSpec)
1 0.000 0.000 0.000 0.000 <string>:1(Arguments)
1 0.000 0.000 0.000 0.000 <string>:1(Attribute)
@dnomadb
dnomadb / test.md
Last active August 29, 2015 14:13

makesurface cool-tools

Raster --> vector surface creation tools in python

Installation

From GitHub:

pip install -e [email protected]:mapbox/make-surface.git#egg=makesurface

lattice=# select quadtree like 'n1n0s%' as qt, avg(value) from latticegrid group by qt;
qt | avg
----+---------------------------
f | 0.36889253738457339608819
t | -7.09836274025862024720
(2 rows)
Time: 4827.139 ms
▶ time makesurface triangulate 10 --tile 0 0 0 | tippecanoe -o tippetest.mbtiles -f -z 5 -Z 5
bbox: 0 0 ffffffff ffbfffff
using layer name tippetest
Sorting 2639920 indices for 2097152 features
Merging: 100%
100.0% 5/31/31
makesurface triangulate 10 --tile 0 0 0 267.43s user 49.23s system 87% cpu 6:02.71 total
tippecanoe -o tippetest.mbtiles -f -z 5 -Z 5 106.24s user 1.94s system 24% cpu 7:15.16 total
▶ time parallel --header : "node ./bin/list-tiles --tile {x}/{y}/3 | node ./bin/get-triangles | makesurface fillfacets '/Users/dnomadb/Dropbox (MapBox)/datashare/gfstemp.tif' -np" ::: x {0..3} ::: y {0..3} | tippecanoe -o temps.mbtiles -f -z 6 -Z 6
bbox: 0 0 80000000 80000000
using layer name temps
Sorting 2733348 indices for 2097152 features
Merging: 100%
100.0% 6/32/32
parallel --header : ::: x {0..3} ::: y {0..3} 470.55s user 45.69s system 199% cpu 4:19.26 total
tippecanoe -o temps.mbtiles -f -z 6 -Z 6 136.09s user 3.80s system 40% cpu 5:49.18 total
(
select
st_union(wkb_geometry) as wkb_geometry,
avg(value) as tempval,
left(quadtree, (z(!scale_denominator!)+5)*2+1) as tqt
from latticegrid
where wkb_geometry && !bbox!
group by tqt
) as data
@class1: #245568;
@class2: #215668;
@class3: #1F5768;
@class4: #1D5969;
@class5: #1B5A69;
@class6: #195B69;
@class7: #165C69;
@class8: #145E69;
@class9: #115F69;
@class10: #0E6069;
z = 3
for t in range(2 ** z):
tbbox = mercantile.bounds(t, t, 3)
childSt = mercantile.tile(tbbox.west, tbbox.north, 11)
childEnd = mercantile.tile(tbbox.east, tbbox.north, 11)
print childSt
Tile(x=0, y=-1, z=11)
Tile(x=256, y=256, z=11)
Tile(x=512, y=511, z=11)
556141 function calls (553630 primitive calls) in 0.763 seconds
Ordered by: standard name
ncalls tottime percall cumtime percall filename:lineno(function)
1 0.000 0.000 0.000 0.000 <string>:1(<module>)
1 0.000 0.000 0.000 0.000 <string>:1(Affine)
1 0.000 0.000 0.000 0.000 <string>:1(ArgInfo)
1 0.000 0.000 0.000 0.000 <string>:1(ArgSpec)
1 0.000 0.000 0.000 0.000 <string>:1(Arguments)
556141 function calls (553630 primitive calls) in 0.752 seconds
Ordered by: standard name
ncalls tottime percall cumtime percall filename:lineno(function)
1 0.000 0.000 0.000 0.000 <string>:1(<module>)
1 0.000 0.000 0.000 0.000 <string>:1(Affine)
1 0.000 0.000 0.000 0.000 <string>:1(ArgInfo)
1 0.000 0.000 0.000 0.000 <string>:1(ArgSpec)
1 0.000 0.000 0.000 0.000 <string>:1(Arguments)