> For the complete documentation index, see [llms.txt](https://pixelfreund.gitbook.io/prompt-engineering/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://pixelfreund.gitbook.io/prompt-engineering/exercises/excercise-geopandas.md).

# Excercise: Geopandas

### Aufgabe

* Eine Tabelle mit der Liste aller Recovery Landeplätze auf der Erde erstellen
* Python Code für Darstellung mittels Geopandas in Google Colab Notebook

### Table with Geolocations

```
Generate a table with all landing coordinates on earth, with the location of all apollo missions
```

Here’s a table of all Apollo mission landing coordinates on Earth and their respective recovery locations:

| **Mission** | **Landing Date** | **Landing Coordinates (Earth)** | **Recovery Location**            |
| ----------- | ---------------- | ------------------------------- | -------------------------------- |
| Apollo 7    | Oct 22, 1968     | 27.23° N, 64.04° W              | North Atlantic Ocean             |
| Apollo 8    | Dec 27, 1968     | 8.10° N, 165.00° W              | Pacific Ocean                    |
| Apollo 9    | Mar 13, 1969     | 23.25° N, 67.56° W              | Atlantic Ocean                   |
| Apollo 10   | May 26, 1969     | 15.25° S, 164.55° W             | Pacific Ocean                    |
| Apollo 11   | Jul 24, 1969     | 13.30° N, 169.15° W             | Pacific Ocean, near USS Hornet   |
| Apollo 12   | Nov 24, 1969     | 15.78° S, 165.15° W             | Pacific Ocean, near USS Hornet   |
| Apollo 13   | Apr 17, 1970     | 21.63° S, 165.39° W             | Pacific Ocean, near USS Iwo Jima |
| Apollo 14   | Feb 9, 1971      | 27.02° S, 172.65° W             | Pacific Ocean                    |
| Apollo 15   | Aug 7, 1971      | 26.13° N, 158.13° W             | Pacific Ocean                    |
| Apollo 16   | Apr 27, 1972     | 0.70° N, 156.23° W              | Pacific Ocean                    |
| Apollo 17   | Dec 19, 1972     | 16.47° S, 166.12° W             | Pacific Ocean                    |

### Python Code

```
Create python code for those coordinates using geopandas in a colab book
```

```notebook-python
# Install necessary libraries in Colab
!pip install geopandas matplotlib descartes

# Import libraries
import geopandas as gpd
import pandas as pd
import matplotlib.pyplot as plt
from shapely.geometry import Point
import os # Import the os module

# Define the Apollo mission landing coordinates and locations
data = {
    "Mission": [
        "Apollo 7", "Apollo 8", "Apollo 9", "Apollo 10",
        "Apollo 11", "Apollo 12", "Apollo 13", "Apollo 14",
        "Apollo 15", "Apollo 16", "Apollo 17"
    ],
    "Latitude": [27.23, 8.10, 23.25, -15.25, 13.30, -15.78, -21.63, -27.02, 26.13, 0.70, -16.47],
    "Longitude": [-64.04, -165.00, -67.56, -164.55, -169.15, -165.15, -165.39, -172.65, -158.13, -156.23, -166.12]
}

# Create a Pandas DataFrame
df = pd.DataFrame(data)

# Create a GeoDataFrame with the coordinates
geometry = [Point(xy) for xy in zip(df["Longitude"], df["Latitude"])]
gdf = gpd.GeoDataFrame(df, geometry=geometry)

# Download the world map data from Natural Earth
!wget https://naturalearth.s3.amazonaws.com/110m_cultural/ne_110m_admin_0_countries.zip
!unzip ne_110m_admin_0_countries.zip

# Load the world map using GeoPandas
world = gpd.read_file("ne_110m_admin_0_countries.shp") # Load the world map data

# Plot the world map
fig, ax = plt.subplots(figsize=(12, 8))
world.plot(ax=ax, color="lightgrey")

# Plot the landing sites
gdf.plot(ax=ax, color="red", markersize=50, label="Apollo Landing Sites")

# Annotate the map with mission names
for x, y, label in zip(gdf.geometry.x, gdf.geometry.y, gdf["Mission"]):
    ax.text(x + 2, y, label, fontsize=8, color="blue")

# Add title and legend
plt.title("Apollo Mission Landing Sites on Earth", fontsize=14)
plt.legend(loc="lower left")
plt.show()
```

### Output

<figure><img src="/files/TtV11D1iPrYqMHYQJVmt" alt=""><figcaption></figcaption></figure>
