I need to create a point shapefile using the coordinates specified in the variable I called "my_points_dataset".
'my_points_dataset' variable has this structure:
1615311.055743243079633 4820229.073873873800039 0,1615321.055743243079633 4820229.073873873800039 0,1615331.055743243079633 4820229.073873873800039 0,1615341.055743243079633 4820229.073873873800039 0,1615351.055743243079633 4820229.073873873800039 0, etc`
The class of this variable is 'osgeo.ogr.Geometry'
Each point in 'my_points_dataset' is defined as x, y and z coordinates (z could be negligeable because is always 0). x, y and z data are separated by a space, each point is separated by comma.
I wrote this Python code, but at the end the result is an empty shapefile. Do yo know why?
import ogr, gdal
shpDriver = ogr.GetDriverByName('ESRI Shapefile')
if os.path.exists('/path/mypoints.shp'):
shpDriver.DeleteDataSource('/path/points_shapefile.shp')
outDataSource = shpDriver.CreateDataSource('/path/points_shapefile.shp')
outLayer = outDataSource.CreateLayer('/path/points_shapefile.shp', geom_type=ogr.wkbMultiPoint)
featureDefn = outLayer.GetLayerDefn()
outFeature = ogr.Feature(featureDefn)
outFeature.SetGeometry(my_points_dataset)
outLayer.CreateFeature(outFeature)
outFeature = None
outFeature.SetGeometry(my_points_dataset)
. Have you tried to use the code of the tutorial exactly?