I have a script for creating points shapefiles, but I can not fix it for make a new polyline shp file.
I have obtained the data from a excel file and extract data in three differents listsLon,lat,label
import shapefile as shpfrom openpyxl import load_workbookfrom mpl_toolkits.basemap import Basemapimport matplotlib.pyplot as pltr = 'myfile.xlsm'wb = load_workbook(filename= r, data_only=True, use_iterators = True) ws = wb['Export_Area']cell_range = ws ['B5
9']tuple(ws.iter_rows('B5
9'))lista = []for row in ws.iter_rows('B5
9'): for cell in row: lista.append(cell.value) Longitud_area = (lista[1:len(lista):3]) latitud_area = (lista[0:len(lista):3]) puntos_area = (lista[2:len(lista):3])creating the shp file
out_file = 'ExportArea.shp'x,y,id_no=Longitud_area,latitud_area,puntos_arealogic = [True,False,True]w = shp.Writer(shp.POINT)w.autoBalance = 1 #ensures gemoetry and attributes matchw.field('X','F',10,5)w.field('Y','F',10,5) #float - needed for coordinatesw.field('etiqueta','D') #datefor j,k in enumerate(x): w.point(k,y[j]) #write the geometry w.record(k,y[j],puntos_area[j]) #write the attributescreating the prj file.
prj = open(out_file +'.prj', 'w')proyeccion ="GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]]'prj.write(proyeccion)It works fine for a point shp file but I can not see how to do the loop for making a poly shp file
أكثر...
I have obtained the data from a excel file and extract data in three differents listsLon,lat,label
import shapefile as shpfrom openpyxl import load_workbookfrom mpl_toolkits.basemap import Basemapimport matplotlib.pyplot as pltr = 'myfile.xlsm'wb = load_workbook(filename= r, data_only=True, use_iterators = True) ws = wb['Export_Area']cell_range = ws ['B5
out_file = 'ExportArea.shp'x,y,id_no=Longitud_area,latitud_area,puntos_arealogic = [True,False,True]w = shp.Writer(shp.POINT)w.autoBalance = 1 #ensures gemoetry and attributes matchw.field('X','F',10,5)w.field('Y','F',10,5) #float - needed for coordinatesw.field('etiqueta','D') #datefor j,k in enumerate(x): w.point(k,y[j]) #write the geometry w.record(k,y[j],puntos_area[j]) #write the attributescreating the prj file.
prj = open(out_file +'.prj', 'w')proyeccion ="GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]]'prj.write(proyeccion)It works fine for a point shp file but I can not see how to do the loop for making a poly shp file
أكثر...