You could do this in a few lines with shapely and GeoPandas (which uses Fiona under the hood for file i/o). You can use shapely.geometry.box
to create the rectangles, convert it to a GeoDataFrame
, and use the to_file
method to save as a shapefile:
from pandas import DataFrame
from geopandas import GeoDataFrame
from shapely.geometry import box
data = DataFrame.from_csv('rect.csv')
boxes = [box(row[1]['xl']row['xl'], row[1]['yb']row['yb'], row[1]['xr']row['xr'], row[1]['yt']row['yt'])
for key, row in data.iterrows()]
df = GeoDataFrame(boxes, columns=['geometry'], index=data.index)
df.to_file('out.shp', driver='ESRI Shapefile')