I have tried to create a fishnet(10 by 10) using the below code. But the output is as shown below. What is that I'm missing in the below code?
import geopandas as gpd
from shapely.geometry import Polygon
import numpy as np
ras= rasterio.open(r"My Raster file")
xmin,ymin,xmax,ymax = ras.bounds
length = 1000
wide = 1000
cols = list(range(int(np.floor(xmin)), int(np.ceil(xmax)), wide))
rows = list(range(int(np.floor(ymin)), int(np.ceil(ymax)), length))
rows.reverse()
polygons = []
for x in cols:
for y in rows:
polygons.append( Polygon([(x,y), (x+wide, y), (x+wide, y-length), (x, y-length)]) )
grid = gpd.GeoDataFrame({'geometry':polygons})
grid.to_file("grid.shp")
df= gpd.read_file('grid.shp')
df.plot()