Skip to content
Back to top
View this page

Q: It takes a long time to make a plot with the ‘intermediate’ or ‘high’ resolution coastlines, how can I speed it up?

A: There is a overhead in processing boundary datasets when a Basemap class in created, and this overhead can be significant for the higher resolution boundaries. If you are makeing many maps for the same region, you only need to create you Basemap class instance once, then re-use it for each plot. If the plots are being created by different scripts, you can save the Basemap class instance to a Pickle on disk, then read it in whatever script needs it (it’s much faster to read a pickle from disk than it is to create the Basemap instance originally). The hires.py example illustrates how to do this.

Q: I have my own boundary dataset that I would like to use, how do I use it in place of (or in addition to) the built-in basemap boundary datasets?

A: If your dataset is in ESRI shapefile format, this is relatively easy. Just create your Basemap class instance, then call the ‘readshapefile’ method on that instance to import your data. Setting ‘drawbounds=True’ will draw the boundaries in the shapefile. The fillstates.py example shows how to do this.

Q: How do I specify the map projection region if I don’t know what the latitude and longitudes of the corners are?

A: As an alternative to specifying the lat/lon values for the upper-right and lower-left corners of the projection domain (using the llcrnrlat, llcrnrlon, urcrnrlat and urcrnrlon keywords) you can specify the center of the map projection domain (using the lat_0 and lon_0 keywords) and the width and height of the domain in map projection coordinates (meters) using the width and height keywords. Basemap will then calculate the corresponging values of llcrnrlat, llcrnrlon, urcrnrlat and urcrnrlon. Examples of this are given in the garp.py and setwh.py examples.