I am trying to densify geometry of polygons loaded by GeoPandas using ogr.Geometry Segmentize. When I print new geometry, it is densified as intended, but it will never save into the shapefile. It should just overwrite the old one, but geometry remains the same as the original one. I have no idea what is wrong. It is not giving me an error.
The code looks like this:
import geopandas as gpd
from osgeo import ogr
from shapely.wkt import loads
path = "/Users/martin/Tess/b3.shp"
objects = gpd.read_file(path) # load file into geopandas
for index, row in objects.iterrows():
wkt = row['geometry'].wkt # shapely Polygon to wkt
geom = ogr.CreateGeometryFromWkt(wkt) # create ogr geometry
geom.Segmentize(2) # densify geometry
wkt2 = geom.ExportToWkt() # ogr geometry to wkt
new = loads(wkt2) # wkt to shapely Polygon
row['geometry'] = new # overwrite old geomtry with densified one
objects.to_file("/Users/martin/Tess/b3s.shp")
Any idea what is wrong?