我想你应该用三角形来填充这个区域。你的“三角形”只是其中的一半。如果只需要你的那一半,只需注释掉for循环的第二部分。在import numpy as np
from shapely.geometry import Polygon
from geopandas import GeoSeries
xlen = 20
ylen = 20
x0 = 0
y0 = 0
xPoints = np.arange(x0, xlen + 1, 1)
yPoints = np.arange(y0, ylen + 1, 1)
GridPoints = list((x, y) for x in xPoints for y in yPoints)
triangles = [] # list of triangles to be populated
for i in range(ylen):
for j in range(xlen):
# triangles with perpendicular angle on the bottom left
triangles.append([i + j * (ylen + 1), (i + 1) + j * (ylen + 1), i + (j + 1) * (ylen + 1)])
# triangles with perpendicular angle on the top right
triangles.append([(i + 1) + j * (ylen + 1), i + (j + 1) * (ylen + 1), (i + 1) + (j + 1) * (yle