Wednesday, November 26, 2014

Basemap Tutorial

Basemap is a great tool for creating maps using python in a simple way. It's a `matplotlib <>`_ extension, so it has got all its features to create data visualizations, and adds the geographical projections and some datasets to be able to plot coast lines, countries, and so on directly from the library.

Basemap has got `some documentation <>`_, but some things are a bit more difficult to find. I started a readthedocs page to extend a little the original documentation and examples, but it grew a little, and now covers many of the basemap possibilities.

Some of the examples from the tutorial

The tutorial can be found at, and all the examples and its source code, at GitHub and it's available for sharing or being modified by adding the attribution.

The tutorial covers:
 I would really appreciate some feedback, the comments are open!


  1. This comment has been removed by the author.

  2. This is really cool, you are helping me with a homework assignment, thanks so much! If I have any useful feedback I'll post here but wanted to say how thankful I am that someone has extended the cryptic documentation. Thanks!

  3. Very helpful tutorials.I am trying to find the coordinates: llcrnrlon,llcrnrlat,urcrnrlon,urcrnrlat for London. Can you please tell me how to find them?
    Thanks in advance.

    1. Hi,

      You can either look on Google Maps the locations you want to show or, if you want to show London in the center, use the lon_0 and lat_0 plus the map size.
      The three options are shown here:

  4. Hi Roger, I've benefited a lot from your tutorials and online docs. Basemap has been a fun tool for me to learn and use, so thanks!

    I'm starting a project now that involves some 3d plotting. I've looked a bit here:
    and this is very useful.

    The question I still have though, is how to add a shapefile to a 3D map. Is this currently possible with Basemap?


    1. Hi Alex,
      Yes, just use the same steps as in
      to load the shapefile and draw the 3d map like in the example

  5. I am working with WRF output using GDAL and learned a lot from your tutorial. Thanks so much!
    One thing that was not explained in the examples from WRF -or at least I could not find it- is how to get the start date and timesteps and other global attributes from the WRF output file using the GDAL library, or in some other way.
    I tried to get the Times as gdal dataset, like the other variables, but that did not work.
    Your advice will be appreciated
    Kees (desde Holanda)

  6. Hi, are you working with grib files or netcdf files?
    Grib files have two metadata elements on each band: grib_ref_time and grib_valid_time, which give the unix timestamp for the model initialization time and the time when the Mayer us vĂ lid.
    Netcdf has a global metadata element with the initial time, but I don't find the element for the band date.

  7. Hi, thanks. I am working with netcdf files. I have been doing some googling and found some scripts that use scipy.netcdf library instead of gdal. I have now found a way to extract the Times variable from the wrfoutput.

  8. Look at the way my associate Wesley Virgin's tale begins with this SHOCKING and controversial VIDEO.

    Wesley was in the army-and shortly after leaving-he unveiled hidden, "self mind control" tactics that the government and others used to obtain anything they want.

    These are the same SECRETS many celebrities (especially those who "became famous out of nothing") and top business people used to become wealthy and successful.

    You probably know how you use less than 10% of your brain.

    That's because most of your brain's power is UNCONSCIOUS.

    Perhaps this thought has even occurred IN YOUR very own mind... as it did in my good friend Wesley Virgin's mind about 7 years back, while riding an unlicensed, beat-up trash bucket of a vehicle without a driver's license and $3.20 in his pocket.

    "I'm very frustrated with going through life paycheck to paycheck! When will I finally succeed?"

    You've taken part in those questions, right?

    Your success story is going to start. Go and take a leap of faith in YOURSELF.