<?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 Unable to convert DF to Shapefile/Feature Layer in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/unable-to-convert-df-to-shapefile-feature-layer/m-p/1133644#M7002</link>
    <description>&lt;P&gt;Hello!&amp;nbsp; I am having an issue when trying to export a spatially enabled dataframe to a feature class or feature layer using the arcgis package for python.&amp;nbsp; I receive the error "TypeError: '&amp;lt;' not supported between instances of 'tuple' and 'float'".&lt;/P&gt;&lt;P&gt;For background, I am importing a shapefile into a sedf&amp;nbsp; using pd.DataFrame.spatial.from_featureclass() (success!), joining this sdf with another df that has economic information (success!), and would like to return this to a shapefile or upload to Arcgis enterprise (failure).&lt;/P&gt;&lt;P&gt;My code when trying to create a local shapefile:&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;sdf&lt;/SPAN&gt;&lt;SPAN&gt;.spatial.to_featureclass(&lt;/SPAN&gt;&lt;SPAN&gt;location&lt;/SPAN&gt;&lt;SPAN&gt;=r"local/location/output.shp&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;My code when trying to create a feature layer on an ArcGIS enterprise portal:&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;...previously established GIS connection...&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;sdf&lt;/SPAN&gt;&lt;SPAN&gt;.spatial.to_featurelayer('my output title'&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;I am using arcgis (1.9.1) and python 3.9.7.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Thank you!&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;P&gt;TypeError Traceback (most recent call last)&lt;BR /&gt;program.py in &amp;lt;module&amp;gt;&lt;BR /&gt;----&amp;gt; 79 disaster_areas.spatial.to_featureclass(location=r&lt;SPAN&gt;"local/location/output.shp&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;)&lt;/P&gt;&lt;P&gt;C:\Anaconda3_2021.11\lib\site-packages\arcgis\features\geo\_accessor.py in to_featureclass(self, location, overwrite)&lt;BR /&gt;1838 def to_featureclass(self, location, overwrite=True):&lt;BR /&gt;1839 """exports a geo enabled dataframe to a feature class."""&lt;BR /&gt;-&amp;gt; 1840 return to_featureclass(geo=self,&lt;BR /&gt;1841 location=location,&lt;BR /&gt;1842 overwrite=overwrite)&lt;/P&gt;&lt;P&gt;C:\Anaconda3_2021.11\lib\site-packages\arcgis\features\geo\_io\fileops.py in to_featureclass(geo, location, overwrite, validate)&lt;BR /&gt;584 fc_name = "%s.shp" % fc_name&lt;BR /&gt;585 if SHPVERSION &amp;lt; [2]:&lt;BR /&gt;--&amp;gt; 586 return _pyshp_to_shapefile(df=df,&lt;BR /&gt;587 out_path=out_location,&lt;BR /&gt;588 out_name=fc_name)&lt;/P&gt;&lt;P&gt;C:\Anaconda3_2021.11\lib\site-packages\arcgis\features\geo\_io\fileops.py in _pyshp_to_shapefile(df, out_path, out_name)&lt;BR /&gt;679 del row&lt;BR /&gt;680 del geom&lt;BR /&gt;--&amp;gt; 681 shpfile.save(out_fc)&lt;BR /&gt;682&lt;BR /&gt;683&lt;/P&gt;&lt;P&gt;C:\Anaconda3_2021.11\lib\site-packages\shapefile.py in save(self, target, shp, shx, dbf)&lt;BR /&gt;1111 target = temp.name&lt;BR /&gt;1112 generated = True&lt;BR /&gt;-&amp;gt; 1113 self.saveShp(target)&lt;BR /&gt;1114 self.shp.close()&lt;BR /&gt;1115 self.saveShx(target)&lt;/P&gt;&lt;P&gt;C:\Anaconda3_2021.11\lib\site-packages\shapefile.py in saveShp(self, target)&lt;BR /&gt;1067 self.shapeType = next((s.shapeType for s in self._shapes if s.shapeType), NULL)&lt;BR /&gt;1068 self.shp = self.__getFileObj(target)&lt;BR /&gt;-&amp;gt; 1069 self.__shapefileHeader(self.shp, headerType='shp')&lt;BR /&gt;1070 self.__shpRecords()&lt;BR /&gt;1071&lt;/P&gt;&lt;P&gt;C:\Anaconda3_2021.11\lib\site-packages\shapefile.py in __shapefileHeader(self, fileObj, headerType)&lt;BR /&gt;752 if self.shapeType != 0:&lt;BR /&gt;753 try:&lt;BR /&gt;--&amp;gt; 754 f.write(pack("&amp;lt;4d", *self.bbox()))&lt;BR /&gt;755 except error:&lt;BR /&gt;756 raise ShapefileException("Failed to write shapefile bounding box. Floats required.")&lt;/P&gt;&lt;P&gt;C:\Anaconda3_2021.11\lib\site-packages\shapefile.py in bbox(self)&lt;BR /&gt;724 the lower-left and upper-right corners. It does not contain the&lt;BR /&gt;725 elevation or measure extremes."""&lt;BR /&gt;--&amp;gt; 726 return self.__bbox(self._shapes)&lt;BR /&gt;727&lt;BR /&gt;728 def zbox(self):&lt;/P&gt;&lt;P&gt;C:\Anaconda3_2021.11\lib\site-packages\shapefile.py in __bbox(self, shapes)&lt;BR /&gt;696 if len(x) == 0:&lt;BR /&gt;697 return [0] * 4&lt;BR /&gt;--&amp;gt; 698 return [min(x), min(y), max(x), max(y)]&lt;BR /&gt;699&lt;BR /&gt;700 def __zbox(self, shapes):&lt;/P&gt;&lt;P&gt;TypeError: '&amp;lt;' not supported between instances of 'tuple' and 'float'&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
    <pubDate>Thu, 13 Jan 2022 22:23:57 GMT</pubDate>
    <dc:creator>dallison</dc:creator>
    <dc:date>2022-01-13T22:23:57Z</dc:date>
    <item>
      <title>Unable to convert DF to Shapefile/Feature Layer</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/unable-to-convert-df-to-shapefile-feature-layer/m-p/1133644#M7002</link>
      <description>&lt;P&gt;Hello!&amp;nbsp; I am having an issue when trying to export a spatially enabled dataframe to a feature class or feature layer using the arcgis package for python.&amp;nbsp; I receive the error "TypeError: '&amp;lt;' not supported between instances of 'tuple' and 'float'".&lt;/P&gt;&lt;P&gt;For background, I am importing a shapefile into a sedf&amp;nbsp; using pd.DataFrame.spatial.from_featureclass() (success!), joining this sdf with another df that has economic information (success!), and would like to return this to a shapefile or upload to Arcgis enterprise (failure).&lt;/P&gt;&lt;P&gt;My code when trying to create a local shapefile:&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;sdf&lt;/SPAN&gt;&lt;SPAN&gt;.spatial.to_featureclass(&lt;/SPAN&gt;&lt;SPAN&gt;location&lt;/SPAN&gt;&lt;SPAN&gt;=r"local/location/output.shp&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;My code when trying to create a feature layer on an ArcGIS enterprise portal:&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;...previously established GIS connection...&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;sdf&lt;/SPAN&gt;&lt;SPAN&gt;.spatial.to_featurelayer('my output title'&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;I am using arcgis (1.9.1) and python 3.9.7.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Thank you!&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;P&gt;TypeError Traceback (most recent call last)&lt;BR /&gt;program.py in &amp;lt;module&amp;gt;&lt;BR /&gt;----&amp;gt; 79 disaster_areas.spatial.to_featureclass(location=r&lt;SPAN&gt;"local/location/output.shp&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;)&lt;/P&gt;&lt;P&gt;C:\Anaconda3_2021.11\lib\site-packages\arcgis\features\geo\_accessor.py in to_featureclass(self, location, overwrite)&lt;BR /&gt;1838 def to_featureclass(self, location, overwrite=True):&lt;BR /&gt;1839 """exports a geo enabled dataframe to a feature class."""&lt;BR /&gt;-&amp;gt; 1840 return to_featureclass(geo=self,&lt;BR /&gt;1841 location=location,&lt;BR /&gt;1842 overwrite=overwrite)&lt;/P&gt;&lt;P&gt;C:\Anaconda3_2021.11\lib\site-packages\arcgis\features\geo\_io\fileops.py in to_featureclass(geo, location, overwrite, validate)&lt;BR /&gt;584 fc_name = "%s.shp" % fc_name&lt;BR /&gt;585 if SHPVERSION &amp;lt; [2]:&lt;BR /&gt;--&amp;gt; 586 return _pyshp_to_shapefile(df=df,&lt;BR /&gt;587 out_path=out_location,&lt;BR /&gt;588 out_name=fc_name)&lt;/P&gt;&lt;P&gt;C:\Anaconda3_2021.11\lib\site-packages\arcgis\features\geo\_io\fileops.py in _pyshp_to_shapefile(df, out_path, out_name)&lt;BR /&gt;679 del row&lt;BR /&gt;680 del geom&lt;BR /&gt;--&amp;gt; 681 shpfile.save(out_fc)&lt;BR /&gt;682&lt;BR /&gt;683&lt;/P&gt;&lt;P&gt;C:\Anaconda3_2021.11\lib\site-packages\shapefile.py in save(self, target, shp, shx, dbf)&lt;BR /&gt;1111 target = temp.name&lt;BR /&gt;1112 generated = True&lt;BR /&gt;-&amp;gt; 1113 self.saveShp(target)&lt;BR /&gt;1114 self.shp.close()&lt;BR /&gt;1115 self.saveShx(target)&lt;/P&gt;&lt;P&gt;C:\Anaconda3_2021.11\lib\site-packages\shapefile.py in saveShp(self, target)&lt;BR /&gt;1067 self.shapeType = next((s.shapeType for s in self._shapes if s.shapeType), NULL)&lt;BR /&gt;1068 self.shp = self.__getFileObj(target)&lt;BR /&gt;-&amp;gt; 1069 self.__shapefileHeader(self.shp, headerType='shp')&lt;BR /&gt;1070 self.__shpRecords()&lt;BR /&gt;1071&lt;/P&gt;&lt;P&gt;C:\Anaconda3_2021.11\lib\site-packages\shapefile.py in __shapefileHeader(self, fileObj, headerType)&lt;BR /&gt;752 if self.shapeType != 0:&lt;BR /&gt;753 try:&lt;BR /&gt;--&amp;gt; 754 f.write(pack("&amp;lt;4d", *self.bbox()))&lt;BR /&gt;755 except error:&lt;BR /&gt;756 raise ShapefileException("Failed to write shapefile bounding box. Floats required.")&lt;/P&gt;&lt;P&gt;C:\Anaconda3_2021.11\lib\site-packages\shapefile.py in bbox(self)&lt;BR /&gt;724 the lower-left and upper-right corners. It does not contain the&lt;BR /&gt;725 elevation or measure extremes."""&lt;BR /&gt;--&amp;gt; 726 return self.__bbox(self._shapes)&lt;BR /&gt;727&lt;BR /&gt;728 def zbox(self):&lt;/P&gt;&lt;P&gt;C:\Anaconda3_2021.11\lib\site-packages\shapefile.py in __bbox(self, shapes)&lt;BR /&gt;696 if len(x) == 0:&lt;BR /&gt;697 return [0] * 4&lt;BR /&gt;--&amp;gt; 698 return [min(x), min(y), max(x), max(y)]&lt;BR /&gt;699&lt;BR /&gt;700 def __zbox(self, shapes):&lt;/P&gt;&lt;P&gt;TypeError: '&amp;lt;' not supported between instances of 'tuple' and 'float'&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 13 Jan 2022 22:23:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/unable-to-convert-df-to-shapefile-feature-layer/m-p/1133644#M7002</guid>
      <dc:creator>dallison</dc:creator>
      <dc:date>2022-01-13T22:23:57Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to convert DF to Shapefile/Feature Layer</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/unable-to-convert-df-to-shapefile-feature-layer/m-p/1133662#M7004</link>
      <description>&lt;P&gt;Not to be tiresome but many people think shapefile suck and even though they invented them Esri programmers might not give them complete attention. So have you tried writing to a file geodatabase instead? I know you said you tried going to Enterprise too but that's a whole nother can of worms.&lt;/P&gt;&lt;P&gt;I worked through a process similar to yours, let me dig around and find it...&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jan 2022 22:51:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/unable-to-convert-df-to-shapefile-feature-layer/m-p/1133662#M7004</guid>
      <dc:creator>Brian_Wilson</dc:creator>
      <dc:date>2022-01-13T22:51:08Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to convert DF to Shapefile/Feature Layer</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/unable-to-convert-df-to-shapefile-feature-layer/m-p/1133676#M7005</link>
      <description>&lt;P&gt;Curious! I've not had that happen before, though I admittedly do not export to shapefiles much.&lt;/P&gt;&lt;P&gt;Similar to &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/403473"&gt;@Brian_Wilson&lt;/a&gt; , I would first confirm if any other export format works, including the non-file options like FeatureCollection and FeatureSet, just to confirm if it's an issue with the format, as opposed to the data itself.&lt;/P&gt;&lt;P&gt;Based on the error you got, it sounds like something is wrong with the bounding box. Can you output the dataframes' &lt;STRONG&gt;bbox &lt;/STRONG&gt;property and see if it's changing over the course of your join operations?&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jan 2022 23:12:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/unable-to-convert-df-to-shapefile-feature-layer/m-p/1133676#M7005</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2022-01-13T23:12:50Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to convert DF to Shapefile/Feature Layer</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/unable-to-convert-df-to-shapefile-feature-layer/m-p/1133690#M7006</link>
      <description>&lt;P&gt;I dug up my code, changed the output path from FGDB to shapefile, and ran it.&lt;/P&gt;&lt;P&gt;I had one problem, my script sets field name aliases and that fails for a shapefile. (I can set aliases in ArcGIS Pro, so this is another bug. I used arcpy.management.AlterField. But I digress.)&lt;/P&gt;&lt;P&gt;One debugging tip that helps me is to dump out the dtypes in a dataframe to see if they make sense.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;    print(len(sdf))
    print(sdf.columns)
    print(sdf.dtypes)&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 13 Jan 2022 23:45:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/unable-to-convert-df-to-shapefile-feature-layer/m-p/1133690#M7006</guid>
      <dc:creator>Brian_Wilson</dc:creator>
      <dc:date>2022-01-13T23:45:05Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to convert DF to Shapefile/Feature Layer</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/unable-to-convert-df-to-shapefile-feature-layer/m-p/1133692#M7007</link>
      <description>&lt;P&gt;Also if you REALLY only need to go shapefile -&amp;gt; df -&amp;gt; shapefile, you could use GeoPandas instead of arcpy.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jan 2022 23:47:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/unable-to-convert-df-to-shapefile-feature-layer/m-p/1133692#M7007</guid>
      <dc:creator>Brian_Wilson</dc:creator>
      <dc:date>2022-01-13T23:47:06Z</dc:date>
    </item>
  </channel>
</rss>

