I'm looking for a way to convert CSV file to polygons shapefile.I need to make polygons with defined size. In the CSV file, The first row is the length of each polygon and the first column is the width of each polygons. and then I have filled the cells with polygons ID, and the ones that don't have any ID, are the gaps between polygons. And I thought I could have the script ask to import the coordinate of first and last point of all polygons to define the extent. (The excel sheet does NOT have any lat/long information, I only have the coordinates of the 4 corners of the whole field).
I have seen Python scripts on CSV to shapefile, but they all have lat/long info. And they don't generate polygons.I attach the sample of my CSV files for more clarification and a sample of output I would like to have.
Can you tell me where to start?
I know how to convert CSV file to KML, but then I get stuck at generating polygons.
This is how far I could go:
import csvwith open('/home/atena/Desktop/field_map.csv', 'rb') as csvfile: reader = csv.reader(csvfile, delimiter='\t') for line in reader print '; '.join(line)import osgeo.ogr, osgeo.osr from osgeo import ogr spatialReference = osgeo.osr.SpatialReference()spatialReference.ImportFromEPSG(4326)driver = osgeo.ogr.GetDriverByName('ESRI Shapefile')shapeData = driver.CreateDataSource('/home/atena/Desktop/polygons.shp')layer = shapeData.CreateLayer('field_map', spatialReference, osgeo.ogr.wkbPoint) layer_defn = layer.GetLayerDefn()
أكثر...
I have seen Python scripts on CSV to shapefile, but they all have lat/long info. And they don't generate polygons.I attach the sample of my CSV files for more clarification and a sample of output I would like to have.
Can you tell me where to start?
I know how to convert CSV file to KML, but then I get stuck at generating polygons.
This is how far I could go:
import csvwith open('/home/atena/Desktop/field_map.csv', 'rb') as csvfile: reader = csv.reader(csvfile, delimiter='\t') for line in reader print '; '.join(line)import osgeo.ogr, osgeo.osr from osgeo import ogr spatialReference = osgeo.osr.SpatialReference()spatialReference.ImportFromEPSG(4326)driver = osgeo.ogr.GetDriverByName('ESRI Shapefile')shapeData = driver.CreateDataSource('/home/atena/Desktop/polygons.shp')layer = shapeData.CreateLayer('field_map', spatialReference, osgeo.ogr.wkbPoint) layer_defn = layer.GetLayerDefn()


أكثر...