Note: This is not actually a question, I am trying to somehow report this issue to Esri but the options available for bug reports don't feel like they're well-suited to this case
When creating a 2-vertex Polyline from an Array of PointGeometry objects (via InsertCursor), the line is forcibly created with 0-length (null) geometry if the distance between the two points is < 0.0002 in units of the target layer's spatial reference. This means that, without a projected coordinate system, lines < 53.5 FEET long cannot be created!
arcpy should absolutely assume that any variation between coordinates is real and should create a line based on the supplied coordinates. It should not assume something is zero-length based on a rounded or calculated length... and currently it's making that assumption from the rounding of a calculated length! It is possible to manually create a line that measures with a Shape_Length < 0.000001 degrees -- so it should be just as possible to create that line (and any other) with Python
Evidence of this cutoff: Result of creating lines in unprojected WGS84 from two-point arrays, where the first point is at [-70.0, 43.0] and the second is at [Latitude, 43.0]
In conclusion: If you are using arcpy to create polylines and they are unexpectedly returning null geometries, try calculating the length between coordinates. If it's teeny-tiny, you have to use a different coordinate system to make it to work!
(I discovered this problem because a coworker was getting null geometry from a custom tool we use frequently when running it based on AGOL data that's in WGS84. I fixed it by telling the tool to use that map's spatial reference if the source layer's SC is geographic. I think this sounds like kind of a niche issue, but I can think of numerous ways that it could continue to hassle us down the line if I hadn't identified the reason & solution)
Esri/arcgis-python-api: Documentation and samples for ArcGIS API for Python
might be worthwhile raising an "issue" there to shorten the path of notification to those responsible for the api
Hi Jonah,
tolerance and resolution are determined from the spatialReference associated with the geometry. The spatial reference has details on domain, units, etc... which allows us to set appropriate tolerance and resolution. So best practice is to always set the SpatialReference when creating geometry objects.
When you're creating polyline it should include a spatialReference (eg: "arcpy.SpatialReference(4326)" for WGS84).
See examples in docs below
sr = arcpy.SpatialReference(4326)
line1 = arcpy.Polyline(arcpy.Array(...), sr)
In the absence of a known SpatialReference, you get the Unknown Coordinate system which has a XYTolerance of 0.001 Unknown Units... which for your case (GCS data) means a tolerance of ~111 meters at the equator. With that tolerance and GCS data, many ooperations are performed on the geometry will cause the vertices to snap and line to degenerate.