Fwd: How to draw a map using python

Yuanchao Xu xuyuanchao37 at gmail.com
Sat Aug 9 21:44:56 EDT 2014


To kind whom it may concern:

I want to draw a map using python, not really a map with full information,
just a get together of a series of small shapes to reflect land use.

The data is like below

1 2 2 3 3 22 3 3 1 1 21 1 1 1 3 33 3 3 3 4 1

Each number represents one land use type. and their positions in the matrix
are their coordinates.

I used VBA to do that before, the whole map consists many small square
shapes representing land use, but since the data was so large, it took a
long time to generate the map, also delete the map.

My question are :

1. I wonder in python, is there any more fast way to generate this kind of
map, as a whole, not a series of shapes, i think that would be faster??

2. I have tried using contourf, as below, but it says "out of bounds for
axis 1", but actually, I printed X,Y and cordi, they have the same shape,
why still out of bounds?

   1.

   y = np.arange(0, 4 , 1)
   x = np.arange(0, 6 , 1)
   X,Y = np.meshgrid(x,y)
   # cordi is the matrix containing all the data# pyplot is imported before

   plt.contourf(X,Y, Cordi[X,Y], 8, alpha=.75, cmap='jet')


3. Some kind person has suggested me to use imshow to plot. I checked the
explanation of imshow, it deals more about images not plots, and it needs a
3D array to plot, in which for each pixel it needs 3 values to show the
color. I also tried, not so acceptable. The interfaces of each color are so
vague, and besides, when the data is large, it just failed to present. So,
if I use imshow, could I have some way to avoid those two problems?


Thank you very much for answering!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20140810/6d905d1d/attachment.html>


More information about the Python-list mailing list