FYI code
import geopandas as gpd
import matplotlib.pyplot as plt
from shapely.geometry import box
# 1) Read world shapefile
shapefile_path = r"ne_110m_admin_0_countries.shp"
world =
gpd.read_file(shapefile_path)
# 2) Ensure WGS84
world =
world.to_crs("EPSG:4326")
# 3) Define highlight countries & color map
highlight_countries = [
"Saudi Arabia", "Bahrain", "Kuwait", "Oman", "Qatar",
"United Arab Emirates", "Israel", "Syria",
"Turkey", "Romania", "Moldova", "Ukraine"
]
color_map = {
"Saudi Arabia": "
#ffcccb",
"Bahrain": "
#ffb6c1",
"Kuwait": "
#ffc0cb",
"Oman": "
#ffa07a",
"Qatar": "
#f08080",
"United Arab Emirates": "
#ff6347",
"Israel": "
#ff4500",
"Syria": "
#fa8072",
"Turkey": "
#ff7f50",
"Romania": "
#ff8c00",
"Moldova": "
#ffa500",
"Ukraine": "
#ff1493"
}
# 4) Clip out far-eastern Russia etc. by bounding box
# Adjust as needed: (min_lon, min_lat, max_lon, max_lat)
minx, miny, maxx, maxy = (18, 12, 60, 50)
bbox_poly = box(minx, miny, maxx, maxy)
# 5) Clip the world to that bounding box (partially cuts off large countries)
region = gpd.clip(world, bbox_poly)
# 6) Build a polygon for the 'ocean' portion by subtracting land from the bounding box
land_union = region.unary_union # merges all land geometry
ocean_area = bbox_poly.difference(land_union)
# Create a GeoDataFrame for the ocean polygon
ocean_gdf = gpd.GeoDataFrame(geometry=[ocean_area], crs="EPSG:4326")
# 7) Assign highlight colors vs. white for everything else
region["color"] = region["NAME"].map(color_map).fillna("white")
# 8) Plot
fig, ax = plt.subplots(figsize=(10, 8))
# Plot the ocean first
ocean_gdf.plot(ax=ax, color="skyblue", zorder=1)
# Plot the region (countries) on top
region.plot(
ax=ax,
color=region["color"],
edgecolor="black",
linewidth=0.5,
zorder=2
)
# 9) Label highlighted countries
for country in highlight_countries:
subset = region[region["NAME"] == country]
if not subset.empty:
centroid = subset.geometry.centroid.iloc[0]
ax.text(
centroid.x, centroid.y, country,
fontsize=9,
ha="center", va="center",
color="black",
bbox=dict(facecolor="white", alpha=0.7, pad=1.0),
zorder=3
)
# 10) Final styling
ax.set_title("Eastern Europe & the Middle East (WGS84)", fontsize=14, fontweight="bold")
ax.set_axis_off()
plt.tight_layout()
# 11) Save/show
output_path = r"C:\pythonprojects\textsearch\improved_map.png"
plt.savefig(output_path, bbox_inches="tight", dpi=300)
plt.show()
print(f"Map saved to {output_path}")