Inspect Data: Plotting
Explore techniques for plotting geospatial data on static maps with matplotlib and dynamic maps with Plotly to visualize store locations effectively. Understand how to manipulate map boundaries, zoom settings, and export interactive visualizations to enhance analysis and interpretation of spatial data in route optimization.
We'll cover the following...
The distinctive feature of geospatial analysis is that it can be displayed on a map or globe. To create a map as a static image, we draw on the descriptive analysis from our previous step: the range between maximum and minimum distribution in terms of longitude and latitude. We fill this list into the border variable.
Now we know the height and width of the image that includes all the stores.
Plotting spatial data on a map
OpenStreetMap (OSM) is an international project to create a free map of the world. With this tool, we can find out where on the map the coordinates are placed. To find out, open OpenStreetMap and enter the border coordinates from above as a bounding box. Click the “Export” button in the top left corner to get there. The bounding box is the area defined by four points, which includes all of the spatial stores. After that, we’ll receive a map section that includes the coordinates we just entered.
We can see for the first time which place is behind the longitude and latitude data: it’s the Moscow metropolitan area.
To export this image, proceed as follows:
Click the “Share” button on the right pane and download the image in the desired format, e.g., as a .png file.
We can use this extract of the map view of Moscow to map the coordinates to it using matplotlib. Draw the coordinates as scatter points in the map image area. Note that it’s important to set up the x-axis, xlim, and the ...