Jonas,

 

I think your formatting of the arguments is not correct.  There are lots of 
ways to do what you need to do.  You can just use your commandline options 
directly in the python gdal.Translate options or you can call gdal_translate 
directly using the python subprocess.call command. There are plenty of examples 
if you just search for it.  I think you can just do something like this for 
what you need:

 

from osgeo import gdal

ds = gdal.Warp(out_path+’tmp.tif’, [‘I:\\indata\\VPDsc\\VPD_scalar.tif’], 
options=’-s_srs EPSG:4326 -t_srs EPSG:32628 -overwrite -tr 20 20 -wm 9000 
-multi -r near -te 453123 1702425 454123 1703425 -te_srs EPSG:32628’)

 

See the documentation sent earlier.  Also, this example might help you:

 

https://gis.stackexchange.com/a/380429/53019

 

Regards,

 

Chris

 

From: gdal-dev [mailto:gdal-dev-boun...@lists.osgeo.org] On Behalf Of Jonas 
Ardö via gdal-dev
Sent: Wednesday, November 02, 2022 8:30 AM
To: Even Rouault; gdal-dev@lists.osgeo.org
Subject: Re: [gdal-dev] Command line /python syntax differences

 

Thanks Even,

Still some discrepancy.

Python (don't work but no error and no output ):
    src_ds = gdal.Open("I:\indata\VPDsc\VPD_scalar.tif")
    #1 GDALWARP to warp all bands in one go
    options = gdal.WarpOptions(options=srcSRS="EPSG:4326", dstSRS="EPSG:32628", 
xRes=20.0, yRes=20.0, resampleAlg="bilinear", format='GTiff', 
outputBounds=[453123, 1702425, 454123, 1703425])
    newfile = gdal.Warp(out_path+"tmp.tif", src_ds, options=options)

Command line work ok:
    gdalwarp -s_srs EPSG:4326 -t_srs EPSG:32628 -overwrite -tr 20 20 -wm 9000 
-multi -r near -te 453123 1702425 454123 1703425 -te_srs EPSG:32628 
/cygdrive/i/indata/VPDsc/VPD_scalar.tif 
/cygdrive/i/data/SNDHR/VPDsc/VPD_scalar_test.tif 

Assuming using -te_srs and -t_srs are redundant?
("outputBoundsSRS – SRS in which output bounds are expressed, in the case they 
are not expressed in dstSRS")

Regards
/Jonas
On 02/11/2022 12:03, Even Rouault wrote:

Jonas,

The doc is at:

https://gdal.org/api/python/osgeo.gdal.html#osgeo.gdal.TranslateOptions

Even

Le 02/11/2022 à 11:53, Jonas Ardö via gdal-dev a écrit :

Dear gdal-gurus,

I am new to using gdal via Python.

As the command line arguments/keywords differ from command prompt mode and 
Python-mode (for example for example is -r in gdal_translate  the same  as 
resampleAlg in gdal.Translate in Python). 
I find it tricky to find arguments/keywords in Python.

How can all options/full syntax for gdal-pythons commands be listed as done 
here 
<https://gis.stackexchange.com/questions/352643/gdal-translate-in-python-where-do-i-find-how-to-convert-the-command-line-argum>
  ?
Where they also refer to https://gdal.org/python/ <https://gdal.org/python/>  
which do not exist.
Any other (full/completed) online resource for this?
Can "pydoc -g osgeo" be used?
Are the The gdal-dev Archives searchable?


Regards 

/Jonas, Lund University, Sweden





_______________________________________________
gdal-dev mailing list
gdal-dev@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/gdal-dev

-- 
http://www.spatialys.com
My software is free, but my time generally not.





-- 
Jonas Ardö
Physical Geography and Ecosystem Science
Lund University
Sölvegatan 12 22362 Lund Sweden
+46462224031
_______________________________________________
gdal-dev mailing list
gdal-dev@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/gdal-dev

Reply via email to