Quantcast
Channel: Forums - Python
Viewing all articles
Browse latest Browse all 2485

ArcGIS 10.1: MakeXYEventLayer-Extra Excel points appeared in attribute table. Why?

$
0
0
Hi all,
In the IDLE Python (GUI) of my ArcGIS 10.1, I executed the following Python-ArcPy script:
Code:

# scNavyAnnexMakeXYlayer.px  [X,Y-coodinates in the xls for 80 points of boring locations]
# Description: Creates an XY layer and uses CopyFeatures to save it to a layer file (Used ArcGIS 10.0)
# Author: ESRI - modified by Scott Chang per Arkadiusz Matoszka & Wayne Whitley (Date:  31 Oct 2012)

# ******* The old script was corrected & this new script executed in ArcGIS 10.1 by Scott Chang on 30 Jan 2013 ******

# import system modules
import arcpy
from arcpy import env
 
try:
    # Set the local variables
    # in_Table = "firestations.csv"
    tb = r"C:\TEMP\Boring_Locations_WGS84_Attributes.xlsx\Boring_Locations_WGS84_Attribut$"
    xc = "POINT_X"
    yc = "POINT_Y"
    zc = "POINT_Z"

    out_Layer = "Pointlocations_layer"
    saved_Layer = r"c:\TEMP\NavyAnnex80BoringPoints.shp"    # not .layer!!!
 
    # Set the spatial reference
    # spRef = r"Coordinate Systems\Projected Coordinate Systems\Utm\Nad 1983\NAD 1983 UTM Zone 11N.prj"
    spRef = r"Coordinate Systems\Geographic Coordinate System\World\WGS 1984"
 
    # Make the XY event layer...
    arcpy.MakeXYEventLayer_management(tb, xc, yc, out_Layer, spRef)
 
    # Print the total rows
    print arcpy.GetCount_management(out_Layer)
 
    # Save to a layer file
    # arcpy.SaveToLayerFile_management(out_Layer, saved_Layer)
    arcpy.CopyFeatures_management(out_Layer, saved_Layer)      # New!!!

except:
    # If an error occurred print the message to the screen
    print arcpy.GetMessages()

I put the X,Y&Z coordinates of 80 points in the Excel .xlsx table as input. It worked. But it gave me the output with 9 extra Excel points of "Null" value I did not expect - see the attached file. I don't know how to avoid these extra Excel "NULL" points from entering the MakeXYEventLayer_management process!!?? Please kindly help and tell me why the extra Excel "NULL" points were read in the input and how to avoid it from happening.

Thanks in advance,
Scott Chang
Attached Files

Viewing all articles
Browse latest Browse all 2485

Trending Articles