1

I try to write a raster file in SAGA GIS format (sgrd). My script is work but some information is missing in the final file (i.e output.sgrd). Here is script :

from osgeo import gdal, ogr, osr
import numpy as np

raster = gdal.Open(raster_file)
driver = gdal.GetDriverByName('SAGA')
driver.Register()
cols = raster.RasterXSize
rows = raster.RasterYSize
band = raster.RasterCount
datatype = raster.GetRasterBand(1).DataType
outDataset = driver.Create(output+'output.sdat', cols, rows, band, datatype)
geoTransform = raster.GetGeoTransform()
outDataset.SetGeoTransform(geoTransform)
crs = raster.GetProjection()
outDataset.SetProjection(crs)

raster_out = np.zeros((rows, cols), dtype=np.uint8)
outBand = outDataset.GetRasterBand(1)
outBand.WriteArray(raster_out)

How can I fix my error?

  • Hi and welcome! :) We can't help you unless you add more details (which information is missing, why do you expect it) to your question! – bugmenot123 Feb 7 at 14:19
  • Hi @bugmenot123, thanks for your reply, i have a line on my raster and when i write this line in saga format this line miss. – Elite Feb 7 at 14:28
  • Is the line on a new layer or really pixels you added to your original raster? – bugmenot123 Feb 11 at 10:01

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.