from osgeo import gdal
from osgeo import osr
driver = gdal.GetDriverByName(‘GTiff’)
ds_in = gdal.Open(‘/DADES/MODELS/PRESCAT/2017/01/01/PRESCAT-2017010100_0.tiff’)
proj_in = ds_in.GetProjection()
ds_out = driver.Create(‘/tmp/out.tiff’, 675, 655,
4, gdal.GDT_Float32)
ds_out.SetGeoTransform([260000, 400, 0, 4750000, 0, -400])
proj_out = osr.SpatialReference()
proj_out.ImportFromEPSG(25831)
proj_out = proj_out.ExportToWkt()
ds_out.SetProjection(proj_out)
method = gdal.GRA_Cubic
gdal.ReprojectImage(ds_in, ds_out,
proj_in, proj_out,
method)
//////////////////
from osgeo import gdal
from osgeo import osr
driver = gdal.GetDriverByName(‘GTiff’)
ds_in = gdal.Open(‘/DADES/MODELS/PRESCAT/2017/01/01/PRESCAT-2017010100_0.tiff’)
proj_in = ds_in.GetProjection()
proj_out = osr.SpatialReference()
proj_out.ImportFromEPSG(25831)
proj_out = proj_out.ExportToWkt()
reproj_file = gdal.AutoCreateWarpedVRT( ds_in, ds_in.GetProjection(), proj_out )
driver = gdal.GetDriverByName(“GTiff”)
dest_file = driver.CreateCopy(“/tmp/t.tiff”, reproj_file, 0)
/////VRT//// —>
PROJCS["ETRS89 / UTM zone 31N",GEOGCS["ETRS89",DATUM["European_Terrestrial_Reference_System_1989",SPHEROID["GRS 1980",6378137,298.257222101,AUTHORITY["EPSG","7019"]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY["EPSG","6258"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4258"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",3],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],PARAMETER["false_northing",0],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["Easting",EAST],AXIS["Northing",NORTH],AUTHORITY["EPSG","25831"]]
2.4390661575654868e+05, 3.7262015453620070e+03, 0.0000000000000000e+00, 4.7562398508180482e+06, 0.0000000000000000e+00, -3.7262015453620070e+03
PRECIPITACIO
1483228800
SFC
%
1483228800
14,285714149475
2,1959420650101
0
3,4693737669996
-9.99000000000000E+02
Red
-0,007142857074737548
14,29285700654984
1000
0
0
1861|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|6|0|0|0|0|0|0|0|0|0|0|0|0|0|156|0|0|0|0|0|0|0|0|0|0|0|0|0|0|578|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0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|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|1|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|1
ESTATCEL
1483228800
SFC
--
1483228800
3
1,2654991243433
0
0,80600888335785
-9.99000000000000E+02
80
74
6.71089e+07
NearestNeighbour
Float32
/DADES/MODELS/PRESCAT/2017/01/01/PRESCAT-2017010100_0.tiff
-0.0199999511241912842,0.0399999991059303284,0,42.9200007356703281,0,-0.0399999991059303284
0.49999878928062591,25.000000558793559,0,1073.00004237517805,0,-25.000000558793559
243906.615756548679,3726.20154536200698,0,4756239.85081804823,0,-3726.20154536200698
-65.4571720792018255,0.000268369809798586279,0,1276.4311841204958,0,-0.000268369809798586279
GEOGCS["ED50",DATUM["European_Datum_1950",SPHEROID["International 1924",6378388,297.000000000005,AUTHORITY["EPSG","7022"]],AUTHORITY["EPSG","6230"]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433],AUTHORITY["EPSG","4230"],EXTENSION["CENTER_LONG",1.74]]
PROJCS["ETRS89 / UTM zone 31N",GEOGCS["ETRS89",DATUM["European_Terrestrial_Reference_System_1989",SPHEROID["GRS 1980",6378137,298.257222101,AUTHORITY["EPSG","7019"]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY["EPSG","6258"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4258"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",3],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],PARAMETER["false_northing",0],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["Easting",EAST],AXIS["Northing",NORTH],AUTHORITY["EPSG","25831"]]
-999
0
-999
0
0
0
0
0
0
0
0
0
0
0
0
0
./gdalwarp —config GDAL_DATA “../data/” -t_srs “EPSG:25831” /DADES/MODELS/PRESCAT/2017/01/01/PRESCAT-2017010100_0.tiff /tmp/l.tiff
./configure
make
cd swig/python
python setup install
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/tmp/gdal-2.1.0/.libs:/usr/lib64
export LD_LIBRARY_PATH
GDAL_DATA=/tmp/gdal-2.1.0/data
export GDAL_DATA
Links
http://www.gdal.org/warptut.html
http://www.gdal.org/gdal_tutorial.html
https://github.com/rouault/gdal2/blob/trunk/gdal/swig/python/scripts/gdal2tiles.py
http://gis.stackexchange.com/questions/143966/why-is-gdalwarp-changing-value-in-nodata-pixels
http://trac.osgeo.org/gdal/ticket/5675
https://gist.github.com/cspanring/5680334
Install gdal 2.1.0