I am trying to process SENTINEL-1 GRD data using python and gdal. I want to get the shapefile from the input data. I have tried to use gdal.Open() using the following extensions but nothing seems to work:

S1A_IW_GRDH_1SDV_20150109T163157_20150109T163222_004097_004F52_6A00.SAFE/manifest.safe S1A_IW_GRDH_1SDV_20150109T163157_20150109T163222_004097_004F52_6A00.SAFE S1A_IW_GRDH_1SDV_20150109T163157_20150109T163222_004097_004F52_6A00.tif S1A_IW_GRDH_1SDV_20150109T163157_20150109T163222_004097_004F52_6A00.zip

srs = osr.SpatialReference()

src_ds = gdal.Open( "S1A_IW_GRDH_1SDV_20150109T163157_20150109T163222_004097_004F52_6A00.SAFE" )
if src_ds is None:
    print 'Cannot open %s' % src_filename

    srcband = src_ds.GetRasterBand(1)
except RuntimeError, e:
    print 'Band ( %i ) not found' % band_num
    print e

dst_layername = "output"
drv = ogr.GetDriverByName("ESRI Shapefile")
dst_ds = drv.CreateDataSource( dst_layername + ".shp" )
dst_layer = dst_ds.CreateLayer(dst_layername, srs = srs )

gdal.Polygonize( srcband, None, dst_layer, -1, [], callback=None )

Does anyone know how to handle these data using gdal?

Best, Elisavet

  • hm, I can open the measurement/*.tiff files with gdalinfo ... so I guess it should be working like that. – pLumo Jul 26 '18 at 13:14
  • The files are not warped yet, but have only GCPs, so Polygonizing may need one extra warping step. But you should be able to open them ... – pLumo Jul 26 '18 at 13:17
  • I checked and it fails at the last step: gdal.Polygonize(srcband, None, dst_layer, 0, [],callback=None ). @RoVo like which warping step could be missing? – eliparsel Jul 27 '18 at 8:12
  • I don't know in Python, in the command line it would be a simple gdalwarp srcfile dstfile, maybe -t_srs EPSG:... is needed. – pLumo Jul 27 '18 at 8:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.