I am trying to transform a number of shapefiles by script using a self-defined custom transformation. When I transform the shapefile using my script in the python shell of the ArcGis GUI everything works fine.

However trying to do the same by the python command line using execfile("myscript.py") leads to a different result. The shapefile is transformed, but I suspect that a different transformation method is used, because the shapes (transformation by python shell and transformation by command line) are offset by 100 m. The transformation by python shell in the ArcGis GUI leads to the wanted outcome.

Here's my script:

import arcpy
from arcpy import env
import os

inputSystem = 31468 
transformSystem = 25832 #'ETRS_1989_UTM_Zone_32N' 
transformMethod = "GK4_to_ETRS_N32" #custom transformation
#transformMethod = "DHDN_To_ETRS_1989_8_NTv2" #available from ArcGis
#transformMethod = "DHDN_To_ETRS_1989_3" #available from ArcGis

outCS = arcpy.SpatialReference(transformSystem)
inpCS = arcpy.SpatialReference(inputSystem)

dir = "C:/mypath"

arcpy.Project_management("C:/mypath/myshape.shp", "myshape_transformed.shp", outCS, transformMethod, inpCS)

The custom transformation requires the download of a separate .gsb file so I can't make it fully reproducible here. The custom transformation was created using the tool Create Custom Geographic Information. It works fine from inside ArcGis.

Any suggestion to what might lead to the strange problem? The script is part of a bigger script which will transform > 5k files, so I would prefer doing it with the much faster command line.

Versions used: ArcGis 10.2 Python command line version: 2.7 (comes installed with ArcGis)

  • 1
    To verfiy the name of the custom transform, run Project in ArcMap, choosing the custom transform. In Geoprocessing, Results, Copy as Python Snippet to see the actual name. – klewis Mar 13 at 18:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.