Text of discourse.matplotlib.org › t › background-basemaps-in-basemap › 17265 as Styx crawled it on Nov 18, 2026. The page may have changed since. Only its words are kept, without pictures or layout, and only the first part of a long page.

Open the live page

Background basemaps in Basemap - matplotlib-users - Matplotlib

Background basemaps in Basemap Community matplotlib-users _Jeff_Whitaker1 August 25, 2012, 10:18pm 1 Klo: For cylindrical equidistant maps (projection='cyl') it will be easy, since the corner lat/lon values are all that is needed. For other projections, we'll need a way to translate EPSG projection codes into Basemap kwargs. Jeff, how is it done for static bitmaps as bluemarble, etopo... ? Can't the same be done, if image fits in one of supported projections?

Klo: The image in interpolated to the Basemap projection region. This is slow - the main reason to use the WMS is to avoid this by having it done on the server side. According http://atlas.resources.ca.gov/arcgis/SDK/REST/export.html `bbox` is required with syntax like: Syntax: <xmin>, <ymin>, <xmax>, <ymax> Number format for `bbox` AFAIK (but not sure) depends on `bboxSR` projection and dense list of available projections with their code is here: http://atlas.resources.ca.gov/arcgis/SDK/REST/pcs.html The trick is to figure out what the EPSG projection code is based on the Basemap projection info, and pass that information to the WMS server so it can do the interpolation.

Here's an example for south polar stereographic: width = 12000.e3 plt.figure() basemap_url =\ " http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_Imagery_World_2D/MapServer/export?\\ bbox=%d,%d,%d,%d&\ bboxSR=3412&\ imageSR=3412&\ size=800,800&\ dpi=128&\ format=png32&\ f=image" % (-width/2,-width/2,width/2,width/2) m =\ Basemap(projection='stere',resolution='i',lon_0=0,lat_0=-90,lat_ts=-70,\ width=width,height=width,rsphere=(6378273,6356889.449)) m.imshow(plt.imread(urllib2.urlopen(basemap_url)),origin='upper') m.drawmeridians(np.arange(-180,180,30),labels=[0,0,0,1],color='y') m.drawparallels(np.arange(-80,-0,10),labels=[1,0,0,0],color='y') m.drawcoastlines() plt.show() -Jeff ··· On 8/25/12 3:08 PM, klo uo wrote: On Sat, Aug 25, 2012 at 10:19 PM, Jeff Whitaker < [email protected] ...> wrote: So perhaps, by just providing `cyl` (bboxSR=4326) and imageSR to any desired projection from above list will do the trick?

Quickly now, I tried to map other projection on whole world as it was easier not knowing Basemap that well: ======================================== from mpl_toolkits.basemap import Basemap import matplotlib.pyplot as plt import urllib2 lon1 = -180; lon2 = 180; lat1 = -90; lat2 = 90 basemap_url = " Export Map (World_Physical_Map) bbox=%d,%d,%d,%d&\ bboxSR=4326&\ imageSR=54030&\ size=2000,1000&\ format=png32&\ f=image" % (lon1, lat1, lon2, lat2) m = Basemap(projection='robin', lon_0=0, resolution='c') m.imshow(plt.imread(urllib2.urlopen(basemap_url)), origin='upper') m.drawcoastlines() plt.gca().axison = False plt.title("Robinson Projection") plt.show() Seems almost fine Klonuo_Umom August 26, 2012, 11:44am 2 Klo: The image in interpolated to the Basemap projection region.

This is slow - the main reason to use the WMS is to avoid this by having it done on the server side. All right, that's the right way anyway The trick is to figure out what the EPSG projection code is based on the Basemap projection info, and pass that information to the WMS server so it can do the interpolation. Yes, and also to pass right `size` parameter as aspect ratio needs to be correct Do you want me to try to pair both projections (Basemap name and WKID and WKT as they call it)?

Here's an example for south polar stereographic: width = 12000.e3 plt.figure() basemap_url =\ " http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_Imagery_World_2D/MapServer/export?\\ bbox=%d,%d,%d,%d&\ bboxSR=3412&\ imageSR=3412&\ size=800,800&\ dpi=128&\ format=png32&\ f=image" % (-width/2,-width/2,width/2,width/2) m =\ Basemap(projection='stere',resolution='i',lon_0=0,lat_0=-90,lat_ts=-70,\ width=width,height=width,rsphere=(6378273,6356889.449)) m.imshow(plt.imread(urllib2.urlopen(basemap_url)),origin='upper') m.drawmeridians(np.arange(-180,180,30),labels=[0,0,0,1],color='y') m.drawparallels(np.arange(-80,-0,10),labels=[1,0,0,0],color='y') m.drawcoastlines() plt.show() Looks beautifully As said later today I'll look at Nokia maps and then will try to look for WMS servers. ··· On Sun, Aug 26, 2012 at 12:18 AM, Jeff Whitaker < [email protected] ...> wrote: Klonuo_Umom August 26, 2012, 5:18pm 3 As said later today I'll look at Nokia maps and then will try to look for WMS servers.

Nokia map services are OK, and can be used even without applying for free account, but they brand every map with their logo even for professional licence. REST services ( http://api.maps.nokia.com/en/restmaps/overview.html ) are very limited, in one projection and mapped according central point instead bounding box. They offer ( http://api.maps.nokia.com/en/index.html ) other approaches like JS, JAVA, HTML5 and perhaps some more advanced service can be deduced from there in Python, but it's not worth perhaps.

BTW I checked one WMS server ( http://wms.jpl.nasa.gov/wms.cgi?request=GetCapabilities ). It has tiling service (GetTileService) and mapping service (GetMap) but only in standard projection EPSG:4326 Here are maps provided: 1 - WMS Global Mosaic, pan sharpened 2 - WMS Global Mosaic, not pan sharpened 3 - CONUS mosaic of 1990 MRLC dataset 4 - SRTM reflectance magnitude, 30m 5 - Current global view of the earth, morning 6 - Current global view of the earth in the afternoon 7 - Blue Marble Next Generation, Global MODIS derived image 8 - Blue Marble, Global MODIS derived image 9 - SRTM derived global elevation, 3 arc-second, hue mapped 10 - Global 1km elevation, seamless SRTM land elevation and ocean depth 11 - SRTM derived global elevation, 3 arc-second 12 - United States elevation, 30m 13 - Digital Elevation Map of the United States, DTED dataset, 3 second resolution, grayscale 14 - Digital Elevation Map of the United States, DTED dataset, 3 second resolution, hue mapped 15 - ASTER DEM, tiled only, 1.5 arc-second per pixel Only first two offer international locations (from Landsat) _Jeff_Whitaker1 August 26, 2012, 7:56pm 4 Klo: The image in interpolated to the Basemap projection region.

This is slow - the main reason to use the WMS is to avoid this by having it done on the server side. All right, that's the right way anyway The trick is to figure out what the EPSG projection code is based on the Basemap projection info, and pass that information to the WMS server so it can do the interpolation. Yes, and also to pass right `size` parameter as aspect ratio needs to be correct Do you want me to try to pair both projections (Basemap name and WKID and WKT as they call it)?

Klo: Since epsg codes comprise a very small subset of possible Basemap projections, it may be better to just allow Basemap to accept an epsg kwarg. That keyword would be required in order to use a WMS to display a map background. This may be tricky though, since Basemap needs more information to define a map projection region than is provided by the epsg code. We may have to start with just a few supported epsg codes and then add more as necessary.

I added a testwms.py example to my fork ( GitHub - jswhit/basemap ) that shows how to use three different map projections (epsg codes). -Jeff -Jeff ··· On 8/26/12 5:44 AM, klo uo wrote: On Sun, Aug 26, 2012 at 12:18 AM, Jeff Whitaker < [email protected] ...> wrote: Here's an example for south polar stereographic: width = 12000.e3 plt.figure() basemap_url =\ " http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_Imagery_World_2D/MapServer/export?\\ bbox=%d,%d,%d,%d&\ bboxSR=3412&\ imageSR=3412&\ size=800,800&\ dpi=128&\ format=png32&\ f=image" % (-width/2,-width/2,width/2,width/2) m =\ Basemap(projection='stere',resolution='i',lon_0=0,lat_0=-90,lat_ts=-70,\ width=width,height=width,rsphere=(6378273,6356889.449)) m.imshow(plt.imread(urllib2.urlopen(basemap_url)),origin='upper') m.drawmeridians(np.arange(-180,180,30),labels=[0,0,0,1],color='y') m.drawparallels(np.arange(-80,-0,10),labels=[1,0,0,0],color='y') m.drawcoastlines() plt.show() Looks beautifully As

The rest of this page is on the live site.