To commemorate the official release of the European Commission's Functional Urban Area boundaries, here're some easy maps that draw them on top of night lights. Enjoy!
%matplotlib inline
import geopandas
import contextily as cx
Assume your download is in unzipped and in the same folder as this notebook:
p = ("GHS_FUA_UCDB2015_GLOBE_R2019A_54009_1K_V1_0/"\
"GHS_FUA_UCDB2015_GLOBE_R2019A_54009_1K_V1_0.gpkg")
db = geopandas.read_file(p)
# Somehow CRS is not read automatically
db.crs = "+proj=moll +lon_0=0 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs"
# Quick visual check
db.plot();
Let's select the NASA night lights as the provider for the basemaps:
prov = cx.providers.NASAGIBS.ViirsEarthAtNight2012
ax = db.query("Cntry_name == 'UnitedKingdom'")\
.plot(facecolor="none",
edgecolor="red",
figsize=(12, 12)
)
cx.add_basemap(ax, crs=db.crs, url=prov);
qry = "Cntry_name == 'Spain' | Cntry_name == 'Portugal'"
ax = db.query(qry)\
.cx[:, 4250000:]\
.plot(facecolor="none",
edgecolor="red",
linewidth=2.5,
figsize=(12, 12)
)
cx.add_basemap(ax, crs=db.crs, url=prov);
ax = db.query("Cntry_name == 'Japan'")\
.to_crs(epsg=4326)\
.plot(facecolor="none",
edgecolor="red",
figsize=(12, 12)
)
cx.add_basemap(ax, crs={'init': 'epsg:4326'}, url=prov);
qry = "Cntry_name == 'SouthKorea' | Cntry_name == 'NorthKorea'"
ax = db.query(qry)\
.to_crs(epsg=4326)\
.plot(facecolor="none",
edgecolor="red",
figsize=(12, 12)
)
cx.add_basemap(ax, crs={'init': 'epsg:4326'}, url=prov);
ax = db.query("Cntry_name == 'Brazil'")\
.to_crs(epsg=4326)\
.plot(facecolor="none",
edgecolor="red",
figsize=(12, 12)
)
cx.add_basemap(ax, crs={'init': 'epsg:4326'}, url=prov);
ax = db.query("Cntry_name == 'Morocco'")\
.to_crs(epsg=4326)\
.plot(facecolor="none",
edgecolor="red",
figsize=(12, 12)
)
cx.add_basemap(ax, crs={'init': 'epsg:4326'}, url=prov);
ax = db.query("Cntry_name == 'India'")\
.to_crs(epsg=4326)\
.plot(facecolor="none",
edgecolor="red",
figsize=(12, 12)
)
cx.add_basemap(ax, crs={'init': 'epsg:4326'}, url=prov);
ax = db.query("Cntry_name == 'Netherlands'")\
.to_crs(epsg=4326)\
.plot(facecolor="none",
edgecolor="red",
linewidth=3,
figsize=(12, 12)
)
cx.add_basemap(ax, crs={'init': 'epsg:4326'}, url=prov);
ax = db.query("Cntry_name == 'China'")\
.to_crs(epsg=4490)\
.plot(facecolor="none",
edgecolor="red",
linewidth=0.5,
figsize=(12, 12)
)
cx.add_basemap(ax, crs={'init': 'epsg:4490'}, url=prov);