## matplotlib-users

 [Matplotlib-users] Erroneous Horizontal Lines when Using Basemap From: Hatch, Sara J - 2009-03-12 22:47:51 Attachments: text/plain basemapBug.png
 Re: [Matplotlib-users] Erroneous Horizontal Lines when Using Basemap From: Jeff Whitaker - 2009-03-12 23:05:26 ```Hatch, Sara J wrote: > > Matplotlib Folks, > > I tried to use the orthographic projection in the basemap toolkit and > I’m finding that the parallel lines are not behaving correctly, i.e., > there are horizontal lines connecting the left and right side of the > map boundary where a curved latitude line intersects the map boundary. > I’ve included a sample script below and a figure illustrating the problem. > > import pylab > > import mpl_toolkits.basemap as basemap > > ortho = > basemap.Basemap(projection='ortho',lon_0=0,lat_0=50,rsphere=1737.4) > > ortho.drawparallels(pylab.arange(-90,90,30)) > > ortho.drawmeridians(pylab.arange(0,360,30)) > > ortho.drawmapboundary(fill_color='w') > > In addition, how do I change the x/y coordinates the center of the > projection to be (0,0)? With the above code, the center of the > bounding circle is at (1737.4,1737.4). > > Thanks for the help, > > Sara > Sara: If you take out the rsphere=1734.4 (thereby using the default value of 6370997), the jumpy lines go away. rsphere=1734.4 means assume the earth is a perfect sphere with a radius of 1734.4 meters. That's an awfully small earth - I think the jumpy lines are a result of roundoff errors in the map projection calculation for very small spheres. Still, that shouldn't happen, so I will look into it. Regarding the x/y coordinate of the middle of the plot - Basemap assigns the lower left corner of the map projection region an x/y value of 0,0 for most map projections. -Jeff ```
 Re: [Matplotlib-users] Erroneous Horizontal Lines when Using Basemap From: Jeff Whitaker - 2009-03-13 02:26:36 ```Hatch, Sara J wrote: > Jeff, > > My plan was to use the orthographic projection to represent the Moon (hence the 1737.4 km radius) and to plot a spacecraft trajectory around it. If I had read the rsphere documentation past the first half sentence I would have noticed that it was in meters instead of kilometers, sorry about that. Once I implemented this change, the horizontal lines go away. > Sara: OK, great. > Regarding the origin location: I have my spacecraft trajectory calculated with the origin being coincident with the center of the Moon. I can easily translate my coordinates to work with the origin not being the center of the projection, but would it be possible to implement some way to change where the origin is on the projection? > No, sorry - there's no easy way to do that. -Jeff > Thanks, > Sara > > > > -----Original Message----- > From: Jeff Whitaker [mailto:jswhit@...] > Sent: Thursday, March 12, 2009 4:05 PM > To: Hatch, Sara J > Cc: matplotlib-users@... > Subject: Re: [Matplotlib-users] Erroneous Horizontal Lines when Using Basemap > > Hatch, Sara J wrote: > >> Matplotlib Folks, >> >> I tried to use the orthographic projection in the basemap toolkit and >> I'm finding that the parallel lines are not behaving correctly, i.e., >> there are horizontal lines connecting the left and right side of the >> map boundary where a curved latitude line intersects the map boundary. >> I've included a sample script below and a figure illustrating the problem. >> >> import pylab >> >> import mpl_toolkits.basemap as basemap >> >> ortho = >> basemap.Basemap(projection='ortho',lon_0=0,lat_0=50,rsphere=1737.4) >> >> ortho.drawparallels(pylab.arange(-90,90,30)) >> >> ortho.drawmeridians(pylab.arange(0,360,30)) >> >> ortho.drawmapboundary(fill_color='w') >> >> In addition, how do I change the x/y coordinates the center of the >> projection to be (0,0)? With the above code, the center of the >> bounding circle is at (1737.4,1737.4). >> >> Thanks for the help, >> >> Sara >> >> > Sara: If you take out the rsphere=1734.4 (thereby using the default > value of 6370997), the jumpy lines go away. rsphere=1734.4 means assume > the earth is a perfect sphere with a radius of 1734.4 meters. That's an > awfully small earth - I think the jumpy lines are a result of roundoff > errors in the map projection calculation for very small spheres. Still, > that shouldn't happen, so I will look into it. > > Regarding the x/y coordinate of the middle of the plot - Basemap assigns > the lower left corner of the map projection region an x/y value of 0,0 > for most map projections. > > -Jeff > > ```