Mijn vorige blogpost, \/blogs\/tilting\/2017\/06\/10\/a-case-of-missing-prefixes-esris-geometries?sr=search&searchId=c6def5e0-70d7-4799-991e-cfbe7cafee76&searchIndex=0<\/A>, was ongepland. Ik begon deze blogpost en de volgende te schrijven, en ik realiseerde me dat de achtergrondinformatie die ik wilde opnemen niet helemaal in een van beide paste, dus schreef ik de achtergrondinformatie apart op.<\/EM><\/P><\/P>In de loop der jaren heb ik de ArcPy Geometry constructors als eigenaardig ervaren, vooral bij rand- of nichegevallen zoals lege geometrieën. Als een betrokken gebruiker, die gelooft dat het geven van feedback aan ontwikkelaars belangrijk is, heb ik in de loop van de tijd verschillende bugs en verbeteringsverzoeken ingediend met betrekking tot geometry constructors. Direct gezegd, ik kan niet zeggen hoeveel er zijn geïmplementeerd, mogelijk slechts één, maar dat stond niet hoog op mijn wensenlijst.<\/P><\/P>Een paar jaar geleden diende ik het Support Empty Geometries with ArcPy Geometry Class Constructors<\/A> idee in. Aangezien zo weinig gebruikers met lege geometrieën werken, ben ik niet verrast door de magere 2 stemmen die het tot nu toe heeft ontvangen. <\/EM>ZoalsDavid Wynne<\/A> van Esri in de opmerkingen aangeeft, worden lege geometrieën eigenlijk ondersteund door de ArcPy Geometry constructors, alleen is de syntaxis ongedocumenteerd. Aangezien lege geometrieën worden ondersteund door de constructors, denk ik dat mijn oorspronkelijke idee samengevoegd moet worden onder Pythonic ArcPy Geometries<\/A>omdat wat ik eigenlijk wil een meer intuïtieve en idiomatische manier is om lege geometrieën te maken met behulp van ArcPy Geometry constructors. Ik zou mijn twee ideeën samenvoegen als ik dat kon, maar dat kan ik niet zelf, en ik wil het idee ook niet gewoon verwijderen.<\/EM><\/P><\/P>Als voorbeeld met de ArcPy Polygon klasse bekijken we een verscheidenheid aan manieren waarop men zou kunnen proberen een lege geometrie te construeren met behulp van de ArcPy Geometry constructors:<\/P><SPAN class="operator token">>><\/SPAN><SPAN class="operator token">><\/SPAN> ctor_stmts <SPAN class="operator token">=<\/SPAN> <SPAN class="punctuation token">(<\/SPAN> <SPAN class="punctuation token">.<\/SPAN><SPAN class="punctuation token">.<\/SPAN><SPAN class="punctuation token">.<\/SPAN> <SPAN class="string token">''<\/SPAN><SPAN class="punctuation token">,<\/SPAN> <SPAN class="punctuation token">.<\/SPAN><SPAN class="punctuation token">.<\/SPAN><SPAN class="punctuation token">.<\/SPAN> <SPAN class="string token">'None'<\/SPAN><SPAN class="punctuation token">,<\/SPAN> <SPAN class="punctuation token">.<\/SPAN><SPAN class="punctuation token">.<\/SPAN><SPAN class="punctuation token">.<\/SPAN> <SPAN class="string token">'arcpy.Array()'<\/SPAN><SPAN class="punctuation token">,<\/SPAN> <SPAN class="punctuation token">.<\/SPAN><SPAN class="punctuation token">.<\/SPAN><SPAN class="punctuation token">.<\/SPAN> <SPAN class="string token">'arcpy.Array(None)'<\/SPAN><SPAN class="punctuation token">,<\/SPAN> <SPAN class="punctuation token">.<\/SPAN><SPAN class="punctuation token">.<\/SPAN><SPAN class="punctuation token">.<\/span> <span class="string token">'arcpy.Point()'<span class="punctuation token">,<span> <span class="punctuation token">.<span class="punctuation token">.<span class="punctuation token">.<span> <span class="string token">'arcpy.Array([])'<span class="punctuation token">,<span> <span class="punctuation token">.<span class="punctuation token">.<span class="punctuation token">.<span> <span class="string token">'arcpy.Array([None])'<span class="punctuation token">,<span> <span class="punctuation token">.<span class="punctuation token">.<span class="punctuation token">.<span> <span class="string token">'arcpy.Array(arcpy.Array())'<span class="punctuation token">,<span> <span class="punctuation token">.<span class="punctuation token">.<span class="punctuation token">.<span> <span class="string token">'arcpy.Array(arcpy.Array(None))'<span class="punctuation token">,<span> <span class="punctuation token">.<span class="punctuation token">.<span class="punctuation token">.<span> <span class="string token">'arcpy.Array(arcpy.Array([]))'<span> <span class="punctuation token">.<span class="punctuation token">.<span class="punctuation token">.<span> <spanclass = " punctuationtoken ">)< span > <spanclass = " punctuationtoken ">. . . </ span > <spanclass = " operatortoken "> > ; > ; </ span > < spanclass = " keywordtoken "> for </ span > i , stmt < spanclass = " keywordtoken "> in </ span > enumerate ( ctor_stmts ) : stmt = "arcpy.Polygon({})".format(stmt) try : print ("{:0>2}. {:<46}: {}".format(i+1, stmt, eval(stmt).WKT)) except Exception as err : print ("{:0>2}. {:<46}: {}....".format(i+1, stmt, err.message[:35])) 01. arcpy.Polygon() : Object: CreateObject kan geen .... 02. arcpy.Polygon(None) : Object: CreateObject kan geen .... 03. arcpy.Polygon(arcpy.Array()) : Object: CreateObject kan geen .... <SPAN class="punctuation token">:<\/SPAN> Object<SPAN class="punctuation token">:<\/SPAN> CreateObject kan geen <SPAN class="punctuation token">.<\/SPAN><SPAN class="punctuation token">.<\/SPAN><SPAN class="punctuation token">.<\/SPAN><SPAN class="punctuation token">.<\/SPAN> <SPAN class="number token">04<\/SPAN><SPAN class="punctuation token">.<\/SPAN> arcpy<SPAN class="punctuation token">.<\/SPAN>Polygon<SPAN class="punctuation token">(<\/SPAN>arcpy<SPAN class="punctuation token">.<\/SPAN>Array<SPAN class="punctuation token">(<\/SPAN>None<SPAN class="punctuation token">)<\/SPAN><SPAN class="punctuation token">)<\/SPAN> <SPAN class="punctuation token">:<\/SPAN> MULTIPOLYGON EMPTY <SPAN class="number token">05<\/SPAN><SPAN class="punctuation token">.<\/SPAN> arcpy<SPAN class="punctuation token">.<\/SPAN>Polygon<SPAN class="punctuation token">(<\/SPAN>arcpy<SPAN class="punctuation token">.<\/SPAN>Point<SPAN class="punctuation token">(<\/SPAN><SPAN class="punctuation token">)<\/SPAN><SPAN class="punctuation token">)<\/SPAN> <SPAN class="punctuation token">:<\/SPAN> MULTIPOLYGON EMPTY <SPAN class="number token">06<\/SPAN><SPAN class="punctuation token">.<\/SPAN> arcpy<SPAN class="punctuation token">.<\/SPAN>Polygon<SPAN class="punctuation token">(<\/SPAN>arcpy<SPAN class="punctuation token">.<\/SPA N>Array<SP ANclass= " punctuationtoken ">( < / SPAN > [ < SPANclass= " punctuationtoken "] < / SPAN > ) < / SPAN > ) < / SPAN > & nbsp ; & nbsp ; & nbsp ; & nbsp ; & nbsp ; & nbsp ; & nbsp ; & nbsp ; & nbsp ; & nbsp ; & nbsp ; & nbsp ; & nbsp ; & nbsp ; < SPANclass= " punctuationtoken "> : < / SPAN > Object < SPANclass= " punctuationtoken "> : < / SPAN > CreateObject kan geen < SPANclass= " punctuationtoken "> . < / SPAN >< SPANclass= " punctuationtoken "> . < / SPAN >< SPANclass= " punctuationtoken "> . < / SPAN >< SPANclass= " punctuationtoken "> . < / SPAN > < SPANclass= " numbertoken " > 07 < / SPAN >< SPANclass= " punctuationtoken " > . < / SPAN > arcpy < SPANclass= " punctuationtoken " > . < / SPAN > Polygon < SPANclass= " punctuationtoken " > ( < / SPAN > arcpy < SPANclass= " punctuationtoken " > . < / SPAN > Array < SPANclass= " punctuationtoken " > ( < / SPAN > None < SPANclass= " punctuationtoken " > ] < / SPAN > ) < / SPAN > ) & nbsp ; & nbsp ; & nbsp ; & nbsp ; & nbsp ; & nbsp ; < SPANclass= " punctuationtoken "> : < / SPAN > MULTIPOLYGON EMPTY < SPANclass= " numbertoken " > 08 < / SPAN >< SPANclass= " punctuationtoken " > . < / SPAN > arcpy < SPANclass= " punctuationtoken " > . < / SPAN > Polygon < SPANclass= " punctuationtoken " > ( < / SPAN > arcpy < SPANclass= " punctuationtoken " > . < / SPAN > Array < SPANclass= " punctuationtoken " > ( < / SPAN > arcpy < SPANclass= " punctuationtoken " > . < / SPAN > Array < SPANclass= " punctuationtoken " > ( < / SPAN > ) < / SPAN > ) < / SPAN > ) & nbsp ; & nbsp ; < SPANclass= " punctuationtoken "> : </SP AN> MULTIPOLYGON EMPTY <SP ANclass ="numbertoken" > 09 </SP AN><SP ANclass ="punctuationtoken">. </SP AN> arcpy<SP ANclass ="punctuationtoken">. </SP AN>Polygon<SP ANclass ="punctuationtoken" >(</SP AN>arcpy<SP ANclass ="punctuationtoken">. </SP AN>Array<SP ANclass ="punctuationtoken" >(</SP AN>arcpy<SP ANclass ="punctuationtoken">. </SP AN>Array<SP ANclass ="punctuationtoken" >(</SP AN>None<SP ANclass ="punctuationtoken" )</SP AN><SP ANclass ="punctuationtoken" )</SP AN><SP ANclass ="punctuationtoken" )</SP AN> : MULTIPOLYGON EMPTY <SP ANclass ="numbertoken" > 10 </SP AN><SP ANclass ="punctuationtoken">. </SP AN> arcpy<SP ANclass ="punctuationtoken">. </SP AN>Polygon<SP ANclass ="punctuationtoken" >(</SP AN>arcpy<SP ANclass ="punctuationtoken">. </SP AN>Array<SP ANclass ="punctuationtoken" >(</SP AN>arcpy<SP ANclass ="punctuationtoken">. </SP AN>Array<SP ANclass ="punctuationtoken" >(</SP AN>[</SP AN><SP ANclass ="punctuationtoken"]</SP AN><SP ANclass ="punctuationtoken")</SP AN><SP ANclass ="punctuationtoken")</SP AN><SP ANclass ="punctuationtoken")</SP AN> : MULTIPOLYGON EMPTY >>> <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></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span> </ span >< span >< << EM OJ I _ 26 >> </ span >< span >< << EM OJ I _ 27 >> </ span >< span >< << EM OJ I _ 28 >> </ span >< span >< << EM OJ I _ 29 >> </ span >< span >< << EM OJ I _ 30 >> </ span >< span >< << EM OJ I _ 31 >> </ span ></ span ></ CODE ></ PRE >< P ></ P >< P > Voordat we gedachten of opmerkingen delen, denk ik dat het belangrijk is om onszelf te herinneren aan wat de<A href="http://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-classes/polygon.htm" rel="nofollow noopener noreferrer" target="_blank">ArcPy Polygon</A>-documentatie precies zegt:< / P >< BLOCKQUOTE class = "jive_macro_quote jive-quote jive_text_macro"><H2 style = "margin: 0.63em 0px 0.63158em; font-family: 'Avenir LT W01 35 Light', Arial, Helvetica, sans-serif; font-style: normal; font-weight: 500; letter-spacing: 0.02em; font-size: 2rem; line-height: 1.2em; -webkit-font-smoothing: antialiased;" id = "toc-hId-1824851459">Syntax</H2 >< DIV class = "" style = "-webkit-font-smoothing: antialiased;"><PRE class = "lia-code-sample line-numbers language-none"> Polygon (inputs, {spatial_reference}, {has_z}, {has_m})</PRE ></ DIV >< DIV class = "" style = "-webkit-font-smoothing: antialiased;"><TABLE style = "width: 767.333px; margin-bottom: 1.5em; font-size: 0.875em; line-height: 1.71429em; font-family: 'Lucida Grande', 'Segoe UI', Arial, sans-serif; background-color: white; border-collapse: collapse; border-spacing: 0px; border: 1px solid #dddddd; text-align: left;">< THEAD style = "background-color: #f4f4f4; border-bottom: 1px solid #dddddd; font-size: 0.9375em; line-height: 1.6em; font-weight: bold;">< TR style = "border-bottom: medium none; text-align: left; height: 39px;">< TD class = "" style = "border-left: 1px solid #dddddd; border-right: 1px solid #dddddd; padding: 12px; height: 39px;">Parameter</TD >< TD class = "" style = "border-left: 1px solid #dddddd; border-right: 1px solid #dddddd; padding: 12px; height: 39px;">Uitleg</TD >< TD class = "" style = "border-left: 1px solid #dddddd; border-right: 1px solid #dddddd; padding: 12px; height: 39px;">Datatype</TD ></ TR ></ THEAD >< TBODY >< TR style = "border-bottom: 1px solid #dddddd; text-align: left; height: 49px;">< TD style = "border-left: 1px solid #dddddd; border-right: 1px solid #dddddd; padding: 12px; height: 49px;">< DIV class = '' style='-webkit-font-smoothing: antialiased;'>inputs</DIV ></ TD >< TD style='border-left:1px solid #dddddd;border-right:1px solid #dddddd;padding:12px;height:49px;'> <P style='font-size:0.875rem;line-height:1.71429em;margin-top:0em;margin-bottom:0px;-webkit-font-smoothing:antialiased;'>De coördinaten die worden gebruikt om het object te maken. Het datatype kan ofwel een<span style='-webkit-font-smoothing:antialiased;font-family:"Consolas",'Andale Mono','Lucida Console',Monaco,'Courier New',Courier,monospace;font-weight:bold;'>Point</span> </P> <P style='font-size:0.875rem;line-height:1.71429em;margin-top:0em;margin-bottom:0px;-webkit-font-smoothing:antialiased;'>of een<span style='-webkit-font-smoothing:antialiased;font-family:"Consolas",'Andale Mono','Lucida Console',Monaco,'Courier New',Courier,monospace;font-weight:bold;'>Array</span>-objecten zijn. </P> </TD> <TD style='border-left:1px solid #dddddd;border-right:1px solid #dddddd;padding:12px;height:49px;'>Object </TD> </TR> </TBODY> </TABLE> </DIV> </BLOCKQUOTE> <P> </P> <P>Kleine observaties voor opmerkingen: </P> <ul> <li>Voorbeelden 01 en 02: <br /> <ul> <li>De documentatie stelt dat de inputs Point of Array-objecten moeten zijn, wat geen van deze voorbeelden levert. </li> </ul> </li> <li>Voorbeelden 03 en 06: <ul> <li>D eze twee voorbeelden zijn hetzelfde, bijvoorbeeld<span style='font-family:courier new,courier,monospace;'>repr(arcpy.Array()) == repr(arcpy.Array([]))</span>. <i>Aangezien Esri geen gelijkwaardigheid implementeert met ArcPy Arrays, gebruikte ik de objecten hun<span style='font-family:courier new,courier,monospace;'>__repr__</span>-methode om gelijkheid in dit geval aan te tonen.</i> </li> <li>Aanroepen van<span style='font-family:courier new,courier,monospace;'>arcpy.Array()</span>-maakt een lege ArcPy Array aan: <span style='font-family:courier new,courier,monospace;'><Array []><\/SPAN>. Lege ArcPy Arrays zijn geldige objecten, en de documentatie vermeldt dat ArcPy Array-objecten kunnen worden doorgegeven aan de ArcPy Polygon constructor.<EM><BR \/><\/EM><\/LI><\/UL><\/LI><LI>Voorbeelden 04 & 07:<UL><LI>Vergelijkbaar met Voorbeelden 03 & 06, zijn deze twee voorbeelden hetzelfde, bijvoorbeeld <SPAN style="font-family: courier new,courier,monospace;">repr(arcpy.Array(None)) == repr(arcpy.Array([None])).<\/SPAN><\/LI><LI>Voorbeeld 04 was de voorgestelde methode door <A href="https:\/\/community.esri.com\/migrated-users\/2582" target="_blank">David Wynne<\/A> in <A href="https:\/\/community.esri.com\/ideas\/10648?sr=search&searchId=d16b084d-001d-4dad-b5a6-7e4ae13606e0&searchIndex=4" target="_blank">Support Empty Geometries with ArcPy Geometry Class Constructors<\/A>.<\/LI><\/UL><\/LI><LI>Voorbeeld 05:<UL><LI>De documentatie vermeldt dat een Point-object als invoer kan worden gebruikt.<\/LI><LI>Het aanroepen van <SPAN style="font-family: courier new,courier,monospace;">arcpy.Point()<\/SPAN> creëert geen leeg punt, zoals het aanroepen van <SPAN style="font-family: courier new,courier,monospace;">arcpy.Array()<\/SPAN>, in plaats daarvan maakt het een punt 0, 0:<SPAN style="font-family: courier new,courier,monospace;"> <Point (0.0, 0.0, #, #)><\/SPAN>. Hoewel niet hierboven aangetoond, toont verder testen dat elk punt werkt, bijvoorbeeld <SPAN style="font-family: courier new,courier,monospace;">arcpy.Polygon(arcpy.Point(10000.5, -4500.3))<\/SPAN> maakt ook een lege multi-polygon.<\/LI><\/UL><\/LI><LI>Voorbeelden 08 & 10:<UL><LI>Vergelijkbaar met Voorbeelden 03 & 06 en Voorbeelden 04 & 07, zijn deze twee voorbeelden hetzelfde.<\/LI><LI>Het aanroepen van <SPAN style="font-family: courier new,courier,monospace;">arcpy.Array(arcpy.Array())<\/SPAN> creëert een lege ArcPy Array genest binnen een ArcPy Array. De <A href="http:\/\/desktop.arcgis.com\/en\/arcmap\/latest\/analyze\/arcpy-classes\/array.htm" rel="nofollow noopener noreferrer" target="_blank">ArcPy Array<\/A> documentatie vermeldt dat een ArcPy Array een geldige invoer is voor de ArcPy Array constructor.<\/LI><\/UL><\/LI><\/UL><P><\/P><P>Er zijn verschillende eigenaardigheden met de resultaten van de polygon constructor test hierboven. Ik denk dat Voorbeelden 03 & 06 waarschijnlijk het meest gebruikers zullen verwarren. De documentatie stelt duidelijk dat ArcPy Array-objecten geldige invoeren zijn, en lege ArcPy Arrays zijn geldige objecten, dus waarom genereert het doorgeven van een lege ArcPy Array aan de ArcPy Polygon constructor een fout? Hoewel Voorbeelden 04 & 07 werken, lijkt het vreemd dat een ArcPy Array die een Python <SPAN style="font-family: courier new,courier,monospace;">None<\/SPAN> bevat op de een of andere manier wezenlijk anders is dan een lege ArcPy Array bij het bouwen van een lege geometrie.<\/P><P><\/P><P>Voorbeeld 05 is een verrassing en maakt voor mij het minste zin. De documentatie stelt duidelijk dat een Point-object een geldige invoer is voor de ArcPy Polygon constructor, maar hoe ziet een polygon met één punt eruit? Een lege multi-polygon, volgens Esri. Wat de vreemdheid voor mij nog verhoogt is dat er geen lege ArcPy Point is, en dat elk ArcPy Point dat wordt doorgegeven aan de ArcPy Polygon constructor een lege geometrie creëert.<\/P><P><\/P><P style="padding-left: 30px;"><EM>Door gebruik te maken van <A class="link-titled" href="https:\/\/docs.python.org\/2\/library\/dis.html" title="https:\/\/docs.python.org\/2\/library\/dis.html" rel="nofollow noopener noreferrer" target="_blank">dis 12 Disassembler for Python bytecode<\/A> om naar de bytecode te kijken voor elk van de constructor statements hierboven, leek Voorbeeld 05 de snelste constructor statement te zijn. Het uitvoeren van <A class="link-titled" href="https:\/\/docs.python.org\/2\/library\/timeit.html" title="https:\/\/docs.python.org\/2\/library\/timeit.html" rel="nofollow noopener noreferrer" target="_blank">timeit 12 Meet uitvoeringstijd van kleine codefragmenten<\/A> op de constructor statements toonde aan dat Voorbeeld 05 het snelst was in het genereren van lege geometrieën, niet veel sneller, maar toch het snelst. Dit voegt alleen maar toe aan het mysterie van de single-point polygon.<\/EM><\/P><P><\/P><P>Voorbeelden 08 & 10 zullen in een volgende blogpost worden behandeld, dus ik zal mijn gedachten daarover hier niet verder uitdiepen.<\/P><P><\/P><P>Hoe passen de resultaten van deze test in het idee/verzoek/smeekbede voor meer <A href="https:\/\/community.esri.com\/ideas\/10963?sr=search&searchId=97894fbc-b12d-4fd3-85e6-92946ebbb702&searchIndex=2" target="_blank">Pythonic ArcPy Geometries<\/A>? Voor mij is het antwoord dat Voorbeeld 01 de primaire manier zou moeten zijn om lege ArcPy geometrieën te maken, d.w.z. geen argumenten doorgeven aan een ArcPy Geometry constructor zou het equivalente lege geometrie-type moeten genereren. Voor objecten die het concept van leegte ondersteunen is het vrij gebruikelijk in Python om geen argumenten door te geven aan de constructor om zo een leeg object te creëren. Laten we eens naar enkele voorbeelden kijken:<\/P><PRE class="lia-code-sample line-numbers language-none"><CODE><SPAN class="operator token">>><\/><SPAN class="operator token">><\/> <SPAN class="comment token"># Veelvoorkomende ingebouwde datastructuren<\/>\n<SPAN class="operator token">>><\/><SPAN class="operator token">><\/> list<SPAN class="punctuation token">(<\/><SPAN class="punctuation token">)<\/>\n<SPAN class="punctuation token">[<\/><SPAN class="punctuation token">]<\/>\n<SPAN class="operator token">>><\/><SPAN class="operator token">><\/> set<SPAN class="punctuation token">(<\/><SPAN class="punctuation token">)<\/>\nset<SPAN class="punctuation token">(<\/><SPAN class="punctuation token">[<\/><SPAN class="punctuation token">]<\/><SPAN class="punctuation token">)<\/>\n<SPAN class="operator token">>><\/><SPAN class="operator token">><\/> dict<SPAN class="punctuation token">(<\/><SPAN class="punctuation token">)<\/>\n<SPAN class="punctuation token">{<\/><SPAN class="punctuation token">}<\/>\n<SPAN class="operator token">>><\/><SPAN class="operator token">><\/> str<SPAN class="punctuation token">(<\/><SPAN class="punctuation token">)<\/>\n<SPAN class="string token">''<\/>\n<SPAN class="operator token">>><\/><SPAN class="operator token">><\/> \n<SPAN class="operator token">>><\/><SPAN class="operator token">><\/> <SPAN class="comment token"># Sommige SciPy datastructuren nu gebundeld met ArcGIS<\/>\n<SPAN class="operator token">>><\/><SPAN class="operator token">><\/> <SPAN class="keyword token">import<\/> pandas\n<SPAN class="operator token">>><\/><SPAN class="operator token">><\/> pandas<SPAN class="punctuation token">.<\/>DataFrame<SPAN class="punctuation token">(<\/><SPAN class="punctuation token">)<\/>\nLeeg DataFrame\nKolommen<span>: [ ]</span> \nIndex<span>: [ ]</span> \n<SPAnclass=opertor-token>>></SPAnclass=opertor-token>> matplotlib.pylab matplotlib.pylab.plot() [] <spanclass=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</span><span</span><span</span><span</span><span</span><span</span><span </SPAnclass=opertor-token>> Wat is meer Pythonic voor het maken van een lege geometrie, arcpy.Polygon(arcpy.Array(None)) of arcpy.Polygon()?
<\/P>
In de loop der jaren heb ik de ArcPy Geometry constructors als eigenaardig ervaren, vooral bij rand- of nichegevallen zoals lege geometrieën. Als een betrokken gebruiker, die gelooft dat het geven van feedback aan ontwikkelaars belangrijk is, heb ik in de loop van de tijd verschillende bugs en verbeteringsverzoeken ingediend met betrekking tot geometry constructors. Direct gezegd, ik kan niet zeggen hoeveel er zijn geïmplementeerd, mogelijk slechts één, maar dat stond niet hoog op mijn wensenlijst.<\/P>
Een paar jaar geleden diende ik het
<SPAN class="operator token">>><\/SPAN><SPAN class="operator token">><\/SPAN> ctor_stmts <SPAN class="operator token">=<\/SPAN> <SPAN class="punctuation token">(<\/SPAN> <SPAN class="punctuation token">.<\/SPAN><SPAN class="punctuation token">.<\/SPAN><SPAN class="punctuation token">.<\/SPAN> <SPAN class="string token">''<\/SPAN><SPAN class="punctuation token">,<\/SPAN> <SPAN class="punctuation token">.<\/SPAN><SPAN class="punctuation token">.<\/SPAN><SPAN class="punctuation token">.<\/SPAN> <SPAN class="string token">'None'<\/SPAN><SPAN class="punctuation token">,<\/SPAN> <SPAN class="punctuation token">.<\/SPAN><SPAN class="punctuation token">.<\/SPAN><SPAN class="punctuation token">.<\/SPAN> <SPAN class="string token">'arcpy.Array()'<\/SPAN><SPAN class="punctuation token">,<\/SPAN> <SPAN class="punctuation token">.<\/SPAN><SPAN class="punctuation token">.<\/SPAN><SPAN class="punctuation token">.<\/SPAN> <SPAN class="string token">'arcpy.Array(None)'<\/SPAN><SPAN class="punctuation token">,<\/SPAN> <SPAN class="punctuation token">.<\/SPAN><SPAN class="punctuation token">.<\/SPAN><SPAN class="punctuation token">.<\/span> <span class="string token">'arcpy.Point()'<span class="punctuation token">,<span> <span class="punctuation token">.<span class="punctuation token">.<span class="punctuation token">.<span> <span class="string token">'arcpy.Array([])'<span class="punctuation token">,<span> <span class="punctuation token">.<span class="punctuation token">.<span class="punctuation token">.<span> <span class="string token">'arcpy.Array([None])'<span class="punctuation token">,<span> <span class="punctuation token">.<span class="punctuation token">.<span class="punctuation token">.<span> <span class="string token">'arcpy.Array(arcpy.Array())'<span class="punctuation token">,<span> <span class="punctuation token">.<span class="punctuation token">.<span class="punctuation token">.<span> <span class="string token">'arcpy.Array(arcpy.Array(None))'<span class="punctuation token">,<span> <span class="punctuation token">.<span class="punctuation token">.<span class="punctuation token">.<span> <span class="string token">'arcpy.Array(arcpy.Array([]))'<span> <span class="punctuation token">.<span class="punctuation token">.<span class="punctuation token">.<span> <spanclass = " punctuationtoken ">)< span > <spanclass = " punctuationtoken ">. . . </ span > <spanclass = " operatortoken "> > ; > ; </ span > < spanclass = " keywordtoken "> for </ span > i , stmt < spanclass = " keywordtoken "> in </ span > enumerate ( ctor_stmts ) : stmt = "arcpy.Polygon({})".format(stmt) try : print ("{:0>2}. {:<46}: {}".format(i+1, stmt, eval(stmt).WKT)) except Exception as err : print ("{:0>2}. {:<46}: {}....".format(i+1, stmt, err.message[:35])) 01. arcpy.Polygon() : Object: CreateObject kan geen .... 02. arcpy.Polygon(None) : Object: CreateObject kan geen .... 03. arcpy.Polygon(arcpy.Array()) : Object: CreateObject kan geen .... <SPAN class="punctuation token">:<\/SPAN> Object<SPAN class="punctuation token">:<\/SPAN> CreateObject kan geen <SPAN class="punctuation token">.<\/SPAN><SPAN class="punctuation token">.<\/SPAN><SPAN class="punctuation token">.<\/SPAN><SPAN class="punctuation token">.<\/SPAN> <SPAN class="number token">04<\/SPAN><SPAN class="punctuation token">.<\/SPAN> arcpy<SPAN class="punctuation token">.<\/SPAN>Polygon<SPAN class="punctuation token">(<\/SPAN>arcpy<SPAN class="punctuation token">.<\/SPAN>Array<SPAN class="punctuation token">(<\/SPAN>None<SPAN class="punctuation token">)<\/SPAN><SPAN class="punctuation token">)<\/SPAN> <SPAN class="punctuation token">:<\/SPAN> MULTIPOLYGON EMPTY <SPAN class="number token">05<\/SPAN><SPAN class="punctuation token">.<\/SPAN> arcpy<SPAN class="punctuation token">.<\/SPAN>Polygon<SPAN class="punctuation token">(<\/SPAN>arcpy<SPAN class="punctuation token">.<\/SPAN>Point<SPAN class="punctuation token">(<\/SPAN><SPAN class="punctuation token">)<\/SPAN><SPAN class="punctuation token">)<\/SPAN> <SPAN class="punctuation token">:<\/SPAN> MULTIPOLYGON EMPTY <SPAN class="number token">06<\/SPAN><SPAN class="punctuation token">.<\/SPAN> arcpy<SPAN class="punctuation token">.<\/SPAN>Polygon<SPAN class="punctuation token">(<\/SPAN>arcpy<SPAN class="punctuation token">.<\/SPA N>Array<SP ANclass= " punctuationtoken ">( < / SPAN > [ < SPANclass= " punctuationtoken "] < / SPAN > ) < / SPAN > ) < / SPAN > & nbsp ; & nbsp ; & nbsp ; & nbsp ; & nbsp ; & nbsp ; & nbsp ; & nbsp ; & nbsp ; & nbsp ; & nbsp ; & nbsp ; & nbsp ; & nbsp ; < SPANclass= " punctuationtoken "> : < / SPAN > Object < SPANclass= " punctuationtoken "> : < / SPAN > CreateObject kan geen < SPANclass= " punctuationtoken "> . < / SPAN >< SPANclass= " punctuationtoken "> . < / SPAN >< SPANclass= " punctuationtoken "> . < / SPAN >< SPANclass= " punctuationtoken "> . < / SPAN > < SPANclass= " numbertoken " > 07 < / SPAN >< SPANclass= " punctuationtoken " > . < / SPAN > arcpy < SPANclass= " punctuationtoken " > . < / SPAN > Polygon < SPANclass= " punctuationtoken " > ( < / SPAN > arcpy < SPANclass= " punctuationtoken " > . < / SPAN > Array < SPANclass= " punctuationtoken " > ( < / SPAN > None < SPANclass= " punctuationtoken " > ] < / SPAN > ) < / SPAN > ) & nbsp ; & nbsp ; & nbsp ; & nbsp ; & nbsp ; & nbsp ; < SPANclass= " punctuationtoken "> : < / SPAN > MULTIPOLYGON EMPTY < SPANclass= " numbertoken " > 08 < / SPAN >< SPANclass= " punctuationtoken " > . < / SPAN > arcpy < SPANclass= " punctuationtoken " > . < / SPAN > Polygon < SPANclass= " punctuationtoken " > ( < / SPAN > arcpy < SPANclass= " punctuationtoken " > . < / SPAN > Array < SPANclass= " punctuationtoken " > ( < / SPAN > arcpy < SPANclass= " punctuationtoken " > . < / SPAN > Array < SPANclass= " punctuationtoken " > ( < / SPAN > ) < / SPAN > ) < / SPAN > ) & nbsp ; & nbsp ; < SPANclass= " punctuationtoken "> : </SP AN> MULTIPOLYGON EMPTY <SP ANclass ="numbertoken" > 09 </SP AN><SP ANclass ="punctuationtoken">. </SP AN> arcpy<SP ANclass ="punctuationtoken">. </SP AN>Polygon<SP ANclass ="punctuationtoken" >(</SP AN>arcpy<SP ANclass ="punctuationtoken">. </SP AN>Array<SP ANclass ="punctuationtoken" >(</SP AN>arcpy<SP ANclass ="punctuationtoken">. </SP AN>Array<SP ANclass ="punctuationtoken" >(</SP AN>None<SP ANclass ="punctuationtoken" )</SP AN><SP ANclass ="punctuationtoken" )</SP AN><SP ANclass ="punctuationtoken" )</SP AN> : MULTIPOLYGON EMPTY <SP ANclass ="numbertoken" > 10 </SP AN><SP ANclass ="punctuationtoken">. </SP AN> arcpy<SP ANclass ="punctuationtoken">. </SP AN>Polygon<SP ANclass ="punctuationtoken" >(</SP AN>arcpy<SP ANclass ="punctuationtoken">. </SP AN>Array<SP ANclass ="punctuationtoken" >(</SP AN>arcpy<SP ANclass ="punctuationtoken">. </SP AN>Array<SP ANclass ="punctuationtoken" >(</SP AN>[</SP AN><SP ANclass ="punctuationtoken"]</SP AN><SP ANclass ="punctuationtoken")</SP AN><SP ANclass ="punctuationtoken")</SP AN><SP ANclass ="punctuationtoken")</SP AN> : MULTIPOLYGON EMPTY >>> <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></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span> </ span >< span >< << EM OJ I _ 26 >> </ span >< span >< << EM OJ I _ 27 >> </ span >< span >< << EM OJ I _ 28 >> </ span >< span >< << EM OJ I _ 29 >> </ span >< span >< << EM OJ I _ 30 >> </ span >< span >< << EM OJ I _ 31 >> </ span ></ span ></ CODE ></ PRE >< P ></ P >< P > Voordat we gedachten of opmerkingen delen, denk ik dat het belangrijk is om onszelf te herinneren aan wat de<A href="http://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-classes/polygon.htm" rel="nofollow noopener noreferrer" target="_blank">ArcPy Polygon</A>-documentatie precies zegt:< / P >< BLOCKQUOTE class = "jive_macro_quote jive-quote jive_text_macro"><H2 style = "margin: 0.63em 0px 0.63158em; font-family: 'Avenir LT W01 35 Light', Arial, Helvetica, sans-serif; font-style: normal; font-weight: 500; letter-spacing: 0.02em; font-size: 2rem; line-height: 1.2em; -webkit-font-smoothing: antialiased;" id = "toc-hId-1824851459">Syntax</H2 >< DIV class = "" style = "-webkit-font-smoothing: antialiased;"><PRE class = "lia-code-sample line-numbers language-none"> Polygon (inputs, {spatial_reference}, {has_z}, {has_m})</PRE ></ DIV >< DIV class = "" style = "-webkit-font-smoothing: antialiased;"><TABLE style = "width: 767.333px; margin-bottom: 1.5em; font-size: 0.875em; line-height: 1.71429em; font-family: 'Lucida Grande', 'Segoe UI', Arial, sans-serif; background-color: white; border-collapse: collapse; border-spacing: 0px; border: 1px solid #dddddd; text-align: left;">< THEAD style = "background-color: #f4f4f4; border-bottom: 1px solid #dddddd; font-size: 0.9375em; line-height: 1.6em; font-weight: bold;">< TR style = "border-bottom: medium none; text-align: left; height: 39px;">< TD class = "" style = "border-left: 1px solid #dddddd; border-right: 1px solid #dddddd; padding: 12px; height: 39px;">Parameter</TD >< TD class = "" style = "border-left: 1px solid #dddddd; border-right: 1px solid #dddddd; padding: 12px; height: 39px;">Uitleg</TD >< TD class = "" style = "border-left: 1px solid #dddddd; border-right: 1px solid #dddddd; padding: 12px; height: 39px;">Datatype</TD ></ TR ></ THEAD >< TBODY >< TR style = "border-bottom: 1px solid #dddddd; text-align: left; height: 49px;">< TD style = "border-left: 1px solid #dddddd; border-right: 1px solid #dddddd; padding: 12px; height: 49px;">< DIV class = '' style='-webkit-font-smoothing: antialiased;'>inputs</DIV ></ TD >< TD style='border-left:1px solid #dddddd;border-right:1px solid #dddddd;padding:12px;height:49px;'> <P style='font-size:0.875rem;line-height:1.71429em;margin-top:0em;margin-bottom:0px;-webkit-font-smoothing:antialiased;'>De coördinaten die worden gebruikt om het object te maken. Het datatype kan ofwel een<span style='-webkit-font-smoothing:antialiased;font-family:"Consolas",'Andale Mono','Lucida Console',Monaco,'Courier New',Courier,monospace;font-weight:bold;'>Point</span> </P> <P style='font-size:0.875rem;line-height:1.71429em;margin-top:0em;margin-bottom:0px;-webkit-font-smoothing:antialiased;'>of een<span style='-webkit-font-smoothing:antialiased;font-family:"Consolas",'Andale Mono','Lucida Console',Monaco,'Courier New',Courier,monospace;font-weight:bold;'>Array</span>-objecten zijn. </P> </TD> <TD style='border-left:1px solid #dddddd;border-right:1px solid #dddddd;padding:12px;height:49px;'>Object </TD> </TR> </TBODY> </TABLE> </DIV> </BLOCKQUOTE> <P> </P> <P>Kleine observaties voor opmerkingen: </P> <ul> <li>Voorbeelden 01 en 02: <br /> <ul> <li>De documentatie stelt dat de inputs Point of Array-objecten moeten zijn, wat geen van deze voorbeelden levert. </li> </ul> </li> <li>Voorbeelden 03 en 06: <ul> <li>D eze twee voorbeelden zijn hetzelfde, bijvoorbeeld<span style='font-family:courier new,courier,monospace;'>repr(arcpy.Array()) == repr(arcpy.Array([]))</span>. <i>Aangezien Esri geen gelijkwaardigheid implementeert met ArcPy Arrays, gebruikte ik de objecten hun<span style='font-family:courier new,courier,monospace;'>__repr__</span>-methode om gelijkheid in dit geval aan te tonen.</i> </li> <li>Aanroepen van<span style='font-family:courier new,courier,monospace;'>arcpy.Array()</span>-maakt een lege ArcPy Array aan: <span style='font-family:courier new,courier,monospace;'><Array []><\/SPAN>. Lege ArcPy Arrays zijn geldige objecten, en de documentatie vermeldt dat ArcPy Array-objecten kunnen worden doorgegeven aan de ArcPy Polygon constructor.<EM><BR \/><\/EM><\/LI><\/UL><\/LI><LI>Voorbeelden 04 & 07:<UL><LI>Vergelijkbaar met Voorbeelden 03 & 06, zijn deze twee voorbeelden hetzelfde, bijvoorbeeld <SPAN style="font-family: courier new,courier,monospace;">repr(arcpy.Array(None)) == repr(arcpy.Array([None])).<\/SPAN><\/LI><LI>Voorbeeld 04 was de voorgestelde methode door <A href="https:\/\/community.esri.com\/migrated-users\/2582" target="_blank">David Wynne<\/A> in <A href="https:\/\/community.esri.com\/ideas\/10648?sr=search&searchId=d16b084d-001d-4dad-b5a6-7e4ae13606e0&searchIndex=4" target="_blank">Support Empty Geometries with ArcPy Geometry Class Constructors<\/A>.<\/LI><\/UL><\/LI><LI>Voorbeeld 05:<UL><LI>De documentatie vermeldt dat een Point-object als invoer kan worden gebruikt.<\/LI><LI>Het aanroepen van <SPAN style="font-family: courier new,courier,monospace;">arcpy.Point()<\/SPAN> creëert geen leeg punt, zoals het aanroepen van <SPAN style="font-family: courier new,courier,monospace;">arcpy.Array()<\/SPAN>, in plaats daarvan maakt het een punt 0, 0:<SPAN style="font-family: courier new,courier,monospace;"> <Point (0.0, 0.0, #, #)><\/SPAN>. Hoewel niet hierboven aangetoond, toont verder testen dat elk punt werkt, bijvoorbeeld <SPAN style="font-family: courier new,courier,monospace;">arcpy.Polygon(arcpy.Point(10000.5, -4500.3))<\/SPAN> maakt ook een lege multi-polygon.<\/LI><\/UL><\/LI><LI>Voorbeelden 08 & 10:<UL><LI>Vergelijkbaar met Voorbeelden 03 & 06 en Voorbeelden 04 & 07, zijn deze twee voorbeelden hetzelfde.<\/LI><LI>Het aanroepen van <SPAN style="font-family: courier new,courier,monospace;">arcpy.Array(arcpy.Array())<\/SPAN> creëert een lege ArcPy Array genest binnen een ArcPy Array. De <A href="http:\/\/desktop.arcgis.com\/en\/arcmap\/latest\/analyze\/arcpy-classes\/array.htm" rel="nofollow noopener noreferrer" target="_blank">ArcPy Array<\/A> documentatie vermeldt dat een ArcPy Array een geldige invoer is voor de ArcPy Array constructor.<\/LI><\/UL><\/LI><\/UL><P><\/P><P>Er zijn verschillende eigenaardigheden met de resultaten van de polygon constructor test hierboven. Ik denk dat Voorbeelden 03 & 06 waarschijnlijk het meest gebruikers zullen verwarren. De documentatie stelt duidelijk dat ArcPy Array-objecten geldige invoeren zijn, en lege ArcPy Arrays zijn geldige objecten, dus waarom genereert het doorgeven van een lege ArcPy Array aan de ArcPy Polygon constructor een fout? Hoewel Voorbeelden 04 & 07 werken, lijkt het vreemd dat een ArcPy Array die een Python <SPAN style="font-family: courier new,courier,monospace;">None<\/SPAN> bevat op de een of andere manier wezenlijk anders is dan een lege ArcPy Array bij het bouwen van een lege geometrie.<\/P><P><\/P><P>Voorbeeld 05 is een verrassing en maakt voor mij het minste zin. De documentatie stelt duidelijk dat een Point-object een geldige invoer is voor de ArcPy Polygon constructor, maar hoe ziet een polygon met één punt eruit? Een lege multi-polygon, volgens Esri. Wat de vreemdheid voor mij nog verhoogt is dat er geen lege ArcPy Point is, en dat elk ArcPy Point dat wordt doorgegeven aan de ArcPy Polygon constructor een lege geometrie creëert.<\/P><P><\/P><P style="padding-left: 30px;"><EM>Door gebruik te maken van <A class="link-titled" href="https:\/\/docs.python.org\/2\/library\/dis.html" title="https:\/\/docs.python.org\/2\/library\/dis.html" rel="nofollow noopener noreferrer" target="_blank">dis 12 Disassembler for Python bytecode<\/A> om naar de bytecode te kijken voor elk van de constructor statements hierboven, leek Voorbeeld 05 de snelste constructor statement te zijn. Het uitvoeren van <A class="link-titled" href="https:\/\/docs.python.org\/2\/library\/timeit.html" title="https:\/\/docs.python.org\/2\/library\/timeit.html" rel="nofollow noopener noreferrer" target="_blank">timeit 12 Meet uitvoeringstijd van kleine codefragmenten<\/A> op de constructor statements toonde aan dat Voorbeeld 05 het snelst was in het genereren van lege geometrieën, niet veel sneller, maar toch het snelst. Dit voegt alleen maar toe aan het mysterie van de single-point polygon.<\/EM><\/P><P><\/P><P>Voorbeelden 08 & 10 zullen in een volgende blogpost worden behandeld, dus ik zal mijn gedachten daarover hier niet verder uitdiepen.<\/P><P><\/P><P>Hoe passen de resultaten van deze test in het idee/verzoek/smeekbede voor meer <A href="https:\/\/community.esri.com\/ideas\/10963?sr=search&searchId=97894fbc-b12d-4fd3-85e6-92946ebbb702&searchIndex=2" target="_blank">Pythonic ArcPy Geometries<\/A>? Voor mij is het antwoord dat Voorbeeld 01 de primaire manier zou moeten zijn om lege ArcPy geometrieën te maken, d.w.z. geen argumenten doorgeven aan een ArcPy Geometry constructor zou het equivalente lege geometrie-type moeten genereren. Voor objecten die het concept van leegte ondersteunen is het vrij gebruikelijk in Python om geen argumenten door te geven aan de constructor om zo een leeg object te creëren. Laten we eens naar enkele voorbeelden kijken:<\/P><PRE class="lia-code-sample line-numbers language-none"><CODE><SPAN class="operator token">>><\/><SPAN class="operator token">><\/> <SPAN class="comment token"># Veelvoorkomende ingebouwde datastructuren<\/>\n<SPAN class="operator token">>><\/><SPAN class="operator token">><\/> list<SPAN class="punctuation token">(<\/><SPAN class="punctuation token">)<\/>\n<SPAN class="punctuation token">[<\/><SPAN class="punctuation token">]<\/>\n<SPAN class="operator token">>><\/><SPAN class="operator token">><\/> set<SPAN class="punctuation token">(<\/><SPAN class="punctuation token">)<\/>\nset<SPAN class="punctuation token">(<\/><SPAN class="punctuation token">[<\/><SPAN class="punctuation token">]<\/><SPAN class="punctuation token">)<\/>\n<SPAN class="operator token">>><\/><SPAN class="operator token">><\/> dict<SPAN class="punctuation token">(<\/><SPAN class="punctuation token">)<\/>\n<SPAN class="punctuation token">{<\/><SPAN class="punctuation token">}<\/>\n<SPAN class="operator token">>><\/><SPAN class="operator token">><\/> str<SPAN class="punctuation token">(<\/><SPAN class="punctuation token">)<\/>\n<SPAN class="string token">''<\/>\n<SPAN class="operator token">>><\/><SPAN class="operator token">><\/> \n<SPAN class="operator token">>><\/><SPAN class="operator token">><\/> <SPAN class="comment token"># Sommige SciPy datastructuren nu gebundeld met ArcGIS<\/>\n<SPAN class="operator token">>><\/><SPAN class="operator token">><\/> <SPAN class="keyword token">import<\/> pandas\n<SPAN class="operator token">>><\/><SPAN class="operator token">><\/> pandas<SPAN class="punctuation token">.<\/>DataFrame<SPAN class="punctuation token">(<\/><SPAN class="punctuation token">)<\/>\nLeeg DataFrame\nKolommen<span>: [ ]</span> \nIndex<span>: [ ]</span> \n<SPAnclass=opertor-token>>></SPAnclass=opertor-token>> matplotlib.pylab matplotlib.pylab.plot() [] <spanclass=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</span><span</span><span</span><span</span><span</span><span</span><span </SPAnclass=opertor-token>>
BEOORDELING 06/2018:
Omwille van volledigheid wil ik ook de resultaten opnemen van het uitvoeren van de constructortests op de andere ArcPy Geometry klassen:
>>0geometry_classes = ["point", "multipoint", "polyline"]>>0ctor_stmts = ('','None','arcpy.Array()','arcpy.Array(None)','arcpy.Point()','arcpy.Array([])','arcpy.Array([None])','arcpy.Array(arcpy.Array())' class="punctuation token">, 'arcpy.Array(arcpy.Array(None))', 'arcpy.Array(arcpy.Array([]))')>>> voor geometry in geometry_classes:... voor i, stmt in enumerate(ctor_stmts):... stmt = "arcpy.Geometry('{}',{})".format(geometry, stmt)... probeer:... print("{:0>2}. {:<60}: {}".format(i+1, stmt, eval(stmt).WKT))... behalve Exception als err:... print(.<\/SPAN>Array(<\/SPAN>)<\/SPAN>)<\/SPAN>)<\/SPAN> :<\/SPAN> Object:<\/SPAN> CreateObject.<\/SPAN>.<\/SPAN>.<\/SPAN>.<\/SPAN>09<\/SPAN>.<\/SPAN> arcpy.<\/SPAN>Geometry(<\/SPAN>'point'<\/SPAN>,<\/SPAN>arcpy.<\/SPAN>Array(<\/SPAN>arcpy.<\/SPAN>Array(<\/SPAN>None)<\/SPAN>)<\/SPAN>)<\/SPAN> :<\/SPAN> Object:<\/SPAN> CreateObject.<\/Span>.<\/span>.<\/span>.<\/span>10<\/span>.<\/span> arcpy.<\/span>Geometry(<\/span>'point'<\/span>,<\/span>arcpy.<\/span>Array(<\/span>arcpy.<\/span>Array(<\/span>[<\/span>]<\/span>)<\/span>)<\/span>)<\/span> :<\/span> Object:<\/span> CreateObject.<\/span>.<\/span>.<\/span>.<\/span>01<\/span>.<\/span> arcpy.<\/span>Geometry(<\/span>'multipoint'<\/span>,<\/span>)<\/span> :<\/span> Object:<\/span> CreateObject.<\/span>.<\/span>.<\/span>.<\/span>02<\/span>.<\/span> arcpy.<\/span>Geometry(<\/span>'multipoint'<\/span>,<\/span>None)<\/span> :<\/span> Object:<\/span> CreateObject<.\/<\ span > . <\ / span > . <\ / span > . <\ / span >03</ span >< span_class= " punctuation_token" >.</ span > arcpy < span_class= " punctuation_token" >.</ span > Geometry < span_class= " punctuation_token" >(</ span >< span_class= " string_token" >'multipoint'</ span >< span_class= " punctuation_token" >,</ span > arcpy < span_class= " punctuation_token" >.</ span > Array < span_class= " punctuation_token" >(</ span >< span_class= " punctuation_token" >)</ span >< span_class= " punctuation_token" >)</ span >& nbsp ; & nbsp ; & nbsp ; & nbsp ; & nbsp ; & nbsp ; & nbsp ; & nbsp ; & nbsp ; & nbsp ; & nbsp ; & nbsp ; & nbsp ; & nbsp ; & nbsp ; & nbsp ; & nbsp ; & nbsp ; & nbsp ; & nbsp ; & nbsp ; & nbsp ; & nbsp ; : Object : CreateObject . . . .04</ span >< span_class= " punctuation_token" >.</ span > arcpy < span_class= " punctuation_token" >.</ span > Geometry < span_class= " punctuation_token" >(</ span >< span_class= " string_token" >'multipoint'</ span >< span_class= " punctuation_token" >,</ span > arcpy < span_class= " punctuation_token" >.</ span > Array < span_class= " punctuation_token" >(</ span > None < span_class= " punctuation_token" )</ span >< span_class= " punctuation_token" )</ span >& nbsp ; & nbsp ; & nbsp ; & nbsp ; & nbsp ; & nbsp ; & nbsp ; & nbsp ; & nbsp ; : MULTIPOINT EMPTY05</ span >< span_class= " punctuation_token" >.</ span > arcpy < span_class= " punctuation_token" >.</ span > Geometry < span_class= " punctuation_token" >(</ span >< span_class= " string_token" >'multipoint'</ span >< span_class= " punctuation_token" >,</ span > arcpy < span_class= " punctuation_token" >.</ span > Point < span_class= " punctuation_token" >(</ span >< span_class= " punctuation_token" )</ span >< span_class= " punctuation_token" )</ span >& nbsp ; & nbsp ; & nbsp ; & nbsp ; & nbsp ; & nbsp ; & nbsp ; & nbsp ; : MULTIPOINT ( ( 0 0 ) )06</ span >< span_class= " punctuation_token" >.</ span > arcpy < span_class= " punctuation_token" >.</ span > Geometry < span_class= " punctuation_token" >(</ span >< span_class= " string_token" >'multipoint'</ span >< span_class= " punctuation_token" >,</ span > arcpy < span_class= " punctuation_token" >.</ span > Array < span_class= " punctuation_token" >(</ span >< span_class= " punctuation_token" >[</ span >< span_class= " punctuation_token" ]</ span >< span_class= " punctuation_token" )</_span>)& nb sp; : Object: CreateObject.....<\/SPAN>.<\/SPAN>.<\/SPAN>02<\/SPAN>.<\/SPAN> arcpy.<\/SPAN>Geometry(<\/SPAN>'polyline'<\/SPAN>,<\/SPAN>None)<\/SPAN> :<\/SPAN> Object:<\/SPAN> CreateObject.<\/SPAN>.<\/SPAN>.<\/SPAN>.<\/SPAN>03<\/SPAN>.<\/SPAN> arcpy.<\/SPAN>Geometry(<\/SPAN>'polyline'<\/SPAN>,<\/SPAN>arcpy.<\/SPAN>Array(<\/SPAN>)<\/SPAN>)<\/SPAN> :<\/SPAN> Object:<\/SPAN> CreateObject.<\/SPAN>.<\/SPAN>.<\/SPAN>.<\/SPAN>04<\/SPAN>.<\/SPA... (truncated) ...rrow new,courier,monospace;">arcpy.Polygon()<\/SPAN> terwijl arcpy.Multipoint()<\/span> één verschil heeft met het doorgeven van arcpy.Point()<\/span>. <\/P><\/BODY><\/HTML>
Nice job Joshua... sadly 'None' still isn't from previous discussions, nothing has changed
Joshua Bixby / Dan Patterson
Do you know how you would invoke the 'within' method? Been struggling with that one.
It's on the Geometry site, but, alas no good sample 😕 Geometry—Help | ArcGIS for Desktop
In the Pro help... still applies to ArcMap http://pro.arcgis.com/en/pro-app/arcpy/data-access/searchcursor-class.htm
Andrew Valenski, I responded in your cross post: Arcpy write geometry error. Instead of cross-posting the same question to slightly-related, existing discussions, it would have been better in this case to just post a new question with a bit more information. I see you started a new question: https://community.esri.com/thread/197968-re-how-to-use-arcpy-geometry-measureonline
In GeoNet, instead of cross posting you can post your question in one space/place and share that question in other spaces/places. That allows the question to get higher visibility without creating multiple, independent versions of the same question that can lead to confusion.
This is an excellent analysis @JoshuaBixby!
Most important thing is that technique for creation of empty geometries should be noted in the docs at least, and even better should be made consistent with other Pythonic methods of creating empties...
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.