Skip to content
This repository has been archived by the owner on Aug 2, 2019. It is now read-only.

Rendering a Map in Django #127

Open
sam8dec opened this issue Oct 7, 2014 · 0 comments
Open

Rendering a Map in Django #127

sam8dec opened this issue Oct 7, 2014 · 0 comments

Comments

@sam8dec
Copy link

sam8dec commented Oct 7, 2014

Hi,

I am building a website using DJango and need to generate some maps. I have created the map using vincent in the following manner:

state_topo = r'us_states.topo.json'
geo_data = [{'name': 'states','url': state_topo,'feature': 'us_states.geo'}]
vis = vincent.Map(data=gdf, geo_data=geo_data, scale=800,projection='albersUsa', data_bind='MENTIONS', data_key='STATE',map_key={'states': 'properties.NAME'}, brew='RdPu')
vis.scales[0].type='threshold'
vis.scales[0].domain = list(domain)
vis.legend(title='Mentions')

Is there any way I can return this map as an HttpResponse, similar to what we do for matplotlib charts:

buffer = StringIO.StringIO()
canvas = pylab.get_current_fig_manager().canvas
canvas.draw()
pilImage = PIL.Image.fromstring("RGB", canvas.get_width_height(), canvas.tostring_rgb())
pilImage.save(buffer, "PNG")
pylab.close()
return HttpResponse(buffer.getvalue(), content_type="image/png")

?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant