Hi,
documentation of mpl_toolkits.basemap.warpimage
(http://matplotlib.sourceforge.net/basemap/doc/html/api/basemap_api.html#mpl_toolkits.basemap.Basemap.warpimage)
states that it could only be used with a very specific set of images:
"Specified image must have pixels covering the whole globe in a
regular lat/lon grid, starting and -180W and the South Pole.", so your
image won't work - it is curved, there is no obvious (linear)
transformation from (x,y) to (lat, long). Examples of good images are
given here: 
http://earthobservatory.nasa.gov/Features/BlueMarble/BlueMarble_monthlies.php

There are easy ways to mimic your picture with native Basemap tools,
like in this examples:
http://matplotlib.sourceforge.net/basemap/doc/html/users/geography.html

But if you would specifically use your own image, the only way I see
is to come up with a transformation function transforming lat and long
coordinates to x,y coordinates of your specific picture. If you would
write such a function yourself than you could easily use ax.plot,
ax.scatter or any other plotting routine to place stuff in correct
place in respect to your picture. Giving (lat, long) of stuff you
would like to draw, than transforming to (x,y) with the function, and
than using those with plotting routines at the same axis you have
place your picture, with for example imshow routine with proper
zorder.

Hope this clears a problem a little bit,
JS


On Fri, Sep 10, 2010 at 13:06, izzybitsie <isid...@juno.com> wrote:
>
> Hi,
> I'm new to matplotlib and I'm looking for an easy way to plot geographical
> data on a background map: bkgmap.png
> http://old.nabble.com/file/p29679002/bkgmap.png
> So far I only found out about warpimage() to do this but only part of
> bkgmap.png comes up in the output image.  I think this is because this image
> has no pixels covering all the world.
> http://old.nabble.com/file/p29679002/partialbkg_polygon.png
>
> Any idea on how to insert this image as background?
> THANKS
>
> Code: the polygon displays in right position even though background doesn't
> show OK (tested with map,lat/lon lines drawn too)
>
> import sys
> import Image, ImageDraw  # PIL
> from matplotlib.patches import Polygon
> from mpl_toolkits.basemap import Basemap
> import matplotlib.image as mpimg
> import matplotlib.pyplot as plt
> import numpy as np
>
> lat0=48
> lon0=13
> lllon=-15
> lllat=20
> urlon=73
> urlat=57
> map =
> Basemap(projection='stere',lat_0=lat0,lon_0=lon0,llcrnrlon=lllon,llcrnrlat=lllat,urcrnrlon=urlon,urcrnrlat=urlat,
>              resolution='c',area_thresh=1000.)
> map.warpimage(image='bkgmap.png',scale=None,ax=plt.gca())
> # points
> lat = [50.,55.,45.,40.,50.]
> lon = [-20.,-10.,10.,-10.,-20.]
> x0,y0 = map(lon[0],lat[0])
> x1,y1 = map(lon[1],lat[1])
> x2,y2 = map(lon[2],lat[2])
> x3,y3 = map(lon[3],lat[3])
> x4,y4 = map(lon[4],lat[4])
> plt.gca().add_patch(Polygon([(x0,y0),(x1,y1),(x2,y2),(x3,y3),(x4,y4)],fill=1,facecolor='red',edgecolor='black'))
> plt.show()
> --
> View this message in context: 
> http://old.nabble.com/matplotlib-basemap-plot-geo-data-on-background-map-tp29679002p29679002.html
> Sent from the matplotlib - users mailing list archive at Nabble.com.
>
>
> ------------------------------------------------------------------------------
> Start uncovering the many advantages of virtual appliances
> and start using them to simplify application deployment and
> accelerate your shift to cloud computing
> http://p.sf.net/sfu/novell-sfdev2dev
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>

------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to