Fwd: How to draw a map using python

Mark Lawrence breamoreboy at yahoo.co.uk
Sun Aug 10 06:13:32 EDT 2014


On 10/08/2014 02:44, Yuanchao Xu wrote:
> 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  2
> 2  3  3  1  1  2
> 1  1  1  1  3  3
> 3  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!
>

See http://matplotlib.org/ specifically 
http://matplotlib.org/basemap/users/examples.html

-- 
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence




More information about the Python-list mailing list