AnsweredAssumed Answered

Scripting env.XYResolution settings?

Question asked by jplay on Jun 8, 2015
Latest reply on Jun 28, 2015 by xander_bakker

I am hoping for a little clarification on how scripting env.XYResolution and/or env.XYTolerance adjustments work.


My script works; I have a question about why it works the way it does.


Because I need to match the work done by another department, I need to create a feature dataset with  resolution values equal to 0.01 feet and all the tolerances equal to 0.02 feet. I thought creating a spatial reference (arcpy.CreateSpatialReference_management) to use in the feature dataset creation would do it, but it only gets me halfway there. I still end up needing to change the XY resolution and tolerance through the environment (env) function.


I’m just confused why it needs to be written the way it does.


This works:

XY_Resolution = arcpy.env.XYResolution
arcpy.env.XYResolution = "0.01 Feet"
XY_Tolerance = arcpy.env.XYTolerance
arcpy.env.XYTolerance = "0.02 Feet"
arcpy.CreateFeatureDataset_management(TerrainGDB, DatasetName, Coordinate_System)
arcpy.env.XYResolution = XY_Resolution
arcpy.env.XYTolerance = XY_Tolerance


This does not:

arcpy.CreateFeatureDataset_management(TerrainGDB, DatasetName, Coordinate_System)
arcpy.env.XYResolution = "0.01 Feet"
arcpy.env.XYTolerance = "0.02 Feet"


Why does the first example work and the second not? The first example just seems overly redundant:

XY_Resolution = arcpy.env.XYResolution = "0.01 Feet" = arcpy.env.XYResolution = XY_Resolution.


Maybe I’m just trying to make it too complicated. Can someone help explain this to me?


I keep thinking I have it figured out. But then I think a little bit more and lose it. Is  XY_Resolution = arcpy.env.XYResolution behaving kind of like Coordinate_System = arcpy.CreateSpatialReference_management only without the “create” verbiage and the parameters? Meaning that arcpy.env.XYResolution can’t be set by anything but another environment setting. But then, arcpy.env.XYResolution is being set by the value “0.01 Feet” and not by another environment setting. The help doesn’t say anything about setting up the code like the first example, only "arcpy.env.XYTolerance = linear_unit". But the first example is what's produced when the process is exported from ModelBuilder.


I feel like I’m missing some giant concept that would make this all make more sense.