0
我已阅读shape文件为GeoDataFrame
并做了一些修改它:使用GeoDataFrame作为osgeo.ogr数据源
import geopandas as gpd
# Read shapefile into geodataframe
geodf = gpd.read_file("shapefile.shp")
# Do some "pandas-like" modifications to shapefile
geodf = modify_geodf(geodf)
不过,我也想在它应用osgeo.ogr
模块的一些功能:
from osgeo import ogr
# Read shapefile into ogr DataSource
ds=ogr.Open("shapefile.shp")
# Do some "gdal/ogr-like" modifications to shapefile
ds = modify_ds(ds)
问题:有什么办法目前正处于一个GeoDataFrame的形式使用,或将一个已经在内存中的shape文件,作为osgeo.ogr.DataSource
直接?
我到目前为止的做法是将GeoDataFrame保存到to_file()
然后osgeo.ogr.Open()
它再次,但这似乎对我来说是多余的。
为什么你需要使用两种方法,而不是两种方法之一? – Benjamin
这只是我解决一些单独任务的方式。一些通过使用ogr,一些通过使用geopandas。后者我觉得更接近熊猫,因为它接近熊猫。那么,我给了它一个镜头,谢谢你的答案! –