MulaiMulai sekarang secara gratis

Calculating distance in a projected CRS

Now we have the Eiffel Tower location in a projected coordinate system, we can calculate the distance to other points.

The final s_eiffel_tower_projected of the previous exercise containing the projected Point is already provided, and we extract the single point into the eiffel_tower variable. Further, the restaurants dataframe (using WGS84 coordinates) is also loaded.

Latihan ini adalah bagian dari kursus

Working with Geospatial Data in Python

Lihat Kursus

Petunjuk latihan

  • Convert the restaurants to the same CRS as the Eiffel Tower point. For this exercise, don't specify the epsg keyword, but make use of the .crs attribute.
  • Calculate the distance for all restaurants to the Eiffel Tower.
  • Print the smallest distance.

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

# Extract the single Point
eiffel_tower = s_eiffel_tower_projected[0]

# Ensure the restaurants use the same CRS
restaurants = restaurants.____

# The distance from each restaurant to the Eiffel Tower
dist_eiffel = ____

# The distance to the closest restaurant
print(____)
Edit dan Jalankan Kode