Skip to content

Instantly share code, notes, and snippets.

@eightysteele
Created August 13, 2011 22:55
Show Gist options
  • Select an option

  • Save eightysteele/1144340 to your computer and use it in GitHub Desktop.

Select an option

Save eightysteele/1144340 to your computer and use it in GitHub Desktop.
[dict(cellkey=k, doc=simplejson.dumps(cells[k])) for k in cells.keys()]
@tucotuco
Copy link
Copy Markdown

Gives this:

4386-4956,"{""_id"": ""4386-4956"", ""b"": [[""-124.6731519"", ""48.7""], [""-124.6605375"", ""48.6916667""]], ""t"": ""11"", ""v"": {""b16"": ""1084""}}"
4371-4956,"{""_id"": ""4371-4956"", ""b"": [[""-124.8623682"", ""48.7""], [""-124.8497538"", ""48.6916667""]], ""t"": ""11"", ""v"": {""b16"": ""1092""}}"
4374-4956,"{""_id"": ""4374-4956"", ""b"": [[""-124.8245249"", ""48.7""], [""-124.8119105"", ""48.6916667""]], ""t"": ""11"", ""v"": {""b16"": ""1078""}}"
4377-4956,"{""_id"": ""4377-4956"", ""b"": [[""-124.7866817"", ""48.7""], [""-124.7740672"", ""48.6916667""]], ""t"": ""11"", ""v"": {""b16"": ""1034""}}"
4383-4956,"{""_id"": ""4383-4956"", ""b"": [[""-124.7109951"", ""48.7""], [""-124.6983807"", ""48.6916667""]], ""t"": ""11"", ""v"": {""b16"": ""1079""}}"
4375-4956,"{""_id"": ""4375-4956"", ""b"": [[""-124.8119105"", ""48.7""], [""-124.7992961"", ""48.6916667""]], ""t"": ""11"", ""v"": {""b16"": ""1034""}}"
4369-4956,"{""_id"": ""4369-4956"", ""b"": [[""-124.887597"", ""48.7""], [""-124.8749826"", ""48.6916667""]], ""t"": ""11"", ""v"": {""b16"": ""1088""}}"
4388-4956,"{""_id"": ""4388-4956"", ""b"": [[""-124.647923"", ""48.7""], [""-124.6353086"", ""48.6916667""]], ""t"": ""11"", ""v"": {""b16"": ""1054""}}"
4381-4956,"{""_id"": ""4381-4956"", ""b"": [[""-124.736224"", ""48.7""], [""-124.7236096"", ""48.6916667""]], ""t"": ""11"", ""v"": {""b16"": ""1012""}}"
4373-4956,"{""_id"": ""4373-4956"", ""b"": [[""-124.8371393"", ""48.7""], [""-124.8245249"", ""48.6916667""]], ""t"": ""11"", ""v"": {""b16"": ""109""}}"
4387-4956,"{""_id"": ""4387-4956"", ""b"": [[""-124.6605375"", ""48.7""], [""-124.647923"", ""48.6916667""]], ""t"": ""11"", ""v"": {""b16"": ""106""}}"
4380-4956,"{""_id"": ""4380-4956"", ""b"": [[""-124.7488384"", ""48.7""], [""-124.736224"", ""48.6916667""]], ""t"": ""11"", ""v"": {""b16"": ""1008""}}"
4385-4956,"{""_id"": ""4385-4956"", ""b"": [[""-124.6857663"", ""48.7""], [""-124.6731519"", ""48.6916667""]], ""t"": ""11"", ""v"": {""b16"": ""1072""}}"
4368-4956,"{""_id"": ""4368-4956"", ""b"": [[""-124.9002115"", ""48.7""], [""-124.887597"", ""48.6916667""]], ""t"": ""11"", ""v"": {""b16"": ""1087""}}"
4372-4956,"{""_id"": ""4372-4956"", ""b"": [[""-124.8497538"", ""48.7""], [""-124.8371393"", ""48.6916667""]], ""t"": ""11"", ""v"": {""b16"": ""1108""}}"
4384-4956,"{""_id"": ""4384-4956"", ""b"": [[""-124.6983807"", ""48.7""], [""-124.6857663"", ""48.6916667""]], ""t"": ""11"", ""v"": {""b16"": ""1068""}}"
4378-4956,"{""_id"": ""4378-4956"", ""b"": [[""-124.7740672"", ""48.7""], [""-124.7614528"", ""48.6916667""]], ""t"": ""11"", ""v"": {""b16"": ""103""}}"
4376-4956,"{""_id"": ""4376-4956"", ""b"": [[""-124.7992961"", ""48.7""], [""-124.7866817"", ""48.6916667""]], ""t"": ""11"", ""v"": {""b16"": ""1016""}}"
4379-4956,"{""_id"": ""4379-4956"", ""b"": [[""-124.7614528"", ""48.7""], [""-124.7488384"", ""48.6916667""]], ""t"": ""11"", ""v"": {""b16"": ""101""}}"
4370-4956,"{""_id"": ""4370-4956"", ""b"": [[""-124.8749826"", ""48.7""], [""-124.8623682"", ""48.6916667""]], ""t"": ""11"", ""v"": {""b16"": ""1082""}}"
4382-4956,"{""_id"": ""4382-4956"", ""b"": [[""-124.7236096"", ""48.7""], [""-124.7109951"", ""48.6916667""]], ""t"": ""11"", ""v"": {""b16"": ""1055""}}"

@tucotuco
Copy link
Copy Markdown

for row in dr:
    cellkey = row.get('CellKey')
    if not cells.has_key(cellkey):
        cells[cellkey] = {
            '_id': cellkey,
            't': options.key,  # tile number
            'b': getboundingbox(cellkey, cells_per_degree), # boundingbox 
            'v': {}  # dictionary of variables (tmean1,...tmin1,...tmax1,...alt,...prec1,...bio1,...)
            }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment