How can I access the resolution and tolerance of a layer as shown in the image below?
Wolfgang KaiserUma Harano
It looks like while saving to memory, the environment settings aren't applied. When I saved my outputs to a file gdb, the resolution and tolerance were set as expected.
I however, would still appreciate any insight into the issue of the spatial reference object having the MTolerance property but not the MResolution property.
Hi
When you use this GP tool using the UI, do you see a different behavior?
For example, are you able to specify this same tolerance/resolution in the tool and run it? Do you get the expected results?
I am trying to see if there an issue using the Pro API or is the result the same with the GP Tool.
Thanks
Uma
Thanks Uma Harano. I was able to retrieve the tolerance and resolution values. I am attempting to use those tolerance and resolution values and apply them to a feature class that is created by the create routes tool like below:
<SPAN class="keyword token">double</SPAN> xyResolution <SPAN class="operator token">=</SPAN> <SPAN class="operator token">-</SPAN><SPAN class="number token">1</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="keyword token">double</SPAN> xyTolerance <SPAN class="operator token">=</SPAN> <SPAN class="operator token">-</SPAN><SPAN class="number token">1</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="keyword token">double</SPAN> mTolerance <SPAN class="operator token">=</SPAN> <SPAN class="operator token">-</SPAN><SPAN class="number token">1</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="keyword token">await</SPAN> QueuedTask<SPAN class="punctuation token">.</SPAN><SPAN class="token function">Run</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">=</SPAN><SPAN class="operator token">></SPAN> <SPAN class="punctuation token">{</SPAN> <SPAN class="keyword token">var</SPAN> sr_Template <SPAN class="operator token">=</SPAN> TemplateLayer<SPAN class="punctuation token">.</SPAN><SPAN class="token function">GetSpatialReference</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> xyResolution <SPAN class="operator token">=</SPAN> sr_Template<SPAN class="punctuation token">.</SPAN>XYResolution<SPAN class="punctuation token">;</SPAN> xyTolerance <SPAN class="operator token">=</SPAN> sr_Template<SPAN class="punctuation token">.</SPAN>XYTolerance<SPAN class="punctuation token">;</SPAN> mTolerance <SPAN class="operator token">=</SPAN> sr_Template<SPAN class="punctuation token">.</SPAN>MTolerance<SPAN class="punctuation token">;</SPAN> <SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="keyword token">var</SPAN> environments <SPAN class="operator token">=</SPAN> Geoprocessing<SPAN class="punctuation token">.</SPAN><SPAN class="token function">MakeEnvironmentArray</SPAN><SPAN class="punctuation token">(</SPAN>XYResolution<SPAN class="punctuation token">:</SPAN> xyResolution<SPAN class="punctuation token">,</SPAN> XYTolerance<SPAN class="punctuation token">:</SPAN> xyTolerance<SPAN class="punctuation token">,</SPAN> MTolerance<SPAN class="punctuation token">:</SPAN> mTolerance<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="keyword token">await</SPAN> Geoprocessing<SPAN class="punctuation token">.</SPAN><SPAN class="token function">ExecuteToolAsync</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"CreateRoutes_lr"</SPAN><SPAN class="punctuation token">,</SPAN> Geoprocessing<SPAN class="punctuation token">.</SPAN><SPAN class="token function">MakeValueArray</SPAN><SPAN class="punctuation token">(</SPAN>infc<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"Name"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"memory\\routes"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"LENGTH"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"#"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"#"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"LOWER_LEFT"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">1</SPAN><SPAN class="punctuation token">.</SPAN>89393939393939E<SPAN class="number token">-04</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="keyword token">false</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="keyword token">true</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">,</SPAN>environments<SPAN class="punctuation token">,</SPAN><SPAN class="keyword token">null</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="keyword token">null</SPAN><SPAN class="punctuation token">,</SPAN> GPExecuteToolFlags<SPAN class="punctuation token">.</SPAN>AddOutputsToMap<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
When I scrutinize the output file 'routes' however, the tolerance and resolution values are not applied. The output file has completely different values than the ones assigned by environments. Do you know what could be causing this issue?
The other issue is that the spatial reference object has the MTolerance but I am unable to locate the MResolution among the properties. The layer properties shown in the image in the original question does show the MResolution. Am I missing something?
Hi Marvis,
Resolution and Tolerance are properties of the Layer's SpatialReference.
<SPAN class="keyword token">var</SPAN> lyr <SPAN class="operator token">=</SPAN> MapView<SPAN class="punctuation token">.</SPAN>Active<SPAN class="punctuation token">.</SPAN>Map<SPAN class="punctuation token">.</SPAN><SPAN class="token function">GetLayersAsFlattenedList</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>OfType<SPAN class="operator token"><</SPAN>FeatureLayer<SPAN class="operator token">></SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="token function">FirstOrDefault</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> QueuedTask<SPAN class="punctuation token">.</SPAN><SPAN class="token function">Run</SPAN><SPAN class="punctuation token">(</SPAN> <SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">=</SPAN><SPAN class="operator token">></SPAN> <SPAN class="punctuation token">{</SPAN> <SPAN class="keyword token">var</SPAN> spatialReference <SPAN class="operator token">=</SPAN> lyr<SPAN class="punctuation token">.</SPAN><SPAN class="token function">GetSpatialReference</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="keyword token">var</SPAN> lyrResolution <SPAN class="operator token">=</SPAN> spatialReference<SPAN class="punctuation token">.</SPAN>XYResolution<SPAN class="punctuation token">;</SPAN> <SPAN class="keyword token">var</SPAN> lyrTolerance <SPAN class="operator token">=</SPAN> spatialReference<SPAN class="punctuation token">.</SPAN>XYTolerance<SPAN class="punctuation token">;</SPAN> <SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
Thanks!
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.