lundi 13 février 2017

Use GeoDataFrame as a osgeo.ogr DataSource

Vote count: 0

I have read shapefile into a GeoDataFrame and did some modification to it:

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)

However, I would also like to apply some functionality of osgeo.ogr module on it:

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)

QUESTION: Is there any way to use or convert an already in-memory shapefile, currently in a form of a GeoDataFrame, as an osgeo.ogr.DataSource directly?

The way I do it so far is to save GeoDataFrame to file with to_file() and then osgeo.ogr.Open() it again, but this seems kind of redundant to me.

asked 30 secs ago

Let's block ads! (Why?)



Use GeoDataFrame as a osgeo.ogr DataSource

Aucun commentaire:

Enregistrer un commentaire