title: Using spatial index to boost distance query from point to polygon
body: <p><a href="https://automating-gis-processes.github.io/site/notebooks/L3/spatial_index.html?highlight=sindex" rel="nofollow noreferrer">Here</a> introduces how to boost spatial intersection queries using R-Tree. <a href="https://gis.stackexchange.com/questions/222315/geopandas-find-nearest-point-in-other-dataframe">Here</a> <a href="https://gis.stackexchange.com/users/130582/jhuw">@JHuw</a> provides ways using R-Tree to calculate the nearest distance from point to point and line, respectively. Nevertheless, I have not found a solution to boost distance query from point to polygon using R-Tree. I followed those examples mentioned above and still have not figured out how to implement R-Tree in nearest distance query from point to polygon. Could anybody help me figure this out? Much appreciated. I use South America and a subset of cities from GeoPandas as an example in the following:</p>
  
  <pre><code># Import libraries
  import geopandas as gpd
  import matplotlib.pyplot as plt
  
  # Load data from GeoPandas
  world = gpd.read_file(gpd.datasets.get_path('naturalearth_lowres'))
  cities = gpd.read_file(gpd.datasets.get_path('naturalearth_cities'))
  
  south_america = world[world.continent == 'South America']
  city_sub = cities[cities.index &lt; 20]
  
  # Plot
  ax= south_america.boundary.plot()
  city_sub.plot(ax=ax)
  
  # Nearest distance from point (city_sub) to polygon (south_america) using R-Tree
  # "To be finished..."
  </code></pre>