如何限制使用Geopandas读取的功能数量?
我有以下python代码,可以使用点x,y
将我的ShapeFile功能读取GeodataFrame
。
import math
import shapely.geometry
import geopandas as gpd
from shapely.ops import nearest_points
absolute_path_to_shapefile = 'c:/test/test1.shp'
gdf1 = gpd.read_file(absolute_path_to_shapefile)
gdf = gpd.GeoDataFrame(
gdf1, geometry=gpd.points_from_xy(gdf1['x'], gdf1['y']))
有没有办法限制读取的功能?一些ShapeFiles有数百万分,但我只想在前100个概念证明中阅读。
I have the following Python code to read my shapefile features into a GeoDataFrame
using the points x, y
.
import math
import shapely.geometry
import geopandas as gpd
from shapely.ops import nearest_points
absolute_path_to_shapefile = 'c:/test/test1.shp'
gdf1 = gpd.read_file(absolute_path_to_shapefile)
gdf = gpd.GeoDataFrame(
gdf1, geometry=gpd.points_from_xy(gdf1['x'], gdf1['y']))
Is there a way to limit the features read in? Some shapefiles have millions of points but I just want to read in the first 100 as proof of concept.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
geopandas
read_file()
具有行
选项,可以限制读取的行数(或使用切片来读取特定行)。GeoPandas
read_file()
has arows
option to limit the number of rows read (or to use a slice to read specific rows).GeoPandas documentation