Basemap is a toolkit under the Python visualization library Matplotlib. Its main function is to draw 2D maps, which are important for visualizing spatial data.
Geographic Data with Basemap
• Basemap
is a toolkit under the Python visualization library Matplotlib. Its main
function is to draw 2D maps, which are important for visualizing spatial data.
Basemap itself does not do any plotting, but provides the ability to transform
coordinates into one of 25 different map projections.
• Matplotlib
can also be used to plot contours, images, vectors, lines or points in
transformed coordinates. Basemap includes the GSSH coastline dataset, as well
as datasets from GMT for rivers, states and national boundaries.
• These
datasets can be used to plot coastlines, rivers and political boundaries on a
map at several different resolutions. Basemap uses the Geometry Engine-Open
Source (GEOS) library at the bottom to clip coastline and boundary features to
the desired map projection area. In addition, basemap provides the ability to
read shapefiles.
• Basemap
cannot be installed using pip install basemap. If Anaconda is installed, you
can install basemap using canda install basemap.
• Example
objects in basemap:
a) contour(): Draw contour lines.
b) contourf(): Draw
filled contours.
c) imshow(): Draw an image.
d) pcolor(): Draw a pseudocolor plot.
e) pcolormesh(): Draw a
pseudocolor plot (faster version for regular meshes).
f) plot(): Draw lines and/or markers.
g) scatter(): Draw points with markers.
h) quiver(): Draw vectors.(draw vector
map, 3D is surface map)
i) barbs(): Draw wind barbs (draw wind
plume map)
j) drawgreatcircle(): Draw a
great circle (draws a great circle route)
• For example,
if we wanted to show all the different types of endangered plants within a
region, we would use a base map showing roads, provincial and state boundaries,
waterways and elevation. Onto this base map, we could add layers that show the
location of different categories of endangered plants. One added layer could be
trees, another layer could be mosses and lichens, another layer could be
grasses.
Basemap basic usage:
import
warnings
warnings.filterwarmings('ignore')
frommpl_toolkits.basemap
import Basemap
importmatplotlib.pyplot
as plt
map = Basemap()
map.drawcoastlines()
#
plt.show()
plt.savefig('test.png')
Output:
Foundation of Data Science: Unit V: Data Visualization : Tag: : Matplotlib | Data Visualization - Geographic Data with Basemap
Foundation of Data Science
CS3352 3rd Semester CSE Dept | 2021 Regulation | 3rd Semester CSE Dept 2021 Regulation