## matplotlib-users

 [Matplotlib-users] display a filled lat/lon basemap rectangle. From: Yeates, Mathew C (388D) - 2010-04-07 19:16:45 Attachments: Message as HTML ```Hi What is the simplest way to fill in a 1 degree by 1 degree rectangle on a basemap projection? Mathew ```
 Re: [Matplotlib-users] display a filled lat/lon basemap rectangle. From: Jeff Whitaker - 2010-04-07 20:54:44 ```Yeates, Mathew C (388D) wrote: > > > > Hi > > What is the simplest way to fill in a 1 degree by 1 degree rectangle > on a basemap projection? > > > > Mathew > Mathew: Try this (for a 10x10 rectangle, but you get the idea) from matplotlib.patches import Polygon import matplotlib.pyplot as plt from mpl_toolkits.basemap import Basemap map = Basemap(projection='moll',lon_0=0) x1,y1 = map(-10,-10) x2,y2 = map(-10,10) x3,y3 = map(10,10) x4,y4 = map(10,-10) p = Polygon([(x1,y1),(x2,y2),(x3,y3),(x4,y4)],\ facecolor='red',edgecolor='blue',linewidth=2) plt.gca().add_patch(p) map.drawcoastlines() map.drawmapboundary() plt.show() -Jeff > ```
 Re: [Matplotlib-users] display a filled lat/lon basemap rectangle. From: Mathew Yeates - 2010-04-07 21:19:38 Attachments: Message as HTML ```I think this will only work with some projections but not all. I looked at the code for tissot. It's pretty hairy but it almost does what I want. (It draws projected circles instead of projected rectangles. On Wed, Apr 7, 2010 at 1:54 PM, Jeff Whitaker wrote: > Yeates, Mathew C (388D) wrote: > > > > > > > > Hi > > > > What is the simplest way to fill in a 1 degree by 1 degree rectangle > > on a basemap projection? > > > > > > > > Mathew > > > > Mathew: Try this (for a 10x10 rectangle, but you get the idea) > > from matplotlib.patches import Polygon > import matplotlib.pyplot as plt > from mpl_toolkits.basemap import Basemap > map = Basemap(projection='moll',lon_0=0) > x1,y1 = map(-10,-10) > x2,y2 = map(-10,10) > x3,y3 = map(10,10) > x4,y4 = map(10,-10) > p = Polygon([(x1,y1),(x2,y2),(x3,y3),(x4,y4)],\ > facecolor='red',edgecolor='blue',linewidth=2) > plt.gca().add_patch(p) > map.drawcoastlines() > map.drawmapboundary() > plt.show() > > -Jeff > > > > > > ------------------------------------------------------------------------------ > Download Intel® Parallel Studio Eval > Try the new software tools for yourself. Speed compiling, find bugs > proactively, and fine-tune applications for parallel performance. > See why Intel Parallel Studio got high marks during beta. > http://p.sf.net/sfu/intel-sw-dev > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users@... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > ```
 Re: [Matplotlib-users] display a filled lat/lon basemap rectangle. From: Jeff Whitaker - 2010-04-08 01:24:44 ```Mathew Yeates wrote: > I think this will only work with some projections but not all. I > looked at the code for tissot. It's pretty hairy but it almost does > what I want. (It draws projected circles > instead of projected rectangles. Mathew: You said you wanted a NxN degree polygon - that's what I gave you. What exactly do you want? A rectangle in map projection coordinates? A rectangle in lat/lon coordinates? A circle? -Jeff > > > On Wed, Apr 7, 2010 at 1:54 PM, Jeff Whitaker > wrote: > > Yeates, Mathew C (388D) wrote: > > > > > > > > Hi > > > > What is the simplest way to fill in a 1 degree by 1 degree > rectangle > > on a basemap projection? > > > > > > > > Mathew > > > > Mathew: Try this (for a 10x10 rectangle, but you get the idea) > > from matplotlib.patches import Polygon > import matplotlib.pyplot as plt > from mpl_toolkits.basemap import Basemap > map = Basemap(projection='moll',lon_0=0) > x1,y1 = map(-10,-10) > x2,y2 = map(-10,10) > x3,y3 = map(10,10) > x4,y4 = map(10,-10) > p = Polygon([(x1,y1),(x2,y2),(x3,y3),(x4,y4)],\ > facecolor='red',edgecolor='blue',linewidth=2) > plt.gca().add_patch(p) > map.drawcoastlines() > map.drawmapboundary() > plt.show() > > -Jeff > > > > > ------------------------------------------------------------------------------ > Download Intel® Parallel Studio Eval > Try the new software tools for yourself. Speed compiling, find bugs > proactively, and fine-tune applications for parallel performance. > See why Intel Parallel Studio got high marks during beta. > http://p.sf.net/sfu/intel-sw-dev > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users@... > > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > ```
 Re: [Matplotlib-users] display a filled lat/lon basemap rectangle. From: Mathew Yeates - 2010-04-08 01:39:49 Attachments: Message as HTML ```lets say I want to shade the area with lat/lon corners 34.-117 and 35,-116 but my map was created with projection='aeqd' The shade area will not be a rectangle. In fact the edges will be curved. See the basemap code for "tissot". I think every point on the boundary of the lat/lon box has to projected to a line segment. The collection of resulting segments forms an irregular polygon. Mathew On Wed, Apr 7, 2010 at 6:24 PM, Jeff Whitaker wrote: > Mathew Yeates wrote: > >> I think this will only work with some projections but not all. I looked at >> the code for tissot. It's pretty hairy but it almost does what I want. (It >> draws projected circles >> instead of projected rectangles. >> > Mathew: > > You said you wanted a NxN degree polygon - that's what I gave you. What > exactly do you want? A rectangle in map projection coordinates? A > rectangle in lat/lon coordinates? A circle? > > -Jeff > >> >> >> On Wed, Apr 7, 2010 at 1:54 PM, Jeff Whitaker > jswhit@...>> wrote: >> >> Yeates, Mathew C (388D) wrote: >> > >> > >> > >> > Hi >> > >> > What is the simplest way to fill in a 1 degree by 1 degree >> rectangle >> > on a basemap projection? >> > >> > >> > >> > Mathew >> > >> >> Mathew: Try this (for a 10x10 rectangle, but you get the idea) >> >> from matplotlib.patches import Polygon >> import matplotlib.pyplot as plt >> from mpl_toolkits.basemap import Basemap >> map = Basemap(projection='moll',lon_0=0) >> x1,y1 = map(-10,-10) >> x2,y2 = map(-10,10) >> x3,y3 = map(10,10) >> x4,y4 = map(10,-10) >> p = Polygon([(x1,y1),(x2,y2),(x3,y3),(x4,y4)],\ >> facecolor='red',edgecolor='blue',linewidth=2) >> plt.gca().add_patch(p) >> map.drawcoastlines() >> map.drawmapboundary() >> plt.show() >> >> -Jeff >> > >> >> >> >> ------------------------------------------------------------------------------ >> Download Intel® Parallel Studio Eval >> Try the new software tools for yourself. Speed compiling, find bugs >> proactively, and fine-tune applications for parallel performance. >> See why Intel Parallel Studio got high marks during beta. >> http://p.sf.net/sfu/intel-sw-dev >> _______________________________________________ >> Matplotlib-users mailing list >> Matplotlib-users@... >> >> >> https://lists.sourceforge.net/lists/listinfo/matplotlib-users >> >> >> > ```
 Re: [Matplotlib-users] display a filled lat/lon basemap rectangle. From: Jeff Whitaker - 2010-04-08 01:45:58 ```Mathew Yeates wrote: > lets say I want to shade the area with lat/lon corners 34.-117 and > 35,-116 > > but my map was created with projection='aeqd' > > The shade area will not be a rectangle. In fact the edges will be > curved. See the basemap code for "tissot". I think every point on the > boundary of the lat/lon box has to projected to a line segment. The > collection of resulting segments forms an irregular polygon. > > Mathew Mathew: Right - it will only be a rectangle in a cylindrical projection. The question remains - what do you want? If you want a rectangle in map projection coordinates, just specify the vertices of a rectangle in map projection coordinates. If you really want a polygon with vertices corresponding to those lat/on values, a polygon with curved sides is the right answer for that map projection. -Jeff > > > > > On Wed, Apr 7, 2010 at 6:24 PM, Jeff Whitaker > wrote: > > Mathew Yeates wrote: > > I think this will only work with some projections but not all. > I looked at the code for tissot. It's pretty hairy but it > almost does what I want. (It draws projected circles > instead of projected rectangles. > > Mathew: > > You said you wanted a NxN degree polygon - that's what I gave you. > What exactly do you want? A rectangle in map projection > coordinates? A rectangle in lat/lon coordinates? A circle? > > -Jeff > > > > On Wed, Apr 7, 2010 at 1:54 PM, Jeff Whitaker > > >> wrote: > > Yeates, Mathew C (388D) wrote: > > > > > > > > Hi > > > > What is the simplest way to fill in a 1 degree by 1 degree > rectangle > > on a basemap projection? > > > > > > > > Mathew > > > > Mathew: Try this (for a 10x10 rectangle, but you get the idea) > > from matplotlib.patches import Polygon > import matplotlib.pyplot as plt > from mpl_toolkits.basemap import Basemap > map = Basemap(projection='moll',lon_0=0) > x1,y1 = map(-10,-10) > x2,y2 = map(-10,10) > x3,y3 = map(10,10) > x4,y4 = map(10,-10) > p = Polygon([(x1,y1),(x2,y2),(x3,y3),(x4,y4)],\ > facecolor='red',edgecolor='blue',linewidth=2) > plt.gca().add_patch(p) > map.drawcoastlines() > map.drawmapboundary() > plt.show() > > -Jeff > > > > > > ------------------------------------------------------------------------------ > Download Intel® Parallel Studio Eval > Try the new software tools for yourself. Speed compiling, > find bugs > proactively, and fine-tune applications for parallel > performance. > See why Intel Parallel Studio got high marks during beta. > http://p.sf.net/sfu/intel-sw-dev > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users@... > > > > > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > > > ```