How can i make image of shape file using python in QGIS?

المشرف العام

Administrator
طاقم الإدارة
Here I am trying to below code, but it give me error.

import shapefileimport Image, ImageDraw# Read in a shapefiler = shapefile.Reader("K:\TM_WORLD_BORDERS-0.3\Mississippi\mississippi")# Geographic x & y distancexdist = r.bbox[2] - r.bbox[0]ydist = r.bbox[3] - r.bbox[1]# Image width & heightiwidth = 400iheight = 600xratio = iwidth/xdistyratio = iheight/ydistpixels = []for x,y in r.shapes()[0].points: px = int(iwidth - ((r.bbox[2] - x) * xratio)) py = int((r.bbox[3] - y) * yratio) pixels.append((px,py))img = Image.new("RGB", (iwidth, iheight), "white")draw = ImageDraw.Draw(img)draw.polygon(pixels, outline="rgb(203, 196, 190)", fill="rgb(198, 204, 189)")img.save("C:\example\mississippi.png")
Error : An error has occured while executing Python code:

Traceback (most recent call last):

File "C:/Users/n/.qgis2/python/plugins\Importtool\Import_tool.py", line 351, in select_output_file_5 img = Image.new("RGB", (iwidth, iheight), "white")

File "C:\PROGRA~1\QGISWI~1\apps\Python27\lib\site-packages\PIL\Image.py", line 1763, in new return Image()._new(core.fill(mode, size, color))

File "C:\PROGRA~1\QGISWI~1\apps\Python27\lib\site-packages\PIL\Image.py", line 37, in getattr raise ImportError("The _imaging C module is not installed")

ImportError: The _imaging C module is not installed


أكثر...
 
أعلى