I have three shapefiles with undefined projection, but I know which one was used (Lisboa_Hayford_Gauss_IPCC). I need to first Define Projection. It works. I then need to transform it to WGS_1984, so I've used:
import sys, arcpy #globals set env.workspace and other used paths import globals as g def main(): # set local variables inDataset = ["rede_Coimbra_node.shp", "rede_Coimbra_link.shp", "rede_Coimbra_zone.shp"] prjFile = g.coveragePath + "Lisboa Hayford Gauss IPCC.prj" prjFileDatum73 = g.coveragePath + "Datum 73 Hayford Gauss IPCC.prj" prjFileWGS = g.coveragePath + "WGS 1984.prj" # Geographic transformation - transformation1 = "Datum_Lisboa_Hayford_To_Datum_73_1" transformation2 = "Datum_73_To_WGS_1984_4" sr1 = arcpy.SpatialReference(prjFile) print sr1.name #"spatialRef.name = Lisboa_Hayford_Gauss_IPCC" #sr2= arcpy.SpatialReference(prjFileDatum73) #print sr2.name #print (arcpy.ListTransformations(sr1, sr2)) #spatialRef.name = "Datum_73_Hayford_Gauss_IPCC" sr3 = arcpy.SpatialReference(prjFileWGS) print (arcpy.ListTransformations(sr1, sr3)) #spatialRef.name = "GCS_WGS_1984" try: print "..." for fc in inDataset: fcFullPath = g.coveragePath+fc #arcpy.DefineProjection_management(fcFullPath, prjFile) outfc= fc.strip(".shp") outfc = arcpy.env.workspace+"/"+outfc+"_wgs1984" print outfc arcpy.Project_management (fcFullPath, outfc,prjFileWGS, u'Datum_Lisboa_Hayford_To_Datum_73_1 + Datum_73_To_WGS_1984_4',prjFile) #arcpy.Project_management (fcFullPath, outfc,prjFileDatum73, transformation1,prjFile) #arcpy.Project_management (outfc, outfc+"_wgs84",prjFileWGS, transformation2,prjFileDatum73) except Exception, e: # If an error occurred, print line number and error message tb = sys.exc_info() print "-->Line %i" % tb.tb_lineno print e.message if __name__ == '__main__': main()
I also have a layer from OSM, which I also projected to WGS_1984 GCS and it fits perfectly to the World Imagery provided by ArcGIS Online or OSM basemap.
However, my projected three shapefiles (now converted to feature classes) don't seem to fit so well. They have a deviation from 1-2m to the raster basemap. Did I do something wrong or is it because the online basemaps are in other CRSs and I can't change that?