I like to use QGIS to examine shapefiles, but sometimes I use a computer that does not have it installed. Below are some notes about plotting shapefiles using web interfaces I can access on most computers: Google Colab and Earth Engine.
Ashwani Dhankhar’s article “Mapping with Matplotlib, Pandas, Geopandas and Basemap in Python” shows how to plot a shapefile on a basemap in Google Colab. Below is code in Google Colab to do this. Following that, is a note about Google Earth Engine.
# https://towardsdatascience.com/mapping-with-matplotlib-pandas-geopandas-and-basemap-in-python-d11b57ab5dac # https://stackoverflow.com/questions/54613992/how-to-install-and-use-basemap-on-google-colab # !apt-get install libgeos-3.6.2 (I am not sure if this is needed) !apt-get install libgeos-dev !pip install https://github.com/matplotlib/basemap/archive/master.zip !pip install geopandas !pip install contextily
Restart the runtime.
import numpy as np import matplotlib.pyplot as plt from mpl_toolkits.basemap import Basemap import geopandas as gpd import pandas as pd import contextily as ctx
The shapefile I want to view (amuqall.shp) is on my Google drive. I wanted to view its geographic extent on a basemap.
amuquall_df=gpd.read_file("/content/drive/MyDrive/amuquall/data/amuqall.shp") print(amuquall_df.crs) # Change crs to one compatible with basemap amuquall_df = amuquall_df.to_crs(epsg=3857) print(amuquall_df.crs) ax = amuquall_df.plot(figsize=(20, 20), alpha=0.5, edgecolor='k') ctx.add_basemap(ax)