<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic ArcGIS API for Python - plotting extent rectangle of a polygon in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/arcgis-api-for-python-plotting-extent-rectangle-of/m-p/833147#M3245</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a layer of polygons and would like to be able to plot the extent boundary rectangle on a map. I have my polygons in a Spatially Enabled DataFrame (polygonSDF = poygonFeatureSet.sdf) that I can successfully plot using spatial.plot(). I've so far tried&amp;nbsp;two different potential approaches to this problem and&amp;nbsp;in both cases have run into errors I haven't been able to solve. I don't want to use draw() as described in the &lt;A href="https://developers.arcgis.com/python/guide/spatially-enabled-dataframe-advanced-topics/" rel="nofollow noopener noreferrer" target="_blank"&gt;Spatially Enabled DataFrames Advanced Topics tutorial&lt;/A&gt; because then you lose the attribute information of the original polygon, and just have a static graphic.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can anyone either point out a fix to one of the&amp;nbsp;approaches described below, or suggest an alternate way to solve this problem? I'm working with ArcGIS API for Python 1.6.1 in the ArcGIS 10.7.1 Jupyter Notebook set-up on Windows 10.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm calculating and storing the extent data as follows:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;extentList &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; f &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; polygonFeatureSet&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;features&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
     &lt;SPAN class="comment token"&gt;# Calculate the extent&lt;/SPAN&gt;
     &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;w&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; s&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; e&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; n&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; Geometry&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;f&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;geometry&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;geoextent
     extent &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; Polygon&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
     &lt;SPAN class="string token"&gt;"rings"&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;e&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; s&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;w&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; s&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;w&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; n&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;e&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; n&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;e&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; s&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
     &lt;SPAN class="string token"&gt;"spatialReference"&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"wkid"&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;4326&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

     &lt;SPAN class="comment token"&gt;# Add the extent to extentList&lt;/SPAN&gt;
     extentList&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;append&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;extent&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
 
&lt;SPAN class="comment token"&gt;# Add the extents to the dataframe as a new column&lt;/SPAN&gt;
polygonSDF&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"MBRextent"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; extentList‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Approach 1: Specify which column of geometry plot() uses&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Issue: &lt;A href="https://developers.arcgis.com/python/api-reference/arcgis.features.toc.html#geoseriesaccessor" rel="nofollow noopener noreferrer" target="_blank"&gt;plot()&lt;/A&gt; doesn't appear to have this functionality, and just uses SHAPE automatically&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Approach 2: Make a copy of my polygon SEDF, and then set the SHAPE column to store the extent data instead&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Issue: Despite extentList containing valid Geometry objects, once loaded into the SEDF the MBRextent column is of type 'object', and thus is unable to be recognized and used as geometry.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="comment token"&gt;# Attempt 1&lt;/SPAN&gt;
copySDF&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'SHAPE'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; copySDF&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'MBRextent'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;‍

&lt;SPAN class="comment token"&gt;# Attempt 1 Error&lt;/SPAN&gt;
AttributeError&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; Cannot use &lt;SPAN class="string token"&gt;'geom'&lt;/SPAN&gt; accessor on objects of dtype &lt;SPAN class="string token"&gt;'object'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;‍‍‍‍‍‍‍‍



&lt;SPAN class="comment token"&gt;# Attempt 2&lt;/SPAN&gt;
copySDF&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;set_geometry&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'MBRextent'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;# Attempt 2 Error&lt;/SPAN&gt;
TypeError&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; Input geometry column must contain valid geometry objects&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;



&lt;SPAN class="comment token"&gt;# Attempt 3&lt;/SPAN&gt;
extentDF &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; pd&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;DataFrame&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;polygonSDF&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"MBRextent"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;set_geometry&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"MBRextent"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;# Attempt 3 Error&lt;/SPAN&gt;
TypeError&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; Input geometry column must contain valid geometry objects&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Approach 2B:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;To try to rectify the issues caused by the extent being of type 'object' I've tried explicitly setting the column type to Geometry.&lt;/P&gt;&lt;P&gt;Issue: Geometry type is not being recognized by pandas methods&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="comment token"&gt;# Attempt 1 - replacement of Line 12 when creating the extent column&lt;/SPAN&gt;
polygonSDF&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"MBRextent"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; pd&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Series&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;extentList&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; dtype&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;Polygon&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;# Attempt 1 error&lt;/SPAN&gt;
TypeError&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; dtype &lt;SPAN class="string token"&gt;'&amp;lt;class '&lt;/SPAN&gt;arcgis&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;geometry&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;_types&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Geometry&lt;SPAN class="string token"&gt;'&amp;gt;'&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;not&lt;/SPAN&gt; understood



&lt;SPAN class="comment token"&gt;# Attempt 2 - setting type after creation of extent column&lt;/SPAN&gt;
polygonSDF&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'MBRextent'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;astype&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;Geometry&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;# Attempt 2 error&lt;/SPAN&gt;
TypeError&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; dtype &lt;SPAN class="string token"&gt;'&amp;lt;class '&lt;/SPAN&gt;arcgis&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;geometry&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;_types&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Geometry&lt;SPAN class="string token"&gt;'&amp;gt;'&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;not&lt;/SPAN&gt; understood



&lt;SPAN class="comment token"&gt;# Attempt 3 - setting type after creation of extent column&lt;/SPAN&gt;
polygonSDF&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"MBRextent"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;astype&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;polygonSDF&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'SHAPE'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;dtype&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;# Attempt 3 error&lt;/SPAN&gt;
NotImplementedError&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; ‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 10:04:45 GMT</pubDate>
    <dc:creator>TracyWhelen</dc:creator>
    <dc:date>2021-12-12T10:04:45Z</dc:date>
    <item>
      <title>ArcGIS API for Python - plotting extent rectangle of a polygon</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/arcgis-api-for-python-plotting-extent-rectangle-of/m-p/833147#M3245</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a layer of polygons and would like to be able to plot the extent boundary rectangle on a map. I have my polygons in a Spatially Enabled DataFrame (polygonSDF = poygonFeatureSet.sdf) that I can successfully plot using spatial.plot(). I've so far tried&amp;nbsp;two different potential approaches to this problem and&amp;nbsp;in both cases have run into errors I haven't been able to solve. I don't want to use draw() as described in the &lt;A href="https://developers.arcgis.com/python/guide/spatially-enabled-dataframe-advanced-topics/" rel="nofollow noopener noreferrer" target="_blank"&gt;Spatially Enabled DataFrames Advanced Topics tutorial&lt;/A&gt; because then you lose the attribute information of the original polygon, and just have a static graphic.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can anyone either point out a fix to one of the&amp;nbsp;approaches described below, or suggest an alternate way to solve this problem? I'm working with ArcGIS API for Python 1.6.1 in the ArcGIS 10.7.1 Jupyter Notebook set-up on Windows 10.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm calculating and storing the extent data as follows:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;extentList &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; f &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; polygonFeatureSet&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;features&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
     &lt;SPAN class="comment token"&gt;# Calculate the extent&lt;/SPAN&gt;
     &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;w&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; s&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; e&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; n&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; Geometry&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;f&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;geometry&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;geoextent
     extent &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; Polygon&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
     &lt;SPAN class="string token"&gt;"rings"&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;e&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; s&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;w&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; s&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;w&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; n&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;e&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; n&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;e&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; s&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
     &lt;SPAN class="string token"&gt;"spatialReference"&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"wkid"&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;4326&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

     &lt;SPAN class="comment token"&gt;# Add the extent to extentList&lt;/SPAN&gt;
     extentList&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;append&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;extent&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
 
&lt;SPAN class="comment token"&gt;# Add the extents to the dataframe as a new column&lt;/SPAN&gt;
polygonSDF&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"MBRextent"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; extentList‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Approach 1: Specify which column of geometry plot() uses&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Issue: &lt;A href="https://developers.arcgis.com/python/api-reference/arcgis.features.toc.html#geoseriesaccessor" rel="nofollow noopener noreferrer" target="_blank"&gt;plot()&lt;/A&gt; doesn't appear to have this functionality, and just uses SHAPE automatically&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Approach 2: Make a copy of my polygon SEDF, and then set the SHAPE column to store the extent data instead&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Issue: Despite extentList containing valid Geometry objects, once loaded into the SEDF the MBRextent column is of type 'object', and thus is unable to be recognized and used as geometry.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="comment token"&gt;# Attempt 1&lt;/SPAN&gt;
copySDF&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'SHAPE'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; copySDF&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'MBRextent'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;‍

&lt;SPAN class="comment token"&gt;# Attempt 1 Error&lt;/SPAN&gt;
AttributeError&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; Cannot use &lt;SPAN class="string token"&gt;'geom'&lt;/SPAN&gt; accessor on objects of dtype &lt;SPAN class="string token"&gt;'object'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;‍‍‍‍‍‍‍‍



&lt;SPAN class="comment token"&gt;# Attempt 2&lt;/SPAN&gt;
copySDF&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;set_geometry&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'MBRextent'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;# Attempt 2 Error&lt;/SPAN&gt;
TypeError&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; Input geometry column must contain valid geometry objects&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;



&lt;SPAN class="comment token"&gt;# Attempt 3&lt;/SPAN&gt;
extentDF &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; pd&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;DataFrame&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;polygonSDF&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"MBRextent"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;set_geometry&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"MBRextent"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;# Attempt 3 Error&lt;/SPAN&gt;
TypeError&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; Input geometry column must contain valid geometry objects&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Approach 2B:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;To try to rectify the issues caused by the extent being of type 'object' I've tried explicitly setting the column type to Geometry.&lt;/P&gt;&lt;P&gt;Issue: Geometry type is not being recognized by pandas methods&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="comment token"&gt;# Attempt 1 - replacement of Line 12 when creating the extent column&lt;/SPAN&gt;
polygonSDF&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"MBRextent"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; pd&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Series&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;extentList&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; dtype&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;Polygon&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;# Attempt 1 error&lt;/SPAN&gt;
TypeError&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; dtype &lt;SPAN class="string token"&gt;'&amp;lt;class '&lt;/SPAN&gt;arcgis&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;geometry&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;_types&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Geometry&lt;SPAN class="string token"&gt;'&amp;gt;'&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;not&lt;/SPAN&gt; understood



&lt;SPAN class="comment token"&gt;# Attempt 2 - setting type after creation of extent column&lt;/SPAN&gt;
polygonSDF&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'MBRextent'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;astype&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;Geometry&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;# Attempt 2 error&lt;/SPAN&gt;
TypeError&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; dtype &lt;SPAN class="string token"&gt;'&amp;lt;class '&lt;/SPAN&gt;arcgis&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;geometry&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;_types&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Geometry&lt;SPAN class="string token"&gt;'&amp;gt;'&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;not&lt;/SPAN&gt; understood



&lt;SPAN class="comment token"&gt;# Attempt 3 - setting type after creation of extent column&lt;/SPAN&gt;
polygonSDF&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"MBRextent"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;astype&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;polygonSDF&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'SHAPE'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;dtype&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;# Attempt 3 error&lt;/SPAN&gt;
NotImplementedError&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; ‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 10:04:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/arcgis-api-for-python-plotting-extent-rectangle-of/m-p/833147#M3245</guid>
      <dc:creator>TracyWhelen</dc:creator>
      <dc:date>2021-12-12T10:04:45Z</dc:date>
    </item>
  </channel>
</rss>

