Wednesday, August 17, 2011

Offset of TIF rasters in ArcGIS 10, pre-SP2

In Arc10, pre-SP2, our Landsat TIF rasters were being shifted half a pixel away from where they should be.  For older Landsat 5TM imagery the thermal band could be up 60m offset in both the x and y.  ESRI fixed the problem in SP2 (Bug NIM060759) but in case you are loading TIF rasters with a pre-SP2 version of Arc10, it is easy to shift the rasters back to the correct location.  Since we were not using the panchromatic rasters from Landsat 7, all of our half cell sizes were integers (30m -> 15m, 60m -> 30m, 120m -> 60m), but that may be an issue for other applications.
half_cell_width = int(0.5*arcpy.Describe(landsat_tif).meanCellWidth+0.5)
half_cell_height = int(0.5*arcpy.Describe(landsat_tif).meanCellHeight+0.5)
arcpy.Shift_management(landsat_tif, shift_raster, -half_cell_width, half_cell_height)


It is also fairly simple to check which ArcGIS version and service pack you have:
version_str = arcpy.GetInstallInfo("desktop")["SPBuild"]
version_str = "10.0.2.3200"
sp_str = version_str.split(".")[2]
sp_str = "2"

No comments:

Post a Comment