AnsweredAssumed Answered

Creating Feature Class

Question asked by deleted-user-Pi5x1UjkS2PY on Dec 9, 2014
Latest reply on Dec 17, 2014 by Dalshearer

I am using     arcpy.da.NumPyArrayToFeatureClass(npyarr, out_fc, ['LONGITUDE','LATITUDE'], sr) to create a shape file but it is removing my Latitude and Longitude fields which I want to include in my JavaScript table.  Not sure why it is doing this.  It creates my shapefile but removes these two columns.  Anyway you know of that I can keep them.

 

Here is my dtype:

[('YEAR', '<i4'), ('REGIONID', '<i4'), ('DISTRICTID', '<i4'), ('REGIONNAME', '|S255'), ('DISTRICTNAME', '|S255'), ('DIVLOC', '|S255'), ('STORENAME', '|S255'), ('CLUSTER', '|S255'), ('SUBID', '|S255'), ('SUBNAME', '|S255'), ('SEQUENCE', '<i4'), ('S_AREA', '<i4'), ('FS_AREA', '<i4'), ('ST_AREA', '<i4'), ('FR_AREA', '<i4'), ('SO_AREA', '<i4'), ('SL_AREA', '<i4'), ('TOTALSALES', '<i4'), ('OWNEDSALES', '<i4'), ('LEASEDSALES', '<i4'), ('GM', '<i4'), ('PROD', '<i4'), ('GMPROD', '<i4'), ('LATITUDE', '<f8'), ('LATITUDE1', '<f8'), ('LONGITUDE', '<f8'), ('LONGITUDE1', '<f8'), ('RANKSALESSUB', '<i4'), ('RANKPRODSUB', '<i4'), ('RANKSALESSUBD', '<i4'), ('RANKPRODSUBD', '<i4'), ('RANKSALESSUBR', '<i4'), ('RANKPRODSUBR', '<i4'), ('RANKSALESSUBS', '<i4'), ('RANKPRODSUBS', '<i4'), ('RANKSALESSUBC', '<i4'), ('RANKPRODSUBC', '<i4')]

 

 

## the important code

   datarray = []

    #for row in cursor:

    for row in cursor.fetchall():

        datarray.append(tuple(row))

 

    dtype = np.dtype(eval(get_dtype))

    WKID = 4326 # WGS-1984
    sr = arcpy.SpatialReference()
    sr.factoryCode = WKID
    sr.create()
    env.outputCoordinateSystem = sr

    npyarr = np.array(datarray, dtype)
    out_fc = strFilePath + strShapeFileName

    if arcpy.Exists(out_fc):
        arcpy.Delete_management(out_fc)
        arcpy.Delete_management("in_memory")
    env.overwriteOutput = 1

 

    arcpy.da.NumPyArrayToFeatureClass(npyarr, out_fc, ['LONGITUDE','LATITUDE'], sr)

Outcomes