<p>我不知道<code>geopy</code>能提供这个。你知道吗</p>
<p>你真正需要的是你感兴趣的地理位置的形状文件。美国人口普查局为不同的地理区域提供了其中的几种:<a href="https://www.census.gov/geo/maps-data/data/tiger-cart-boundary.html" rel="nofollow noreferrer">Cartographic Boundary Shapefiles</a>。由于您的问题与纽约市有关,我们可以使用<a href="https://geo.nyu.edu/catalog/nyu-2451-34561" rel="nofollow noreferrer">NYU</a>提供的shapefile。你知道吗</p>
<p>使用NYU GeoJSON文件:</p>
<pre><code>import geopandas
df = geopandas.read_file('nyu-2451-34561-geojson.json')
df[df.ntaname == 'Gramercy'].geometry
#54 (POLYGON ((-73.97849845639804 40.7367909565254...
#Name: geometry, dtype: object
</code></pre>
<p>这些几何图形是<a href="https://shapely.readthedocs.io/en/stable/manual.html#polygons" rel="nofollow noreferrer">Shapely MultiPolygons</a>,因此您可以访问一些有用的属性,例如,您可以将所有内容估计为矩形,而不是使用多重多边形:</p>
<pre><code>df[df.ntaname == 'Gramercy'].geometry.bounds
# minx miny maxx maxy
#54 -73.989967 40.73135 -73.978052 40.743325
# Or get the full boundary:
df[df.ntaname == 'Gramercy'].geometry.boundary
#54 (LINESTRING (-73.97849845639804 40.73679095652...
#dtype: object
</code></pre>
<p>如果你在jupyter笔记本上工作,你可以感觉到它的形状:</p>
<pre><code>df[df.ntaname == 'Gramercy'].geometry.item()
</code></pre>
<p><a href="https://i.stack.imgur.com/HP6lY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HP6lY.png" alt="enter image description here"/></a></p>