Sei sulla pagina 1di 3

11/18/2014

Plotting cylindrical map data over a 3D sphere in Python - Stack Overflow


sign up

log in

tour

help

stack overflow careers

Ad Options

Ads by Lyrics

Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no
registration required.

Take the 2-minute tour

Plotting cylindrical map data over a 3D sphere in Python


Suppose I have an image with a cylindrical map of a planet, say one of these:
http://www.johnstonsarchive.net/spaceart/cylmaps.html
And I want to plot it over a 3D sphere to recover the original figure of the planet.
Is there a way to do it using a Python package like matplotlib, mayavi, basemap or similar?
python

3d

matplotlib

plot

edited Jun 30 '13 at 5:49

asked Jun 28 '13 at 13:02


Juanlu001
615 7 26

add a comment

2 Answers
the basemap toolkit is ideal for this task.
The Problem seems to be that you don't really have the data, i.e. something like lat,lon,value for each
pixel. The problem is also that for a given image, you normally don't know the projection which was used
to create the image, therefore you cannot do the back-transformation to get the original data.
If you just like to plot a image of the earth, use the bluemarble() function from the basemap toolkit:
http://wiki.scipy.org/Cookbook/Matplotlib/Maps
answered Jun 28 '13 at 13:49
Raphael Roth
624 3 12
I am not interested on Earth precisely, but your answer gave me great insight: the bluemarble function calls
warpimage : github.com/matplotlib/basemap/blob/master/lib/mpl_toolkits/ which might be exactly what I
want. I'll try this later, thanks. Juanlu001 Jun 28 '13 at 14:25
add a comment

Thanks to Raphael Roth answer I finally found what I was looking for: the function warpimage.
Here is a very minimal example. Using this cylindrical map of Venus, and based on the simple example of
the cookbook:

http://stackoverflow.com/questions/17365364/plotting-cylindrical-map-data-over-a-3d-sphere-in-python

1/3

11/18/2014

Plotting cylindrical map data over a 3D sphere in Python - Stack Overflow


from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt
import numpy as np
# set up orthographic map projection with
# perspective of satellite looking down at 50N, 100W.
# use low resolution coastlines.
# don't plot features that are smaller than 1000 square km.
map = Basemap(projection='ortho', lat_0 = 50, lon_0 = -100,
resolution = 'l', area_thresh = 1000.)
# plot surface
map.warpimage(image='venuscyl4.jpg')
# draw the edge of the map projection region (the projection limb)
map.drawmapboundary()
# draw lat/lon grid lines every 30 degrees.
map.drawmeridians(np.arange(0, 360, 30))
map.drawparallels(np.arange(-90, 90, 30))
plt.show()
produces the following output:
Ad Options

WebSpades Ads

Ads by Lyrics

Trust Rating

95%
stackoverflow.com

answered Jun 28 '13 at 23:43


Juanlu001
615 7 26

cool, good to know that this is possible Raphael Roth Jun 29 '13 at 5:13
add a comment

Not the answer you're looking for? Browse other questions tagged python 3d
matplotlib

plot or ask your own question.

http://stackoverflow.com/questions/17365364/plotting-cylindrical-map-data-over-a-3d-sphere-in-python

2/3

11/18/2014

Plotting cylindrical map data over a 3D sphere in Python - Stack Overflow

Ads by Lyrics

http://stackoverflow.com/questions/17365364/plotting-cylindrical-map-data-over-a-3d-sphere-in-python

Ad Options

3/3

Potrebbero piacerti anche