GOAL: Take a raster and reproject it from one co-ordinate set to another and also change the pixel size while I am at it by using GDAL.
WHY: I am trying to use gdal to speed up multiple rasters having to be reprojected which is taking a long time in ArcPy.
Current progress: I can get this to happen nicely by using ArcPy and the following segment of code:
arcpy.ProjectRaster_management(in.tif, out.tif, "PROJCS['WGS_1984_UTM_zone_48N',GEOGCS['GCS_WGS_1984',DATUM['D_WGS_1984',SPHEROID['WGS_1984',6378137.0,298.257223563]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]],PROJECTION['Transverse_Mercator'],PARAMETER['false_easting',500000.0],PARAMETER['false_northing',0.0],PARAMETER['central_meridian',105.0],PARAMETER['scale_factor',0.9996],PARAMETER['latitude_of_origin',0.0],UNIT['Meter',1.0]]", "NEAREST", "100", "", "", "GEOGCS['GCS_WGS_1984',DATUM['D_WGS_1984',SPHEROID['WGS_1984',6378137.0,298.257223563]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]]")
The GDAL code: I am using the segment of code below to hopefully try to obtain the same result.
call(['C:\Program Files (x86)\GDAL\gdalwarp.exe',"-s_srs", "EPSG:4326","-t_srs","EPSG:32648","-tr","100","100","-r","near","-srcnodata","0.0","-dstnodata","0.0","-of","GTiFF",in.tif, out.tif])
Actual result from gdal: A dataset that is reprojected to the correct co-ord system and pixel resized to the desired size.
The problem: The raster dataset when opened and worked with keeps showing that the min and max values it contains is the nodata value of +-3.40282e+038
The key point: Does anyone have any idea why this is not working correctly in gdal?
While trying different different options I found that by running
call(['C:\Program Files (x86)\GDAL\gdalwarp.exe',"-s_srs", "EPSG:4326","-t_srs","EPSG:32648",,"-srcnodata","0.0","-dstnodata","0.0","-of","GTiFF",in.tif, out.tif])
I found that the resulting cell size from the projection is ~1000x1000 so I don't know why it won't let me scale to a smaller cell size?
Extra checks:
- I have checked the spatial reference website to ensure that the EPSG co-ord I am using as the correct ones.
- And as far as I can tell from the gdalwarp info page the code should work nice.
gdalinfo -hist
report about the pixel size and histogram? Have you tried to use integer numbers for nodata-srsnodata 0 -dstnodata 0
?