How can I increase Polygon area and draw on center of image in python?

المشرف العام

Administrator
طاقم الإدارة
I have draw Polygon area on image but it will draw on below side corner of image and small area. How can I increase Polygon area and draw on center of image in python.

I am using below code.

import shapefile

from PIL import Image,ImageDraw

r = shapefile.Reader("K:\NEW_GIS\NEW Data\Garpani_NLRMP_Data\Shape files\Garpani_corrected")

shapes = r.shapes()

xdist = r.bbox[2] - r.bbox[0]

ydist = r.bbox[3] - r.bbox1

iwidth = 800

iheight = 800

xratio = iwidth/xdist

yratio = iheight/ydist

print xratio

print yratio

pixels = []

for x,y in r.shapes()[39].points:

px = int(iwidth - ((r.bbox[2] - x) * xratio))py = int((r.bbox[3] - y) * yratio)print pxprint pypixels.append((px,py))img = Image.new("RGB", (iwidth, iheight), "white")

draw = ImageDraw.Draw(img)

draw.polygon(pixels,outline="black", fill="white")

img_new_name="C:/example/Garpani_corrected.png" img.save(img_new_name)



أكثر...
 
أعلى