Create four points with slightly different properties to test other properties.
<SPAN class="operator token">>></SPAN><SPAN class="operator token">></SPAN> pnt0 <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>Point<SPAN class="punctuation token">(</SPAN>X<SPAN class="operator token">=</SPAN><SPAN class="number token">1</SPAN><SPAN class="punctuation token">,</SPAN>Y<SPAN class="operator token">=</SPAN><SPAN class="number token">2</SPAN><SPAN class="punctuation token">,</SPAN>Z<SPAN class="operator token">=</SPAN><SPAN class="number token">3</SPAN><SPAN class="punctuation token">,</SPAN>M<SPAN class="operator token">=</SPAN><SPAN class="number token">4</SPAN><SPAN class="punctuation token">,</SPAN>ID<SPAN class="operator token">=</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="comment token"># a point</SPAN>
<SPAN class="operator token">>></SPAN><SPAN class="operator token">></SPAN> pnt1 <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>Point<SPAN class="punctuation token">(</SPAN>X<SPAN class="operator token">=</SPAN><SPAN class="number token">1</SPAN><SPAN class="punctuation token">,</SPAN>Y<SPAN class="operator token">=</SPAN><SPAN class="number token">2</SPAN><SPAN class="punctuation token">,</SPAN>Z<SPAN class="operator token">=</SPAN><SPAN class="number token">1</SPAN><SPAN class="punctuation token">,</SPAN>M<SPAN class="operator token">=</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">,</SPAN>ID<SPAN class="operator token">=</SPAN><SPAN class="number token">1</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="comment token"># different Z,M and ID</SPAN>
<SPAN class="operator token">>></SPAN><SPAN class="operator token">></SPAN> pnt2 <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>Point<SPAN class="punctuation token">(</SPAN>X<SPAN class="operator token">=</SPAN><SPAN class="number token">3</SPAN><SPAN class="punctuation token">,</SPAN>Y<SPAN class="operator token">=</SPAN><SPAN class="number token">4</SPAN><SPAN class="punctuation token">,</SPAN>Z<SPAN class="operator token">=</SPAN><SPAN class="number token">2</SPAN><SPAN class="punctuation token">,</SPAN>M<SPAN class="operator token">=</SPAN><SPAN class="number token">2</SPAN><SPAN class="punctuation token">,</SPAN>ID<SPAN class="operator token">=</SPAN><SPAN class="number token">2</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="comment token"># different X,Y,Z,M and ID</SPAN>
<SPAN class="operator token">>></SPAN><SPAN class="operator token">></SPAN> pnt3 <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>Point<SPAN class="punctuation token">(</SPAN>X<SPAN class="operator token">=</SPAN><SPAN class="number token">1</SPAN><SPAN class="punctuation token">,</SPAN>Y<SPAN class="operator token">=</SPAN><SPAN class="number token">2</SPAN><SPAN class="punctuation token">,</SPAN>Z<SPAN class="operator token">=</SPAN><SPAN class="number token">3</SPAN><SPAN class="punctuation token">,</SPAN>M<SPAN class="operator token">=</SPAN><SPAN class="number token">4</SPAN><SPAN class="punctuation token">,</SPAN>ID<SPAN class="operator token">=</SPAN><SPAN class="number token">3</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="comment token"># clone pnt0, changing ID only</SPAN>
<SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
Perform some equality checks to test what is comparable to pnt0. There is some fancy attribute collection and print formatting.
<SPAN class="operator token">>></SPAN><SPAN class="operator token">></SPAN> all_pnts <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">[</SPAN>pnt0<SPAN class="punctuation token">,</SPAN>pnt1<SPAN class="punctuation token">,</SPAN>pnt2<SPAN class="punctuation token">,</SPAN>pnt3<SPAN class="punctuation token">]</SPAN>
<SPAN class="operator token">>></SPAN><SPAN class="operator token">></SPAN> equality <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">[</SPAN><SPAN class="punctuation token">[</SPAN>getattr<SPAN class="punctuation token">(</SPAN>pnt0<SPAN class="punctuation token">,</SPAN>i<SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">==</SPAN> getattr<SPAN class="punctuation token">(</SPAN>p<SPAN class="punctuation token">,</SPAN>i<SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">for</SPAN> i <SPAN class="keyword token">in</SPAN> props<SPAN class="punctuation token">]</SPAN> <SPAN class="keyword token">for</SPAN> p <SPAN class="keyword token">in</SPAN> all_pnts<SPAN class="punctuation token">]</SPAN>
<SPAN class="operator token">>></SPAN><SPAN class="operator token">></SPAN> <SPAN class="keyword token">for</SPAN> i <SPAN class="keyword token">in</SPAN> range<SPAN class="punctuation token">(</SPAN>len<SPAN class="punctuation token">(</SPAN>equality<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN>
<SPAN class="punctuation token">.</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="punctuation token">.</SPAN> <SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">'pnt0 vs pnt{}: {}'</SPAN><SPAN class="punctuation token">.</SPAN>format<SPAN class="punctuation token">(</SPAN>i<SPAN class="punctuation token">,</SPAN> equality<SPAN class="punctuation token">[</SPAN>i<SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="punctuation token">.</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="punctuation token">.</SPAN>
pnt0 vs pnt0<SPAN class="punctuation token">:</SPAN> <SPAN class="punctuation token">[</SPAN><SPAN class="token boolean">True</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="token boolean">True</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="token boolean">True</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="token boolean">True</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="token boolean">True</SPAN><SPAN class="punctuation token">]</SPAN>
pnt0 vs pnt1<SPAN class="punctuation token">:</SPAN> <SPAN class="punctuation token">[</SPAN><SPAN class="token boolean">True</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="token boolean">True</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="token boolean">False</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="token boolean">False</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="token boolean">False</SPAN><SPAN class="punctuation token">]</SPAN>
pnt0 vs pnt2<SPAN class="punctuation token">:</SPAN> <SPAN class="punctuation token">[</SPAN><SPAN class="token boolean">False</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="token boolean">False</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="token boolean">False</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="token boolean">False</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="token boolean">False</SPAN><SPAN class="punctuation token">]</SPAN>
pnt0 vs pnt3<SPAN class="punctuation token">:</SPAN> <SPAN class="punctuation token">[</SPAN><SPAN class="token boolean">True</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="token boolean">True</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="token boolean">True</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="token boolean">True</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="token boolean">False</SPAN><SPAN class="punctuation token">]</SPAN>
<SPAN class="operator token">>></SPAN><SPAN class="operator 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>It is good, that pnt0 is identical to itself, and pnt3 only differs by the ID number. All the other comparisons identify what attributes in the properties list (prop) differ. Why not simplify things then and use the built-in methods? Well...because...
<SPAN class="operator token">>></SPAN><SPAN class="operator token">></SPAN> pnt0 <SPAN class="operator token">==</SPAN> pnt3
<SPAN class="token boolean">False</SPAN>
<SPAN class="operator token">>></SPAN><SPAN class="operator token">></SPAN> pnt0<SPAN class="punctuation token">.</SPAN>equals<SPAN class="punctuation token">(</SPAN>pnt3<SPAN class="punctuation token">)</SPAN>
<SPAN class="token boolean">True</SPAN>
<SPAN class="operator token">>></SPAN><SPAN class="operator token">></SPAN>
<SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
The first equality check ( == ) is comparing objects and all its properties, whilst the second
check doesn’t consider the ID value. To confirm this consider the following tests.
I would expect this behaviour
real_pnt <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>Point<SPAN class="punctuation token">(</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="number token">1</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="number token">1</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="operator token">>></SPAN><SPAN class="operator token">></SPAN> real_pnt2 <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>Point<SPAN class="punctuation token">(</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="number token">1</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="number token">1</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="operator token">>></SPAN><SPAN class="operator token">></SPAN> real_pnt <SPAN class="operator token">==</SPAN> real_pnt
<SPAN class="token boolean">True</SPAN>
<SPAN class="operator token">>></SPAN><SPAN class="operator token">></SPAN> real_pnt <SPAN class="operator token">==</SPAN> real_pnt2
<SPAN class="token boolean">False</SPAN>
<SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
not this
<SPAN class="operator token">>></SPAN><SPAN class="operator token">></SPAN> real_pnt<SPAN class="punctuation token">.</SPAN>equals<SPAN class="punctuation token">(</SPAN>real_pnt2<SPAN class="punctuation token">)</SPAN>
<SPAN class="token boolean">True</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN></SPAN>
<SPAN class="operator token">>></SPAN><SPAN class="operator token">></SPAN> a <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>Point<SPAN class="punctuation token">(</SPAN>X<SPAN class="operator token">=</SPAN><SPAN class="number token">1</SPAN><SPAN class="punctuation token">,</SPAN>Y<SPAN class="operator token">=</SPAN><SPAN class="number token">2</SPAN><SPAN class="punctuation token">,</SPAN>Z<SPAN class="operator token">=</SPAN><SPAN class="number token">3</SPAN><SPAN class="punctuation token">,</SPAN>M<SPAN class="operator token">=</SPAN><SPAN class="number token">4</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="operator token">>></SPAN><SPAN class="operator token">></SPAN> b <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>Point<SPAN class="punctuation token">(</SPAN>X<SPAN class="operator token">=</SPAN><SPAN class="number token">1</SPAN><SPAN class="punctuation token">,</SPAN>Y<SPAN class="operator token">=</SPAN><SPAN class="number token">2</SPAN><SPAN class="punctuation token">,</SPAN>Z<SPAN class="operator token">=</SPAN><SPAN class="number token">3</SPAN><SPAN class="punctuation token">,</SPAN>M<SPAN class="operator token">=</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="operator token">>></SPAN><SPAN class="operator token">></SPAN> c <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>Point<SPAN class="punctuation token">(</SPAN>X<SPAN class="operator token">=</SPAN><SPAN class="number token">1</SPAN><SPAN class="punctuation token">,</SPAN>Y<SPAN class="operator token">=</SPAN><SPAN class="number token">2</SPAN><SPAN class="punctuation token">,</SPAN>Z<SPAN class="operator token">=</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">,</SPAN>M<SPAN class="operator token">=</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="operator token">>></SPAN><SPAN class="operator token">></SPAN> a <SPAN class="operator token">==</SPAN> b<SPAN class="punctuation token">,</SPAN> a <SPAN class="operator token">==</SPAN> c<SPAN class="punctuation token">,</SPAN> b <SPAN class="operator token">==</SPAN> c
<SPAN class="punctuation token">(</SPAN><SPAN class="token boolean">False</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="token boolean">False</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="token boolean">False</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="operator token">>></SPAN><SPAN class="operator token">></SPAN> a<SPAN class="punctuation token">.</SPAN>equals<SPAN class="punctuation token">(</SPAN>b<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">,</SPAN> a<SPAN class="punctuation token">.</SPAN>equals<SPAN class="punctuation token">(</SPAN>c<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">,</SPAN> b<SPAN class="punctuation token">.</SPAN>equals<SPAN class="punctuation token">(</SPAN>c<SPAN class="punctuation token">)</SPAN>
<SPAN class="punctuation token">(</SPAN><SPAN class="token boolean">True</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="token boolean">True</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="token boolean">True</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="operator token">>></SPAN><SPAN class="operator token">></SPAN>
<SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
Shades of George Orwell...
"...all Points are equal but some Points are more equal than others..."
Disappointing if you require comparisons on all point properties.
Well PointGeometry is no better, since it depends upon the points that are used to construct it. Consider the equality check again, using PointGeometry objects instead of Point objects.
<SPAN class="operator token">>></SPAN><SPAN class="operator token">></SPAN> pg_a <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>PointGeometry<SPAN class="punctuation token">(</SPAN>a<SPAN class="punctuation token">)</SPAN>
<SPAN class="operator token">>></SPAN><SPAN class="operator token">></SPAN> pg_b <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>PointGeometry<SPAN class="punctuation token">(</SPAN>b<SPAN class="punctuation token">)</SPAN>
<SPAN class="operator token">>></SPAN><SPAN class="operator token">></SPAN> pg_c <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>PointGeometry<SPAN class="punctuation token">(</SPAN>c<SPAN class="punctuation token">)</SPAN>
<SPAN class="operator token">>></SPAN><SPAN class="operator token">></SPAN>
<SPAN class="operator token">>></SPAN><SPAN class="operator token">></SPAN> pg_a <SPAN class="operator token">==</SPAN> pg_b<SPAN class="punctuation token">,</SPAN> pg_a <SPAN class="operator token">==</SPAN> pg_c<SPAN class="punctuation token">,</SPAN> pg_b <SPAN class="operator token">==</SPAN> pg_c
<SPAN class="punctuation token">(</SPAN><SPAN class="token boolean">False</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="token boolean">False</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="token boolean">False</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="operator token">>></SPAN><SPAN class="operator token">></SPAN> pg_a<SPAN class="punctuation token">.</SPAN>equals<SPAN class="punctuation token">(</SPAN>pg_b<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">,</SPAN> pg_a<SPAN class="punctuation token">.</SPAN>equals<SPAN class="punctuation token">(</SPAN>pg_c<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">,</SPAN> pg_b<SPAN class="punctuation token">.</SPAN>equals<SPAN class="punctuation token">(</SPAN>pg_c<SPAN class="punctuation token">)</SPAN>
<SPAN class="punctuation token">(</SPAN><SPAN class="token boolean">True</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="token boolean">True</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="token boolean">True</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="operator token">>></SPAN><SPAN class="operator 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>
Any comments as to why the Arcpy Point and PointGeometry class are so feable? Is the implementation in ArcObjects better? Or should I go back to using my own geometry classes.
I will be producing a summary on my blog after my musings about the various geometry classes is complete but my impressions are somewhat muted by the seemingly poor implementation or exposure to useful properties and methods.