<?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 Re: convert a csv with wkt geometry to featureclass with all attributes in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/convert-a-csv-with-wkt-geometry-to-featureclass/m-p/1027775#M60022</link>
    <description>&lt;P&gt;Thanks Jeff!&amp;nbsp; I also figured the spatial dataframe might work, but I didn't have experience with it and was having trouble figuring it out.&amp;nbsp; jcarlson had the same idea and with just a few lines provided a perfect solution.&amp;nbsp; Thanks for your ideas!&lt;/P&gt;</description>
    <pubDate>Wed, 17 Feb 2021 19:11:09 GMT</pubDate>
    <dc:creator>BrookeHodge</dc:creator>
    <dc:date>2021-02-17T19:11:09Z</dc:date>
    <item>
      <title>convert a csv with wkt geometry to featureclass with all attributes</title>
      <link>https://community.esri.com/t5/python-questions/convert-a-csv-with-wkt-geometry-to-featureclass/m-p/1027324#M59988</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I'm trying to take a csv that was created from a pandas dataframe that has a wkt string as the geometry information (it's a line geometry), and create a line feature class containing all the fields within the csv (15 or so).&amp;nbsp; I can use the arcpy.FromWKT to crate a geometry object and can put that into a list, and use the arcpy.CopyFeatures_management to create a featureclass from that list, however, it doesn't contain any other fields from the CSV, it only contains the geometry, so just creates a line.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here for a test, I'm just trying to bring over 1 other field (id).&amp;nbsp; I have tried creating a list of lists with it, but I get an error with the CopyFeatures function that it doesn't like that.&lt;/P&gt;&lt;P&gt;I can also use a .da.insertcursor to get each value for each field and and write it out to a file row by row, but I have about 15 fields with millions and millions of rows and feel like there needs to be a more computationally efficient way of doing this.&lt;/P&gt;&lt;P&gt;I'm not sure if a dictionary would work (instead of a list).&amp;nbsp; I don't have any experience working with dictionaries, but I can't find any info on how to use a dictionary to create a featureclass even if I could figure them out.&amp;nbsp; Does anyone have any ideas?&lt;/P&gt;&lt;P&gt;In summary: how to I convert a csv with wkt geometry information into a feature class containing all fields?&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy

# Set environments / workspace.  
arcpy.env.workspace = r"C:\Users\bhodge\Dropbox (New England Aquarium)\AIS_Projects\AISData\AISData.gdb"
arcpy.env.overwriteOutput = True

# Define Spatial Reference
wkt_sr = 'GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]]'
sr = arcpy.SpatialReference()
sr.loadFromString(wkt_sr)

inputFile = r'C:\Users\bhodge\Projects\MMC_AIS\Data\TEST_OUTPUT_FILES\TestOutput.csv'

# Create an empty feature list
FeatureList = []
# iterate through table to pull geometries
fields = ['wkt_geom', 'id']
# array = arcpy.Array()
with arcpy.da.SearchCursor(inputFile, fields) as cur:
    for row in cur:
        # Name variables and assign values starting on first record of table
        wkt = row[0]
        id = row[1]
        tempWKT = arcpy.FromWKT(wkt, sr)
        FeatureList.append(tempWKT)
    else:
        pass
del cur

arcpy.CopyFeatures_management(FeatureList, r"C:\Users\bhodge\Dropbox (New England Aquarium)\AIS_Projects\AISData\AISData.gdb\TEST50")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Feb 2021 21:04:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/convert-a-csv-with-wkt-geometry-to-featureclass/m-p/1027324#M59988</guid>
      <dc:creator>BrookeHodge</dc:creator>
      <dc:date>2021-02-16T21:04:10Z</dc:date>
    </item>
    <item>
      <title>Re: convert a csv with wkt geometry to featureclass with all attributes</title>
      <link>https://community.esri.com/t5/python-questions/convert-a-csv-with-wkt-geometry-to-featureclass/m-p/1027349#M59989</link>
      <description>&lt;P&gt;Could you skip the csv and go from the dataframe directly to the shapefile?&amp;nbsp; The sample below uses osgeo to iterate over the df and create a shapefile with fields, and ArcGIS for Python API has the &lt;A href="https://developers.arcgis.com/python/api-reference/arcgis.features.toc.html#arcgis.features.SpatialDataFrame" target="_self"&gt;spatialdataframe&lt;/A&gt; that has a &lt;A href="https://developers.arcgis.com/python/api-reference/arcgis.features.toc.html#arcgis.features.SpatialDataFrame.to_featureclass" target="_self"&gt;to_featureclass&lt;/A&gt; method that looks promising, but I don't have any examples of using it to share.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# set the driver
from osgeo import ogr
drv = ogr.GetDriverByName('ESRI Shapefile')

export_shpefle = 'path to your output file'

# create the data source
data_source = drv.CreateDataSource(export_shpefle)

# create the spatial reference, WGS84
srs = osr.SpatialReference()
srs.ImportFromEPSG(4326)

# create the layer
layer = data_source.CreateLayer("your layer name", srs, ogr.wkbLineString)

nameField = ogr.FieldDefn('id', ogr.OFTString)
layer.CreateField(nameField)
nameField = ogr.FieldDefn('field1name', ogr.OFTString)
layer.CreateField(nameField)
nameField = ogr.FieldDefn('field2name', ogr.OFTString)
layer.CreateField(nameField)

for index, row in df_geocode.iterrows():
    featureDefn = layer.GetLayerDefn()
    outFeature = ogr.Feature(featureDefn)
    wkt = ogr.CreateGeometryFromWkt(row[4]) # the field index that holds your wkt
    outFeature.SetField('field0name', str(row[0]))
    outFeature.SetGeometry(wkt)
    outFeature.SetField('field1name', row[1])
    outFeature.SetField('field2name', row[2])
    layer.CreateFeature(outFeature)                             
    outFeature = None

layer.ResetReading() # resets reading for next layer&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Feb 2021 21:56:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/convert-a-csv-with-wkt-geometry-to-featureclass/m-p/1027349#M59989</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-02-16T21:56:39Z</dc:date>
    </item>
    <item>
      <title>Re: convert a csv with wkt geometry to featureclass with all attributes</title>
      <link>https://community.esri.com/t5/python-questions/convert-a-csv-with-wkt-geometry-to-featureclass/m-p/1027350#M59990</link>
      <description>&lt;P&gt;For the attributes, use&amp;nbsp;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/tool-reference/conversion/table-to-table.htm" target="_blank"&gt;Table To Table (Conversion)—ArcGIS Pro | Documentation&lt;/A&gt;&lt;/P&gt;&lt;P&gt;then join to the geometry... way faster than reading each record through a searchcursor&lt;/P&gt;</description>
      <pubDate>Tue, 16 Feb 2021 21:59:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/convert-a-csv-with-wkt-geometry-to-featureclass/m-p/1027350#M59990</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2021-02-16T21:59:40Z</dc:date>
    </item>
    <item>
      <title>Re: convert a csv with wkt geometry to featureclass with all attributes</title>
      <link>https://community.esri.com/t5/python-questions/convert-a-csv-with-wkt-geometry-to-featureclass/m-p/1027378#M59991</link>
      <description>&lt;P&gt;If you've got your data in a pandas dataframe, I'd definitely skip the export/import.&lt;/P&gt;&lt;P&gt;Using &lt;STRONG&gt;GeoPandas&lt;/STRONG&gt; and &lt;STRONG&gt;Shapely&lt;/STRONG&gt;, along with &lt;STRONG&gt;Arcgis&lt;/STRONG&gt;, you can get your original dataframe &lt;A href="https://developers.arcgis.com/python/api-reference/arcgis.features.toc.html#arcgis.features.GeoAccessor.to_featureclass" target="_self"&gt;into a feature class&lt;/A&gt; in only a few lines.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;from geopandas import GeoDataFrame
from shapely import wkt
from arcgis.features import GeoAccessor

gdf = GeoDataFrame(df, crs="EPSG:3435", geometry=df['wkt'].apply(wkt.loads))
sedf = GeoAccessor.from_geodataframe(gdf)

sedf.spatial.to_featureclass('path/to/your.gdb/output-layer-name')&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jcarlson_0-1613515648143.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/6178iF8E1FD370AFE2BA7/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jcarlson_0-1613515648143.png" alt="jcarlson_0-1613515648143.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Edit: Nearly forgot to mention, but if you want to just work w/ the CSV, as you already have it, GeoPandas' &lt;STRONG&gt;read_file()&lt;/STRONG&gt; can take in a CSV and will correctly interpret a WKT column as geometry.&lt;/P&gt;</description>
      <pubDate>Wed, 17 Feb 2021 22:41:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/convert-a-csv-with-wkt-geometry-to-featureclass/m-p/1027378#M59991</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2021-02-17T22:41:35Z</dc:date>
    </item>
    <item>
      <title>Re: convert a csv with wkt geometry to featureclass with all attributes</title>
      <link>https://community.esri.com/t5/python-questions/convert-a-csv-with-wkt-geometry-to-featureclass/m-p/1027772#M60020</link>
      <description>&lt;P&gt;Thanks Josh!&amp;nbsp; This worked!&amp;nbsp; I just needed to add .spatial to the last line (sedf.&lt;STRONG&gt;spatial&lt;/STRONG&gt;.to_featureclass), but it works perfectly and is exactly what I was looking for!&amp;nbsp; Thanks so much!&lt;/P&gt;&lt;P&gt;Brooke&lt;/P&gt;</description>
      <pubDate>Wed, 17 Feb 2021 19:09:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/convert-a-csv-with-wkt-geometry-to-featureclass/m-p/1027772#M60020</guid>
      <dc:creator>BrookeHodge</dc:creator>
      <dc:date>2021-02-17T19:09:16Z</dc:date>
    </item>
    <item>
      <title>Re: convert a csv with wkt geometry to featureclass with all attributes</title>
      <link>https://community.esri.com/t5/python-questions/convert-a-csv-with-wkt-geometry-to-featureclass/m-p/1027775#M60022</link>
      <description>&lt;P&gt;Thanks Jeff!&amp;nbsp; I also figured the spatial dataframe might work, but I didn't have experience with it and was having trouble figuring it out.&amp;nbsp; jcarlson had the same idea and with just a few lines provided a perfect solution.&amp;nbsp; Thanks for your ideas!&lt;/P&gt;</description>
      <pubDate>Wed, 17 Feb 2021 19:11:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/convert-a-csv-with-wkt-geometry-to-featureclass/m-p/1027775#M60022</guid>
      <dc:creator>BrookeHodge</dc:creator>
      <dc:date>2021-02-17T19:11:09Z</dc:date>
    </item>
    <item>
      <title>Re: convert a csv with wkt geometry to featureclass with all attributes</title>
      <link>https://community.esri.com/t5/python-questions/convert-a-csv-with-wkt-geometry-to-featureclass/m-p/1027777#M60023</link>
      <description>&lt;P&gt;Thanks Dan.&amp;nbsp; jcarlson provided a simple solution, but this could be a good workaround for other things.&amp;nbsp; Thanks for your ideas!&lt;/P&gt;&lt;P&gt;Brooke&lt;/P&gt;</description>
      <pubDate>Wed, 17 Feb 2021 19:12:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/convert-a-csv-with-wkt-geometry-to-featureclass/m-p/1027777#M60023</guid>
      <dc:creator>BrookeHodge</dc:creator>
      <dc:date>2021-02-17T19:12:11Z</dc:date>
    </item>
    <item>
      <title>Re: convert a csv with wkt geometry to featureclass with all attributes</title>
      <link>https://community.esri.com/t5/python-questions/convert-a-csv-with-wkt-geometry-to-featureclass/m-p/1027870#M60024</link>
      <description>&lt;P&gt;Glad to hear it, and thanks for catching my omission! I've amended the original post for anyone else who may find it.&lt;/P&gt;</description>
      <pubDate>Wed, 17 Feb 2021 22:42:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/convert-a-csv-with-wkt-geometry-to-featureclass/m-p/1027870#M60024</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2021-02-17T22:42:07Z</dc:date>
    </item>
    <item>
      <title>Re: convert a csv with wkt geometry to featureclass with all attributes</title>
      <link>https://community.esri.com/t5/python-questions/convert-a-csv-with-wkt-geometry-to-featureclass/m-p/1101594#M62537</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/363906"&gt;@jcarlson&lt;/a&gt;, I'm trying to do the same thing as OP.&amp;nbsp;Do you have any tips on successfully creating an environment where arcpy and geopandas work together? I am using a cloned python environment in ArcGIS Pro. I am getting a failed message when trying to conda-forge install geopandas. I also am worried about the same thing occurring when trying to install shapely.. Many thanks!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Sep 2021 12:46:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/convert-a-csv-with-wkt-geometry-to-featureclass/m-p/1101594#M62537</guid>
      <dc:creator>jblng</dc:creator>
      <dc:date>2021-09-24T12:46:39Z</dc:date>
    </item>
    <item>
      <title>Re: convert a csv with wkt geometry to featureclass with all attributes</title>
      <link>https://community.esri.com/t5/python-questions/convert-a-csv-with-wkt-geometry-to-featureclass/m-p/1101602#M62538</link>
      <description>&lt;P&gt;I do occasionally run into issues when geopandas and arcgis are used together; it seems to be related on where my scripts are run from. I use &lt;A href="https://anaconda.org/" target="_blank"&gt;Anaconda&lt;/A&gt; to manage my python envs, and run my notebooks from there, or else through the (recently updated and much improved) notebook viewer in VS Code.&lt;/P&gt;&lt;P&gt;As a general rule, I don't really mess with python envs in Pro. Times I've attempted to clone and modify the Pro python env, I've had nothing but trouble. If I need arcpy, I just stick to what's available via arcpy and the default env.&lt;/P&gt;&lt;P&gt;You'll notice in my post that I don't actually use arcpy at all, just arcgis and geopandas.&lt;/P&gt;</description>
      <pubDate>Fri, 24 Sep 2021 13:14:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/convert-a-csv-with-wkt-geometry-to-featureclass/m-p/1101602#M62538</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2021-09-24T13:14:13Z</dc:date>
    </item>
    <item>
      <title>Re: convert a csv with wkt geometry to featureclass with all attributes</title>
      <link>https://community.esri.com/t5/python-questions/convert-a-csv-with-wkt-geometry-to-featureclass/m-p/1101744#M62539</link>
      <description>&lt;P&gt;Thanks, Josh! Quick follow-up question, I'm still wrapping my head around the difference between arcgis and arcpy. Is arcgis used to access the ArcGIS API, while arcpy is pulling from your local instance of Pro? Also, good to know about limitations of modifying a python env in Pro, saves me time knowing it's not really possible.&lt;/P&gt;&lt;P&gt;Thanks again!&amp;nbsp;&lt;/P&gt;&lt;P&gt;Jo&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Sep 2021 17:39:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/convert-a-csv-with-wkt-geometry-to-featureclass/m-p/1101744#M62539</guid>
      <dc:creator>jblng</dc:creator>
      <dc:date>2021-09-24T17:39:34Z</dc:date>
    </item>
    <item>
      <title>Re: convert a csv with wkt geometry to featureclass with all attributes</title>
      <link>https://community.esri.com/t5/python-questions/convert-a-csv-with-wkt-geometry-to-featureclass/m-p/1288333#M67629</link>
      <description>&lt;P&gt;Hi Josh,&lt;/P&gt;&lt;P&gt;I'm trying to get this to work, but I'm getting the following error message:&lt;/P&gt;&lt;P&gt;AttributeError: 'str' object has no attribute 'loads'&lt;/P&gt;&lt;P&gt;I'm using the following code:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Python1.png" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/70465iFABFD9A926FBBA74/image-size/large?v=v2&amp;amp;px=999" role="button" title="Python1.png" alt="Python1.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Here's a screenshot of the error:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Python.png" style="width: 952px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/70466i62172FD604E1164A/image-size/large?v=v2&amp;amp;px=999" role="button" title="Python.png" alt="Python.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Any help would be greatly appreciated.&lt;/P&gt;</description>
      <pubDate>Thu, 11 May 2023 19:04:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/convert-a-csv-with-wkt-geometry-to-featureclass/m-p/1288333#M67629</guid>
      <dc:creator>Luis</dc:creator>
      <dc:date>2023-05-11T19:04:02Z</dc:date>
    </item>
    <item>
      <title>Re: convert a csv with wkt geometry to featureclass with all attributes</title>
      <link>https://community.esri.com/t5/python-questions/convert-a-csv-with-wkt-geometry-to-featureclass/m-p/1288357#M67630</link>
      <description>&lt;P&gt;Could be a long shot, but are you importing the GeoAssessor?&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from arcgis.features import GeoAccessor, GeoSeriesAccessor&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 May 2023 20:07:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/convert-a-csv-with-wkt-geometry-to-featureclass/m-p/1288357#M67630</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2023-05-11T20:07:17Z</dc:date>
    </item>
    <item>
      <title>Re: convert a csv with wkt geometry to featureclass with all attributes</title>
      <link>https://community.esri.com/t5/python-questions/convert-a-csv-with-wkt-geometry-to-featureclass/m-p/1289157#M67644</link>
      <description>&lt;P&gt;Hi Jeff, thanks for the suggestion.&amp;nbsp; There was actually an empty cell in the data that was causing a problem, but it's working now.&amp;nbsp; I appreciate it, though.&lt;/P&gt;</description>
      <pubDate>Mon, 15 May 2023 14:41:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/convert-a-csv-with-wkt-geometry-to-featureclass/m-p/1289157#M67644</guid>
      <dc:creator>Luis</dc:creator>
      <dc:date>2023-05-15T14:41:50Z</dc:date>
    </item>
    <item>
      <title>Re: convert a csv with wkt geometry to featureclass with all attributes</title>
      <link>https://community.esri.com/t5/python-questions/convert-a-csv-with-wkt-geometry-to-featureclass/m-p/1373079#M69700</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/363906"&gt;@jcarlson&lt;/a&gt;&amp;nbsp;This code has been a valuable find. Thank you very much for sharing.&lt;BR /&gt;&lt;BR /&gt;I have it working, but I was unable to get a feature class to save into the provided .GDB. I can get an output for a .SHP though... Any idea why this would be? Code says it runs just fine with the feature class but when I check the destination it's empty.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jan 2024 18:10:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/convert-a-csv-with-wkt-geometry-to-featureclass/m-p/1373079#M69700</guid>
      <dc:creator>Zartico-GIS</dc:creator>
      <dc:date>2024-01-22T18:10:49Z</dc:date>
    </item>
    <item>
      <title>Re: convert a csv with wkt geometry to featureclass with all attributes</title>
      <link>https://community.esri.com/t5/python-questions/convert-a-csv-with-wkt-geometry-to-featureclass/m-p/1487524#M70758</link>
      <description>&lt;P&gt;import arcpy&lt;BR /&gt;import csv&lt;/P&gt;&lt;P&gt;arcpy.env.overwriteOutput = True&lt;/P&gt;&lt;P&gt;# INPUTS---------------------------------------------#&lt;BR /&gt;input_csv = r"CSV FILE LOCATION"&lt;/P&gt;&lt;P&gt;# Output Geometry Information - type and the integer EPSG code that refers to the spatial reference.&lt;BR /&gt;geom_type = "MULTIPOLYGON" # This could also be POINT, POLYLINE, etc.&lt;BR /&gt;geom_sr = 4326 # you can Google your spatial reference name and "EPSG" to get this number&lt;/P&gt;&lt;P&gt;# Output Location and Name&lt;BR /&gt;out_gdb = r"YOUR.gdb"&lt;BR /&gt;out_name = "NAME_FC" # Leave if you want, this is the output feature class name&lt;/P&gt;&lt;P&gt;# Create a blank output FC using the provided geometry type and spatial reference.&lt;BR /&gt;out_fc = arcpy.management.CreateFeatureclass(out_path=out_gdb,&lt;BR /&gt;out_name=out_name,&lt;BR /&gt;geometry_type=geom_type,&lt;BR /&gt;spatial_reference=geom_sr, )&lt;/P&gt;&lt;P&gt;# Open CSV. Create Reader object.&lt;BR /&gt;with open(input_csv, "r", newline="") as csvfile:&lt;BR /&gt;csvreader = csv.reader(csvfile, delimiter=",")&lt;/P&gt;&lt;P&gt;# Create InsertCursor.&lt;BR /&gt;# For each row in CSV, attempt to convert WKT in column 1 to Esri Geometry object.&lt;BR /&gt;# All other columns are read, but ignored.&lt;BR /&gt;with arcpy.da.InsertCursor(out_fc, "SHAPE@") as icurs:&lt;BR /&gt;for wkt_geom, *other_columns in csvreader:&lt;/P&gt;&lt;P&gt;# Try to convert the WKT to a geom object.&lt;BR /&gt;try:&lt;BR /&gt;#print(f"CONVERTING WKT GEOM...\n{wkt_geom}")&lt;BR /&gt;geom_from_wkt = arcpy.FromWKT(wkt_geom, arcpy.SpatialReference(4326))&lt;/P&gt;&lt;P&gt;# Skip if conversion fails, could be bad formatting or a spreadsheet header.&lt;BR /&gt;except TypeError:&lt;BR /&gt;print(f"SKIPPING {wkt_geom}; IS THIS A HEADER?")&lt;BR /&gt;continue&lt;/P&gt;&lt;P&gt;# Attempt to write the Geometry object to the new feature class.&lt;BR /&gt;icurs.insertRow([geom_from_wkt])&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This creates a "CLEAN" joinable FC that allows for many different use cases. You can design Toolbox to handle the params and allow users to change as desired.&lt;/P&gt;</description>
      <pubDate>Sat, 08 Jun 2024 00:23:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/convert-a-csv-with-wkt-geometry-to-featureclass/m-p/1487524#M70758</guid>
      <dc:creator>GeopixiDev</dc:creator>
      <dc:date>2024-06-08T00:23:02Z</dc:date>
    </item>
  </channel>
</rss>

