|
@@ -2,55 +2,26 @@ import geopandas as gpd
|
|
|
import matplotlib.pyplot as plt
|
|
|
from shapely.wkt import loads
|
|
|
from PIL import Image
|
|
|
+import os
|
|
|
|
|
|
|
|
|
|
|
|
-def resizeImage(filePath):
|
|
|
+def resizeImage(dir,fileName):
|
|
|
|
|
|
- original_image = Image.open(filePath)
|
|
|
+ original_image = Image.open(dir+"/"+fileName)
|
|
|
|
|
|
resized_image = original_image.resize((256, 256))
|
|
|
- filePath = filePath.replace('tb', 'tb_256')
|
|
|
+ dir = dir.replace('tb', 'tb_256')
|
|
|
+ if not os.path.exists(dir):
|
|
|
+ os.makedirs(dir)
|
|
|
|
|
|
- resized_image.save(filePath)
|
|
|
+ resized_image.save(dir+"/"+fileName)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-def savePng(fileName, ewkt):
|
|
|
+
|
|
|
+def savePng(fileName, ewkt,dir):
|
|
|
|
|
|
geometry = loads(ewkt.split(';')[1])
|
|
|
gdf = gpd.GeoDataFrame(geometry=[geometry])
|
|
@@ -78,12 +49,16 @@ def savePng(fileName, ewkt):
|
|
|
ax.axis('off')
|
|
|
|
|
|
|
|
|
- filePath = 'img/tb/' + fileName + '.png'
|
|
|
- plt.savefig(filePath, dpi=300, bbox_inches='tight', pad_inches=0)
|
|
|
+ dir=dir+'/tb'
|
|
|
+ if not os.path.exists(dir):
|
|
|
+ os.makedirs(dir)
|
|
|
+
|
|
|
+ fileName = fileName + '.png'
|
|
|
+ plt.savefig(dir+"/"+fileName, dpi=300, bbox_inches='tight', pad_inches=0)
|
|
|
plt.close()
|
|
|
|
|
|
|
|
|
- resizeImage(filePath)
|
|
|
+ resizeImage(dir,fileName)
|
|
|
|
|
|
|
|
|
|