Skip to content

Instantly share code, notes, and snippets.

@TheSkorm
Created April 21, 2014 13:54
Show Gist options
  • Select an option

  • Save TheSkorm/11143439 to your computer and use it in GitHub Desktop.

Select an option

Save TheSkorm/11143439 to your computer and use it in GitHub Desktop.
maxfields iitc export
def iitcexport(self):
textfile = open(self.outputDir+'iitc-import.txt','w')
textfile.write( "[")
first=True
for i in xrange(self.m):
p,q = self.orderedEdges[i]
for tri in self.a.edge[p][q]['fields']:
coords = np.array([ self.a.node[v]['xy'] for v in tri ])
iitcfield = []
for v in tri:
iitcfield.append(self.a.node[v]["e6"])
if first==False:
textfile.write( ",")
else:
first=False
textfile.write( """
{
"type": "polygon",
"latLngs": [
{
"lat": """ +str(iitcfield[0][0]/1000000)+ """,
"lng": """ +str(iitcfield[0][1]/1000000)+ """
},
{
"lat": """ +str(iitcfield[1][0]/1000000)+ """,
"lng": """ +str(iitcfield[1][1]/1000000)+ """
},
{
"lat": """ +str(iitcfield[2][0]/1000000)+ """,
"lng": """ +str(iitcfield[2][1]/1000000)+ """
}
],
"color": "#a24ac3"
}""")
textfile.write( "]")
@TheSkorm
Copy link
Author


 # This part assumes we're working with E6 latitude-longitude data
    e6 = locs
    locs = geometry.e6LLtoRads(locs)
    xyz  = geometry.radstoxyz(locs)
    xy   = geometry.gnomonicProj(locs,xyz)

    for i in xrange(n):
        a.node[i]['e6'] = e6[i]
        a.node[i]['geo'] = locs[i]
        a.node[i]['xyz'] = xyz [i]
        a.node[i]['xy' ] = xy  [i]

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