見出し画像

Pythonメモ - 巨石文明を地図にプロット

# python

import matplotlib.pyplot as plt
import pandas as pd
import geopandas as gpd

# Data for the ancient sites with their approximate coordinates.
sites_data = {
    "Site": [
        "Ziggurats of Mesopotamia",
        "Pyramids of Giza",
        "Moai of Easter Island",
        "Greek Temples and Theatres",
        "Stonehenge",
        "Megalithic Temples of Malta",
        "Dolmens and Menhirs of India",
        "Pyramids and Palaces of Maya",
        "Machu Picchu",
    ],
    "Latitude": [
        32.536389,
        29.979175,
        -27.112723,
        37.983810,
        51.178882,
        35.827875,
        15.333333,
        17.251011,
        -13.163068,
    ],
    "Longitude": [
        44.420556,
        31.134358,
        -109.366424,
        23.727539,
        -1.826215,
        14.442505,
        76.500000,
        -89.592586,
        -72.545128,
    ],
}

# Create a DataFrame
df_sites_locations = pd.DataFrame(sites_data)

# Create a GeoDataFrame
gdf_sites = gpd.GeoDataFrame(
    df_sites_locations,
    geometry=gpd.points_from_xy(
        df_sites_locations.Longitude, df_sites_locations.Latitude
    ),
)

# Load the world map
world = gpd.read_file(gpd.datasets.get_path("naturalearth_lowres"))

# Plot the world map
fig, ax = plt.subplots(1, 1, figsize=(15, 10))
world.plot(ax=ax, color="lightgrey")

# Plot the ancient sites on the world map
gdf_sites.plot(ax=ax, color="red", markersize=50)

# Annotate the sites
for x, y, label in zip(gdf_sites.geometry.x, gdf_sites.geometry.y,
                       gdf_sites.Site):
    ax.text(x, y, label, fontsize=8, ha="right", va="bottom")

# Adjust the limits and aspect
ax.set_xlim([-180, 180])
ax.set_ylim([-90, 90])
ax.set_aspect("equal")

# Remove axes
ax.axis("off")

# Set title
ax.set_title("Ancient Sites with Megalithic Structures", fontえsizre=15, pad=20)

# Show the plot
plt.show()


# requirements.txt

astroid==3.0.2
attrs==23.2.0
bandit==1.7.7
black==24.1.0
certifi==2023.11.17
click==8.1.7
click-plugins==1.1.1
cligj==0.7.2
colorama==0.4.6
contourpy==1.2.0
cycler==0.12.1
dill==0.3.7
fiona==1.9.5
flake8==7.0.0
fonttools==4.47.0
geopandas==0.14.2
isort==5.13.2
kiwisolver==1.4.5
markdown-it-py==3.0.0
matplotlib==3.8.2
mccabe==0.7.0
mdurl==0.1.2
mypy==1.8.0
mypy-extensions==1.0.0
numpy==1.26.3
packaging==23.2
pandas==2.1.4
pandas-stubs==2.1.4.231227
pathspec==0.12.1
pbr==6.0.0
pillow==10.2.0
platformdirs==4.1.0
pycodestyle==2.11.1
pyflakes==3.2.0
Pygments==2.17.2
pylint==3.0.3
Pyment==0.3.3
pyparsing==3.1.1
pyproj==3.6.1
python-dateutil==2.8.2
pytz==2023.3.post1
PyYAML==6.0.1
rich==13.7.0
setuptools==69.0.3
shapely==2.0.2
six==1.16.0
stevedore==5.1.0
tomlkit==0.12.3
types-pytz==2023.3.1.1
typing_extensions==4.9.0
tzdata==2023.4


この記事が気に入ったらサポートをしてみませんか?