2

I have an Esri shapefile that I have dropped duplicates from and turned into a numpy array using the following code:

loc_ID_fld_names = ["LocIDNmbr", "Lat", "Long"]
loc_ID_array = arcpy.da.FeatureClassToNumPyArray(Data,loc_ID_fld_names)
uniqueLocIDs_array = list(set(locIDNmbr))
locIDs_df = pd.DataFrame(loc_ID_array)
locIDs_df_no_dupes = locIDs_df.drop_duplicates(subset=["LocIDNmbr"])
locIDs_df_no_dupes = locIDs_df_no_dupes.to_numpy()

Now I want to know how to go back and turn it to an Esri shapefile. I want to do this in the ArcPy terminal on ArcGIS Pro and not using the API, if possible.

PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked Oct 24, 2022 at 20:42

1 Answer 1

2

You can use the NumPyArrayToFeatureClass function. The array needs to be in a Structured Array format and you can convert your ndarray to this using np.rec.fromarrays. E.g.

import numpy as np
etc...
locIDs_df_no_dupes = locIDs_df_no_dupes.to_numpy()
locIDs_array_no_dupes = np.rec.fromarrays(locIDs_df_no_dupes.T, dtype=loc_ID_array.dtype)
arcpy.da.NumPyArrayToFeatureClass(locIDs_array_no_dupes, out_shp, ['Long', 'Lat'], arcpy.Describe(Data).spatialReference)
answered Oct 25, 2022 at 0:21

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.