This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import md5 | |
import urllib | |
import urllib2 | |
#the API Secret for your Project | |
secret = '9393c2df-e1c8-457c-adc1-a5b75210d52f' | |
#the User email address you querying (all lowercase) | |
email = 'andrewxhill@gmail.com' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import md5 | |
import urllib | |
import urllib2 | |
#the API Secret for your Project | |
secret = '9393c2df-e1c8-457c-adc1-a5b75210d52f' | |
#the User email address you querying (all lowercase) | |
email = 'andrewxhill@gmail.com' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import md5 | |
import urllib | |
import urllib2 | |
#the API Secret for your Project | |
secret = '9393c2df-e1c8-457c-adc1-a5b75210d52f' | |
#the User email address you querying (all lowercase) | |
email = 'andrewxhill@gmail.com' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#you have this | |
class Note(db.Model): | |
""" user note on a cell """ | |
cell = db.ReferenceProperty(Cell) | |
#Instead, do this, | |
class Note(db.Model): | |
""" user note on a cell """ | |
#parent = Cell #this is done on creation | |
cell = db.ReferenceProperty(collection='notes', Cell) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Another thought | |
The use of indexes can be super useful as it avoids serialization of all the data | |
by doing key only queries. Then, using the key returned to pull the parent which | |
would be the full set of data. So, something like this | |
""" | |
class CellIndex(db.Model): | |
#parent = Cell |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GIT | |
remote: git://github.com/ferblape/sequel-rails.git | |
revision: a283527d53895d6189f879bd96d2500b609b82e7 | |
specs: | |
sequel-rails (0.1.7) | |
actionpack (~> 3.0.0.rc) | |
activesupport (~> 3.0.0.rc) | |
railties (~> 3.0.0.rc) | |
sequel (~> 3.13) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
SUM(ST_Value(rast, 1, x, y)), count(*), SUM(ST_Value(rast, 1, x, y))/count(*) | |
FROM carbon_query_test_s CROSS JOIN | |
generate_series(1,10) As x CROSS JOIN generate_series(1,10) As y | |
WHERE rid in ( SELECT rid FROM carbon_query_test_s WHERE ST_Intersects(rast, ST_GeomFromText('MULTIPOLYGON(((18.511962890625 5.386335689520536,14.864501953125 2.141834969768584,18.775634765625 0.0769042737833478,22.510986328125 -0.5383221578577078,26.114501953125 0.8239462091017685,26.553955078125 3.3269862108134998,22.423095703125 6.085935520826564,18.511962890625 5.386335689520536)))',4326)) ) | |
AND | |
ST_Intersects( | |
ST_Translate (ST_MakeEnvelope( | |
ST_UpperLeftX(rast), ST_UpperLeftY(rast), | |
ST_UpperLeftX(rast) + ST_ScaleX(rast), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT SUM(ST_Value(rast, 1, x, y)), COUNT(*) | |
FROM carbon_query_test_s CROSS JOIN | |
generate_series(1,10) As x CROSS JOIN generate_series(1,10) As y | |
WHERE rid in ( SELECT rid FROM carbon_query_test_s WHERE ST_Intersects(rast, ST_GeomFromText('MULTIPOLYGON(((18.511962890625 5.386335689520536,14.864501953125 2.141834969768584,18.775634765625 0.0769042737833478,22.510986328125 -0.5383221578577078,26.114501953125 0.8239462091017685,26.553955078125 3.3269862108134998,22.423095703125 6.085935520826564,18.511962890625 5.386335689520536)))',4326)) ) | |
AND | |
ST_Intersects( | |
ST_Translate (ST_MakeEnvelope( | |
ST_UpperLeftX(rast), ST_UpperLeftY(rast), | |
ST_UpperLeftX(rast) + ST_ScaleX(rast), | |
ST_UpperLeftY(rast) + ST_ScaleY(rast), 4326 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT rid, | |
encode( | |
ST_AsPng( | |
ST_Resample( | |
ST_ClipEx( | |
rast, | |
ST_World2RasterCoordX( | |
rast, | |
foo.upper_left), | |
ST_World2RasterCoordY( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE OR REPLACE FUNCTION ST_ClipEx(rast raster, x int, y int, width int, height int) | |
RETURNS raster AS | |
$$ | |
DECLARE | |
newrast raster := ST_MakeEmptyRaster(width, height, ST_UpperLeftX(rast), ST_UpperLeftY(rast), | |
ST_ScaleX(rast), ST_ScaleY(rast), ST_SkewX(rast), ST_SkewY(rast), ST_SRID(rast)); | |
numband int := ST_Numbands(rast); | |
band int; | |
cx int; | |
cy int; |