4

I have a script that goes through all the rasters in a particular folder and then reprojects it to another coordinate system, using arcpy.

My problem is that i keep on getting the following:

ERROR 000365: Invalid geographic transformation.

My code fails on this line

        arcpy.ProjectRaster_management(raster, in_memoryLayer, "British National Grid.prj","#", "#", transformation,"#", "#")

I have set the transformation to the following

transformation = "OSGB_1936_To_WGS_1984_7"

and have also tried

transformation = "PROJCS['British_National_Grid',GEOGCS['GCS_OSGB_1936',DATUM['D_OSGB_1936',SPHEROID['Airy_1830',6377563.396,299.3249646]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]],PROJECTION['Transverse_Mercator'],PARAMETER['False_Easting',400000.0],PARAMETER['False_Northing',-100000.0],PARAMETER['Central_Meridian',-2.0],PARAMETER['Scale_Factor',0.9996012717],PARAMETER['Latitude_Of_Origin',49.0],UNIT['Meter',1.0]]", "NEAREST", "0.516860387597052", "OSGB_1936_To_WGS_1984_7", "", "GEOGCS['GCS_WGS_1984',DATUM['D_WGS_1984',SPHEROID['WGS_1984',6378137.0,298.257223563]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433],METADATA['World',-180.0,-90.0,180.0,90.0,0.0,0.0174532925199433,0.0,1262]]"

I got the above from exporting a model from modelbuilder.

but i still get the error.

Here is the code for the ProjectRaster tool that is exported from ModelBuilder

arcpy.ProjectRaster_management(inputRaster, convertedRaster, "PROJCS['British_National_Grid',GEOGCS['GCS_OSGB_1936',DATUM['D_OSGB_1936',SPHEROID['Airy_1830',6377563.396,299.3249646]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]],PROJECTION['Transverse_Mercator'],PARAMETER['False_Easting',400000.0],PARAMETER['False_Northing',-100000.0],PARAMETER['Central_Meridian',-2.0],PARAMETER['Scale_Factor',0.9996012717],PARAMETER['Latitude_Of_Origin',49.0],UNIT['Meter',1.0]]", "NEAREST", "0.521227542928997", "OSGB_1936_To_WGS_1984_7", "", "GEOGCS['GCS_WGS_1984',DATUM['D_WGS_1984',SPHEROID['WGS_1984',6378137.0,298.257223563]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433],METADATA['World',-180.0,-90.0,180.0,90.0,0.0,0.0174532925199433,0.0,1262]]")

The above does not work when running from python, but the model itself does.

Any advice on where I'm going wrong?

PolyGeo
  • 65,136
  • 29
  • 109
  • 338
MapMan
  • 2,164
  • 1
  • 22
  • 32
  • 1
    Have you tried running it without using in_memory inputs and outputs? I know the regular project tool cannot use in_memory datasets for inputs and outputs. – dmahr Mar 06 '13 at 18:33
  • Try using the full path of the projection, e.g. "c:/ArcGIS/projections and coordinates or whatever/British National Grid.prj" – Jason Bellino Mar 06 '13 at 21:42
  • @dmahr, tried that, made no difference – MapMan Mar 07 '13 at 12:58
  • @Jason, tried that aswell, no difference, I can get it to work when I use modelbuilder but once exported it, i get the error. – MapMan Mar 07 '13 at 12:59
  • Do you have the NTv2 grid installed? If not you need to download it (below) and put it in ArcGIS install, pedata/ntv2/uk: http://www.ordnancesurvey.co.uk/oswebsite/support/os-net/ostn02-ntv2-format.html – mkennedy Mar 07 '13 at 16:18
  • @mkennedy,I've downloaded that, and have been using that from within ModelBuilder (which does work), I've edited the orig question with what the export to python script from modelbuilder for the ProjectRaster tool. – MapMan Mar 07 '13 at 16:56

1 Answers1

1

Check your transformation, OSGB_1936_To_WGS_1984_7, against the list of valid transformations: C:\ArcGIS\Desktop10.0\Documentation\geographic_transformations.pdf.

It is not listed in version of the document I have; only the following transformations for OSGB are valid:

enter image description here

PolyGeo
  • 65,136
  • 29
  • 109
  • 338
Jason Bellino
  • 4,321
  • 26
  • 35
  • Isn't there a spatial reference class method at 10.1 that lets you feed in 2 layers and it will return a list of the acceptable transformations between the 2? I'm not on 10.1 and I cannot find it in the docs right now. – Chad Cooper Mar 07 '13 at 15:10
  • 2
    This is an old list. The document was updated at 10.1. – mkennedy Mar 07 '13 at 16:23
  • He should still check it, unless you are saying that you already have and it exists in the 10.1 document. – Jason Bellino Mar 07 '13 at 18:22
  • @Jason, its in the 10.1 document. I think I might just stick with creating a model that iterates through my files as we know it works. – MapMan Mar 07 '13 at 21:15
  • Chad, the tool you are looking for is: http://gis.stackexchange.com/a/49119/10919 AND http://resources.arcgis.com/en/help/main/10.2/index.html#//018v0000001p000000 – Tom Dec 16 '13 at 23:34