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.

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)

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.