2017-02-13 71 views
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()它再次,但這似乎對我來說是多餘的。

+0

爲什麼你需要使用兩種方法,而不是兩種方法之一? – Benjamin

+0

這只是我解決一些單獨任務的方式。一些通過使用ogr,一些通過使用geopandas。後者我覺得更接近熊貓,因爲它接近熊貓。那麼,我給了它一個鏡頭,謝謝你的答案! –

回答