-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

I'm developing a websuite for open meshed networks written in django. I
must admit, matplotlib and such was kinda hard stuff to step into. Most
examples and documentation is only based on the pylab api, which isn't
well suited for my purpos, because Django runs best with mod-python.

Anyways. I'm wrote a function which generates tiles for google maps and
those should be overlayers with transparent background.

My code currently looks like this:


from matplotlib.toolkits.basemap import Basemap
from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas
from matplotlib.figure import Figure

[...]

def mktopo(ll_lng, ll_lat, ur_lng, ur_lat, aspect, filename, state):
    """Generates atopo tile for given latitude/longitude pairs"""
    dpi = 64
    fig = Figure()
    canvas = FigureCanvas(fig)
    # what does this do ???
    #fig.set_facecolor((1.0,1.0,0,0.0))

    m =
Basemap(llcrnrlon=ll_lng,llcrnrlat=ll_lat,urcrnrlon=ur_lng,urcrnrlat=ur_lat,
        resolution='c',area_thresh=1000.,projection='merc',lat_ts=-8.0)

    m.ax = fig.add_axes([0, 0, 1, 1], axisbg=(1.0,1.0,0.0,0.0),
frameon=False )
    # 72 dpi
    # we need 256x256 pixel images
    fig.set_figsize_inches(256/dpi, 256/dpi)

    nodes = Node.objects.exclude(gps_position_lat=False)
    lats=[]
    lons=[]
    for node in nodes:
        lons.append(node.gps_position_lng)
        lats.append(node.gps_position_lat)
        #print node
        #a = m(node.gps_position_lat,node.gps_position_lng)
        #print a
    x,y = m(lons,lats)

    m.plot(x,y,'bo')
    canvas.print_figure(filename, dpi=dpi)


kindly regards
   Daniel
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (GNU/Linux)
Comment: GnuPT 2.7.2
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFE0Udmy/mkIQp7AD0RAtLGAJsGK23BKKCr7vAMIqjyuYdRlHdf7wCgnvCI
Oj32/fRh2SClDf7+dUaKQEM=
=6zWI
-----END PGP SIGNATURE-----

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to