I have a script tool that creates outputs with unknown coordinate systems. This is as designed. The outputs are profiles, created from an x,y table.
Recently (10.3?), the tool has been failing and that seems to be because ArcMap wants to apply the wgs84 coordinate system by default when none is specified.
I want it to be "Unknown" or "Undefined" both of which fail when I enter them into the MakeXY_Table_management tool:
arcpy.MakeXYEventLayer_management(proftab,"PROF_X","PROF_Y",profptlyr,"Unknown","#")
This also fails:
arcpy.DefineProjection_management(profptlyr,coor_system="Unknown"), although I can enter "Unknown" when I run the DefineProjection tool from the toolbox.
The coord_system input is considered illegitimate.
Is it possible to do this?
Thanks
Solved! Go to Solution.
Give this a shot.
import arcpy unknown = arcpy.SpatialReference() unknown.loadFromString(u'{B286C06B-0879-11D2-AACA-00C04FA33C20};-450359962737.05 -450359962737.05 10000;#;#;0.001;#;#;IsHighPrecision') arcpy.MakeXYEventLayer_management(r'C:\Path\To\DATA.csv', 'x_coord', 'y_coord', 'LayerName', unknown)
I'm not sure if there is a way to set the spatial reference to Unknown using the define projection tool. One thing you can do is use python to delete the .prj file for the shapefile. I'm not sure why you would ever want to do this, but that is one way to go about it.
There was an earlier question (some while ago) here.
Trying to find it.
Give this a shot.
import arcpy unknown = arcpy.SpatialReference() unknown.loadFromString(u'{B286C06B-0879-11D2-AACA-00C04FA33C20};-450359962737.05 -450359962737.05 10000;#;#;0.001;#;#;IsHighPrecision') arcpy.MakeXYEventLayer_management(r'C:\Path\To\DATA.csv', 'x_coord', 'y_coord', 'LayerName', unknown)
Freddie, brilliant.
As someone said at the time, nothing says Unknown Spatial Reference like..
{B286C06B-0879-11D2-AACA-00C04FA33C20}
Perfectly obvious.
The problem with creating an "Unknown/Undefined" spatial reference has been around for years; unfortunately, Esri has made it clear they don't really see it as much of a problem and don't plan on addressing it. For example, see Bug NIM-087033: Arcpy.DefineProjection_management does not take 'Unknown' as a valid coordinate syst....
The SpatialReference.loadFromString works, but it relies on passing the Esri internal Class ID/GUID value for the unknown spatial reference. Although that Class ID/GUID has remained the same for many, many years, it is nonetheless an internal value that Esri could change. My preferred workaround is to create an empty point geometry with no spatial reference, which gets turned into the unknown spatial reference, and then pass that into a variable:
>>> SR = arcpy.FromWKT('POINT EMPTY').spatialReference >>> #which can be seen to use Unknown/Undefined spatial reference >>> SR.exportToString() u'{B286C06B-0879-11D2-AACA-00C04FA33C20};-450359962737.05 -450359962737.05 10000;#;#;0.001;#;#;IsHighPrecision'
or like mine below...
One problem I run into trying to reply during the day, I get distracted and my responses get drawn out, so other responses come in before I hit reply. I wish comments could be easily saved as draft and revisited later. Although there is auto-saving, I have run into cases where I lost content, and copying and pasting the content/html back and forth to the clipboard is such a hassle.
Thank you, that did it.
Just like that.
Me thinks Freddie is being cruel....
so here is what you do
>>> desc = arcpy.Describe(r'f:\test\buff.shp') >>> SR_unknown = desc.SpatialReference >>> ancient_text = SR_unknown.exportToString() >>> print("FYI \n{}".format(ancient_text)) FYI {B286C06B-0879-11D2-AACA-00C04FA33C20};341985 5023985 300239975158033;#;#;0.001;#;#;IsHighPrecision >>>
Of course yours will be different, but it was an MTM zone 9 originally which the first two numbers are about right for.