I want to create a shape file in the end of this process. How can I do it? please respond if anyone knows this question.
import os, sys, numpy, scipy, osgeo.ogrfrom scipy import *from scipy.cluster.vq import *import matplotlib.pyplot as pltos.chdir('c:\ospy_data1')file = open ('out4.txt', 'r')separated = file.read().split ('\n')file.close()x = []y = []for anything in separated: xAndy= anything.split (',') x.append (float(xAndy [1])) y.append (float(xAndy [2]))xx = numpy.array (x)xxx = xx.reshape (42,1)yy = numpy.array yyy = yy.reshape (42,1)features = numpy.concatenate ((xxx, yyy), axis = 1)fot = features.reshape (42, 2)print (xxx),'\n'print (yyy),'\n'print (features), '\n'centroids,variance = kmeans (fot, 8)code,distance = vq(fot,centroids)plt.plot ([p[0] for p in xxx], [p[0] for p in yyy], 'or', markersize = 10)plt.plot ([p[0] for p in centroids], [p[1] for p in centroids], 'go', markersize = 10)plt.show()
أكثر...
import os, sys, numpy, scipy, osgeo.ogrfrom scipy import *from scipy.cluster.vq import *import matplotlib.pyplot as pltos.chdir('c:\ospy_data1')file = open ('out4.txt', 'r')separated = file.read().split ('\n')file.close()x = []y = []for anything in separated: xAndy= anything.split (',') x.append (float(xAndy [1])) y.append (float(xAndy [2]))xx = numpy.array (x)xxx = xx.reshape (42,1)yy = numpy.array yyy = yy.reshape (42,1)features = numpy.concatenate ((xxx, yyy), axis = 1)fot = features.reshape (42, 2)print (xxx),'\n'print (yyy),'\n'print (features), '\n'centroids,variance = kmeans (fot, 8)code,distance = vq(fot,centroids)plt.plot ([p[0] for p in xxx], [p[0] for p in yyy], 'or', markersize = 10)plt.plot ([p[0] for p in centroids], [p[1] for p in centroids], 'go', markersize = 10)plt.show()
أكثر...