BaşlayınÜcretsiz Başlayın

Shapely's spatial methods

Now we have a shapely Point object for the Eiffel Tower, we can use the different methods available on such a geometry object to perform spatial operations, such as calculating a distance or checking a spatial relationship.

We repeated the construction of eiffel_tower, and also provide the code that extracts one of the neighbourhoods (the Montparnasse district), as well as one of the restaurants located within Paris.

Bu egzersiz

Working with Geospatial Data in Python

kursunun bir parçasıdır
Kursu Görüntüle

Egzersiz talimatları

  • Check if the Eiffel Tower is located within the Montparnasse district.
  • Check if the Montparnasse district contains the restaurant location.
  • Calculate the distance between the Eiffel Tower and the restaurant (note: in this case, the distance is returned in meters).

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

# Construct a point object for the Eiffel Tower
eiffel_tower = Point(255422.6, 6250868.9)

# Accessing the Montparnasse geometry (Polygon) and restaurant
district_montparnasse = districts.loc[52, 'geometry']
resto = restaurants.loc[956, 'geometry']

# Is the Eiffel Tower located within the Montparnasse district?
print(____)

# Does the Montparnasse district contains the restaurant?
print(____)

# The distance between the Eiffel Tower and the restaurant?
print(____)
Kodu Düzenle ve Çalıştır