1

I polygonized a raster with the following code:

from osgeo import gdal, ogr, osr
gdal.UseExceptions()

srs = osr.SpatialReference()
srs.ImportFromEPSG(32633)

ds = gdal.Open('H:/Threshold/savi_nsdvi66.tif')
srcband = ds.GetRasterBand(1)
dst_layername = 'H:/Threshold/c11111111'
drv = ogr.GetDriverByName('ESRI Shapefile')
dst_ds = drv.CreateDataSource(dst_layername + '.shp')

dst_layer = dst_ds.CreateLayer(dst_layername, srs = srs,   geom_type=ogr.wkbMultiPolygon )
polygone = gdal.Polygonize( srcband, None, dst_layer, -1, [], callback=None )

Everything works fine just one point is freaking me out. The shapefile shows the correct reference system (+proj=utm +zone=33 +datum=WGS84 +units=m +no_defs) in QGIS but I receive wrong layer spatial system units (xmin,xmax,ymin,ymax) dimensions from the input raster file not the usual EPSG coordinates.

closed as off-topic by Ian Turton Feb 2 at 9:38

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This problem cannot or can no longer be reproduced. Changes to the system or to the asker's circumstances may have rendered the question obsolete, or the question does not include a procedure to enable potential answerers to reproduce the same symptoms. Such questions are off-topic as they are unlikely to help future readers, but editing them to include more details can lead to re-opening." – Ian Turton
If this question can be reworded to fit the rules in the help center, please edit the question.

  • what do you mean by "not the usual EPSG coordinates"? EPSG is not a unit, in this case the units would be meters – Ian Turton Feb 1 at 14:18
  • For a shapefile i want to compare with i have those values (xMin,yMin 419726.66,5852881.85 : xMax,yMax 420461.79,5853444.63) for the one from the example code i get (xMin,yMin 0,0 : xMax,yMax 10980,10980). I dont mean units i mean the extension?! – RemoteSensing Feb 1 at 14:22
  • so your bounding box is wrong? is your tif georeferenced? please add the output of gdalinfo to the question – Ian Turton Feb 1 at 14:27
  • Yes youre right. For the comand print ds.GetMetadata() i recieve {}. I wrote the raster from a numpy array before. – RemoteSensing Feb 1 at 14:38
  • 1
    then that is your problem – Ian Turton Feb 1 at 14:40

Browse other questions tagged or ask your own question.