Commit 20083f6a authored by Mario Chirinos Colunga's avatar Mario Chirinos Colunga 💬

wkt raster

parent e86c5ba7
...@@ -28,18 +28,18 @@ def createLayer(wkt, layerName="wkt"): ...@@ -28,18 +28,18 @@ def createLayer(wkt, layerName="wkt"):
def getPolygonArray(image, wkt_geom): def getPolygonArray(image, wkt_geom):
rows, cols, geotransform = image.RasterYSize, image.RasterXSize, image.GetGeoTransform() rows, cols, geotransform = image.RasterYSize, image.RasterXSize, image.GetGeoTransform()
print(rows, cols, geotransform) print(rows, cols, geotransform)
sr = osr.SpatialReference() sr = osr.SpatialReference(wkt=image.GetProjection())
sr.ImportFromWkt(image.GetProjection()) # sr.ImportFromWkt(image.GetProjection())
# shapefile # shapefile
driverShp = ogr.GetDriverByName("ESRI Shapefile") driverShp = ogr.GetDriverByName("ESRI Shapefile")
data_source = driverShp.CreateDataSource("myShape.shp") data_source = driverShp.CreateDataSource("myShape.shp")
srs = osr.SpatialReference() # srs = osr.SpatialReference()
srs.ImportFromWkt(image.GetProjection()) # srs.ImportFromEPSG(4326)
layer = data_source.CreateLayer("wkt", srs, ogr.wkbPolygon) layer = data_source.CreateLayer("wkt", sr, ogr.wkbPolygon)
geometry = ogr.CreateGeometryFromWkt(wkt_geom) geometry = ogr.CreateGeometryFromWkt(wkt)
feature = ogr.Feature(layer.GetLayerDefn()) feature = ogr.Feature(layer.GetLayerDefn())
# feature.SetStyleString("PEN(c:#FF0000,w:5px);") # feature.SetStyleString("PEN(c:#FF0000,w:5px);")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment