- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我制作了一个 geopandas 数据框,我想使用 geopandas_dataframe.explore()
创建一个交互式 map 。这是我的代码。首先,我创建了 geopandas 数据框,我检查了数据类型,然后尝试使用 gdf.explore()
映射数据框。不幸的是,我的代码没有错误地完成并且没有显示 map 。
代码:
geometry = [Point(xy) for xy in zip(df[1], df[0])]
gdf = geopandas.GeoDataFrame(df, geometry=geometry)
print(gdf.head())
print(gdf.dtypes)
gdf.explore()
输出:
0 1 geometry
0 51.858306 5.778404 POINT (5.77840 51.85831)
1 51.858322 5.778410 POINT (5.77841 51.85832)
2 51.858338 5.778416 POINT (5.77842 51.85834)
3 51.858354 5.778422 POINT (5.77842 51.85835)
4 51.858370 5.778429 POINT (5.77843 51.85837)
0 float64
1 float64
geometry geometry
dtype: object
Process finished with exit code 0
为什么我没有 map ?我已经尝试过 gdf.show()
但那不存在。我需要做什么才能显示 geopandas map ?
最佳答案
您使用的是什么 IDE?在 Jupyter Notebook 中,您的代码(稍作修改)适用于我。但是,当我在 PyCharm 中运行它时,我得到“进程已完成,退出代码为 0”,但没有任何情节。
import geopandas as gpd
import pandas as pd
from shapely.geometry import Point
data_dict = {'x': {0: -110.1, 1: -110.2, 2: -110.3, 3: -110.4, 4: -110.5},
'y': {0: 40.1, 1: 40.2, 2: 40.3, 3: 40.4, 4: 40.5}}
df = pd.DataFrame(data_dict)
geometry = [Point(xy) for xy in zip(df['x'], df['y'])]
gdf = gpd.GeoDataFrame(df, geometry=geometry, crs=4326)
print(gdf.head())
print(gdf.dtypes)
gdf.explore()
编辑:看起来您可以将 folium 图保存为 html。这对 PyCharm 有用。
m = gdf.explore()
outfp = r"<your dir path>\base_map.html"
m.save(outfp)
关于python - 如何使用 .explore() 显示 geopandas 交互式 map ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70759514/
我使用来自 OpenStreetMap (link) 的形状文件创建了一个简单的 geopandas map 。 import geopandas as gpd map_gdf = gpd.read_
我正在尝试更改 geopandas 数据框的 CRS。目前的 CRS 是: Name: unknown Axis Info [ellipsoidal]: - lon[east]: Longitude
是否有在 Windows PC 上安装 geopandas 的教程(逐步)?或者哪种方式效果更好? 我已经使用 anaconda 尝试了文档中的解决方案,但最终收到错误(甚至按照建议创建环境)。我什至
我正在尝试按照描述设置 geopandas 对象的 crs here . 示例文件可以从here下载。 import geopandas as gdp df = pd.read_pickle('myS
我目前在 Python 中结合使用 Pandas 和 ArcPy 来完成我的 GIS 工作。我最近听说了 Geopandas 并且有兴趣学习使用它作为 ArcPy 的替代品来进行基本的地理处理操作(空
我读了 .csv文件作为数据框,如下所示: import pandas as pd df = pd.read_csv('myFile.csv') df.head() BoroName g
将 geojson 文件加载到 GeoPandas 后,我得到了预期的名为“几何”的列/特征,其中包含多边形和多边形。 如何将此对象作为 json 或 Python 字典再次取出? 在当前形式下,它是
我正在尝试使用 ANACONDA spyder 运行一个简单的 geopandas 代码。但是,我遇到了错误。 我已经包含了代码和错误如下: —— 这是代码: import geopandas as
我有一个点,我想知道哪个多边形最接近该点。我有点和多边形的地理数据。 最佳答案 您可以使用 distance查找到每个多边形的距离并对它们进行排序以检索最近的。 示例 >>> from shapely
如果我有下面的图,如何将颜色图/图例转换为对数刻度? import geopandas as gpd import matplotlib.pyplot as plt world = gpd.read_
我有一个 geopandas 数据框 geometry idx 0 POLYGON ((-74.2555
我在 python 中使用 GeoPandas 并且有一个有效的多边形 GeoDataframe。 0 POLYGON Z ((68.70999999999999 623.1 0, 3
假设我有以下包含 3 个多边形对象的地理数据框。 import geopandas as gpd from shapely.geometry import Polygon p1=Polygon([(0
我有一个 geopandas 数据框,由 id 和由 2D 点填充的几何列组成。我想连接每个唯一 id 的点来创建一个多边形,以便我的新数据框将多边形作为其几何形状。我的代码目前看起来像这样: pol
我想使用geopandas.rotate()函数根据列中的属性旋转geodataframe中的所有要素。如果我只选择一项功能,我就会成功。然而,对于多行,我相信我需要创建一个 for 循环。 new_
我正在尝试在我的 Mac OS X 上安装 geopandas。 我做了什么: • 下载并安装了适用于 Python 2.7 的 Anaconda here .图形安装程序。 • python --v
我一直收到这个错误,并且已经阅读了其他人的在线访问, ImportError: geopandas, pyshp and shapely must be installed for this figu
您好,我正在尝试将 X 和 Y 坐标列表转换为直线。我想通过 groupby ID 和时间来映射这些数据。只要我 grouby 一列,我的代码就可以成功执行,但是两列是我遇到错误的地方。我引用了这个q
我在使用 read_file 函数时遇到了一些关于 geopandas 和 fiona 的问题。这是我的回溯: df = gpd.read_file('/Users/danqing0703/githu
我有一个在 mapshaper 上看起来像这样的 shapefile: 但是当我尝试用下面的代码在 pandas 中绘制它时 police = gpd.read_file('srilanka_poli
我是一名优秀的程序员,十分优秀!