How to add simple points and lines to our plots

We can see, from the preceding map, that we have Europe in the middle. We will plot some data points and some curves with lines all over Europe. We will begin by putting down a cross or a point. So the latitude and longitude of Heidelberg is 8.7 degrees east and 49.5 degrees north.

We will start with the scatter method. So the scatter behaves just like we are used to it behaving from the standard Cartesian Euclidean projections. Input the code as follows:

# Projecting with and without latlon
m = Basemap(width=1.2e7,height=9e6,projection='lcc',
lat_1=.45,lat_2=.55,lat_0=49.5,lon_0=8.7)
setup_map(m)
HD = (8.7, 49.5)
plt.show()

We will get the output as shown:

There is actually another way of plotting the cross or a point without having to use the map projection explicitly to convert these coordinates. Hence, when we add an extra keyword argument called latlon, and set that to True, it will automatically pass these x and y coordinates through the map projection to convert them into map coordinates, as shown in the following output:

So either way, this works perfectly well for converting coordinates from one coordinate system to the other. There is not much difference between the two. We have seen a single point here, but we can also plot multiple points.

To plot a line right across Europe connecting two points, the following diagram shows a nice little black line going from just above Spain all the way into the edge of Europe:

When we add more than two points, the straight line shown in the previous output gets a curve.

The reason that the line changes into a curve is that we are giving a range of longitude coordinates, but just a single latitude coordinate, so having more than one point with the same latitude coordinate will actually draw an arc of equal latitude.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset