You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Geopandas报GeocoderNotFound错误:未知地理编码器'geocodefarm'如何解决?

解决Geopandas地理编码的GeocoderNotFound错误

问题场景

运行以下Geopandas地理编码代码:

import geopandas

place = "Sankt Gallen"
geopandas.tools.geocode(place).explore()

触发错误:

GeocoderNotFound: Unknown geocoder 'geocodefarm'; options are: dict_keys(['algolia', 'arcgis', 'azure', 'baidu', 'baiduv3', 'banfrance', 'bing', 'databc', 'geocodeearth', 'geocodio', 'geonames', 'google', 'googlev3', 'geolake', 'here', 'herev7', 'ignfrance', 'mapbox', 'mapquest', 'maptiler', 'nominatim', 'opencage', 'openmapquest', 'pickpoint', 'pelias', 'photon', 'liveaddress', 'tomtom', 'what3words', 'what3wordsv3', 'yandex'])

解决方法

错误原因是geocode()方法默认依赖的geocodefarm编码器已不再被支持,需显式指定错误提示中列出的可用编码器。

推荐方案(开源免费)

使用Nominatim编码器,无需API密钥,但必须设置user_agent标识请求来源(避免被服务端限制访问):

import geopandas

place = "Sankt Gallen"
# 替换user_agent为你的邮箱或应用名称
gdf = geopandas.tools.geocode(place, provider='nominatim', user_agent='my_geocoding_tool')
gdf.explore()

其他编码器使用示例

若需使用商业/专有编码器,需提前获取对应API密钥并传入:

# Google v3编码器示例
geopandas.tools.geocode(place, provider='googlev3', api_key='你的API密钥')

# Bing编码器示例
geopandas.tools.geocode(place, provider='bing', api_key='你的API密钥')

内容的提问来源于stack exchange,提问作者Muriel

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.16 08:17:03