Load features from database

379
2
03-24-2017 07:08 AM
JasonDavis3
New Contributor

Sorry, I'm quite new to ArcGIS, but I've been struggling to find documentation showing how to do what I need. If someone could provide a code fragment, or point me towards existing samples, I'd appreciate it.

I have a Teradata table loaded with ST_GEOMETRY points. When I query the table, the results look like:

POINT (35.856971 -86.370195)

I understand this is ArcGIS's native format, but I don't understand how to load this directly into a Feature Class. I inherited some existing code which converts a string into a list into a Numpy array into NumPyArrayToFeatureClass(), but all that shouldn't be necessary, right?

0 Kudos
2 Replies
DanPatterson_Retired
MVP Esteemed Contributor

It could be that the output is being used to produce a numpy structured array from which you can convert to a point featureclass.  Is that the only thing that is in the data file (ie any header lines) ?  If so, it can be readily brought.  The sample code would be useful to see if they are using numpy's loadtxt or similar approach.

0 Kudos
JasonDavis3
New Contributor

I can show sample code, but I'm not trying to improve it or anything. The text file layout was kinda weird--we're not using it any more. The coordinates are now in a Teradata table loaded with ST_GEOMETRY points, along with some additional data.

csv_f = csv.reader(f)
for row in csv_f:
    mbr = [(row[0], row[1], row[2], (row[1], row[2]))]
    dstMbrList.append(mbr)
f.close()
in_fc = dataPath + "a2c_output.gdb/spatialRefXY"
spatial_ref = arcpy.Describe(in_fc).spatialReference
typez = numpy.dtype=[('id', 'S23'), ('X', 'f8'), ('Y', 'f8'), ('XY', '<f8', 2)]
prv_arr = numpy.array(dstPrvList, typez)
out_prv_fc = dataPath + "a2c_output.gdb/outDstPrvTestXY01"
if arcpy.Exists(out_prv_fc):
    arcpy.Delete_management(out_prv_fc)
arcpy.da.NumPyArrayToFeatureClass(prv_arr, out_prv_fc, ['XY'], spatial_ref)

As long as I end up with the FeatureClass at the end, we're happy.

0 Kudos