CS syntax for stand-alone python

813
5
Jump to solution
06-22-2014 04:03 PM
BobMCkay
New Contributor III
Hi,

I'm trying to run;
ASCII3D_to_Feature_Class

The geographic coordinate system I require is 'GDA 1994 MGA Zone 55'

I've tried
CS = "Coordinate Systems/Geographic Coordinate Systems/World/GDA 1994 MGA Zone 55.prj"

But, I get the error;
>>> ERROR 000622: Failed to execute (ASCII 3D to Feature Class). Parameters are not valid.
ERROR 000628: Cannot set input into parameter input_coordinate_system.

Some help with the correct syntax would be greatly appreciated

Cheers
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
BobMCkay
New Contributor III
Hi,

I placed the appropiate prj file in the workspace. I also placed the xyz data files directly in the workspace.
It then was asked for an average_point_spacing.
I used 2.0 and it all worked.


The figures I had to set the point_spacing;

Avg. Point Density: 0.5 pts/m
Footprint Size: 0.32m

I used the first one to assume the value of 2.0m, Am I correct?

Cheers and many thanks


'''**************************************************************************** Name: ASCII3D_to_Feature_Class Example Description: This script demonstrates how to use the               ASCII3D_to_Feature_Class tool to create a point feature class              from a set of text files in the specified workspace. ****************************************************************************''' # Import system modules` import arcpy, os from arcpy import env import exceptions, sys, traceback  try:     #prjFile = os.path.join(arcpy.GetInstallInfo()["InstallDir"],     #                       "M:/GIS/ArcGIS 10 Coordinate System Files and Projections/ArcGIS 10 Coordinate System Files and Projections/Coordinate Systems/Projected Coordinate Systems/National Grids/Australia/GDA 1994 MGA Zone 55.prj")     #CS = arcpy.SpatialReference(prjFile)     # Obtain a license for the ArcGIS 3D Analyst extension     arcpy.CheckOutExtension("3D")     # Set environment settings     env.workspace = "M:/GIS/data"     # Set Local Variables     inFormat = "XYZ"     # Name of the output file     outFC = "90MileBeachPts_from_ASCII.shp"     # Geometry of the output feature class     outType = "MULTIPOINT"     zFactor = 1     # Coordinate system of the output feature class     CS = "GDA 1994 MGA Zone 55.prj"     fileSuffix = "mga55.xyz"      decSep = "DECIMAL_POINT" # Specifies the decimal delimeter     # Create list of ASCII files     txtList = arcpy.ListFiles("*" + fileSuffix)     # Verify the presence of TINs in the list     if len(txtList) > 0:         # Execute ASCII3D_to_Feature_Class         arcpy.ASCII3DToFeatureClass_3d(txtList, inFormat, outFC, outType,                                       zFactor,CS, 2.0, fileSuffix, decSep)  except arcpy.ExecuteError:     print arcpy.GetMessages() except:     # Get the traceback object     tb = sys.exc_info()[2]     tbinfo = traceback.format_tb(tb)[0]     # Concatenate error information into message string     pymsg = 'PYTHON ERRORS:\nTraceback info:\n{0}\nError Info:\n{1}'\           .format(tbinfo, str(sys.exc_info()[1]))     msgs = 'ArcPy ERRORS:\n {0}\n'.format(arcpy.GetMessages(2))     # Return python error messages for script tool or Python Window     arcpy.AddError(pymsg)     arcpy.AddError(msgs)

View solution in original post

0 Kudos
5 Replies
JasonScheirer
Occasional Contributor III
Try

CS = "Geographic Coordinate Systems/GDA 1994 MGA Zone 55"

should work.
0 Kudos
BobMCkay
New Contributor III
I tried it with and without .prj but alas no success. The sample code states that it is for Output but I beleive the syntax is for input. I'm confused

'''****************************************************************************
Name: ASCII3D_to_Feature_Class Example
Description: This script demonstrates how to use the 
             ASCII3D_to_Feature_Class tool to create a point feature class
             from a set of text files in the specified workspace.
****************************************************************************'''
# Import system modules`
import arcpy
from arcpy import env
import exceptions, sys, traceback

try:
    # Obtain a license for the ArcGIS 3D Analyst extension
    arcpy.CheckOutExtension("3D")
    # Set environment settings
    env.workspace = "M:/GIS/LidarProd/XYZToFeature/Missing Lidar from DSE 21022013/elevation/cep2007-08_srw-90mb/regular_surface/dem_ground/xyz_ascii"
    # Set Local Variables
    inFormat = "XYZ"
    # Name of the output file
    outFC = "90MileBeachPts_from_ASCII.shp"
    # Geometry of the output feature class
    outType = "MULTIPOINT"
    zFactor = 1
    # Coordinate system of the output feature class
    CS = "Geographic Coordinate Systems/GDA 1994 MGA Zone 55.prj"
    fileSuffix = "mga55.xyz" 
    decSep = "DECIMAL_POINT" # Specifies the decimal delimeter
    # Create list of ASCII files
    txtList = arcpy.ListFiles("*" + fileSuffix)
    # Verify the presence of TINs in the list
    if len(txtList) > 0:
        # Execute ASCII3D_to_Feature_Class
        arcpy.ASCII3DToFeatureClass_3d(txtList, inFormat, outFC, outType, 
                                     zFactor, CS, fileSuffix, decSep)

except arcpy.ExecuteError:
    print arcpy.GetMessages()
except:
    # Get the traceback object
    tb = sys.exc_info()[2]
    tbinfo = traceback.format_tb(tb)[0]
    # Concatenate error information into message string
    pymsg = 'PYTHON ERRORS:\nTraceback info:\n{0}\nError Info:\n{1}'\
          .format(tbinfo, str(sys.exc_info()[1]))
    msgs = 'ArcPy ERRORS:\n {0}\n'.format(arcpy.GetMessages(2))
    # Return python error messages for script tool or Python Window
    arcpy.AddError(pymsg)
    arcpy.AddError(msgs)
0 Kudos
Luke_Pinner
MVP Regular Contributor
GDA 1994 MGA Zone 55 is a projected (UTM) coordinate system not geographic.
0 Kudos
BobMCkay
New Contributor III
Hi

First of all I'm using 10.0.
When I run the code at the bottom I get the following result;

PythonWin 2.6.5 (r265:79096, Mar 19 2010, 21:48:26) [MSC v.1500 32 bit (Intel)] on win32.
Portions Copyright 1994-2008 Mark Hammond - see 'Help/About PythonWin' for further copyright information.
Traceback (most recent call last):
  File "C:\Python26\Lib\site-packages\Pythonwin\pywin\framework\scriptutils.py", line 326, in RunScript
    exec codeObject in __main__.__dict__
  File "M:\GIS\LidarProd\XYZToFeature\XYZ to Feature Missing 90Ml Beach 20062014\XYZ_3DfeatureclassArcPyVers.py", line 8, in <module>
    import arcpy, os
  File "C:\Program Files\ArcGIS\Desktop10.0\arcpy\arcpy\__init__.py", line 17, in <module>
    from geoprocessing import gp
  File "C:\Program Files\ArcGIS\Desktop10.0\arcpy\arcpy\geoprocessing\__init__.py", line 14, in <module>
    from _base import *
  File "C:\Program Files\ArcGIS\Desktop10.0\arcpy\arcpy\geoprocessing\_base.py", line 568, in <module>
    env = GPEnvironments(gp)
  File "C:\Program Files\ArcGIS\Desktop10.0\arcpy\arcpy\geoprocessing\_base.py", line 565, in GPEnvironments
    return GPEnvironment(geoprocessor)
  File "C:\Program Files\ArcGIS\Desktop10.0\arcpy\arcpy\geoprocessing\_base.py", line 521, in __init__
    self._refresh()
  File "C:\Program Files\ArcGIS\Desktop10.0\arcpy\arcpy\geoprocessing\_base.py", line 523, in _refresh
    envset = (set(env for env in self._gp.listEnvironments()))
RuntimeError: NotInitialized
>>>

What isn't initialised?
I also noticed that arcpy.SpatialReference() didn't have SpatialReference appear in the list that is normally there after typing the dot (Whatever that is called)

Cheers


'''****************************************************************************
Name: ASCII3D_to_Feature_Class Example
Description: This script demonstrates how to use the 
             ASCII3D_to_Feature_Class tool to create a point feature class
             from a set of text files in the specified workspace.
****************************************************************************'''
# Import system modules`
import arcpy, os
from arcpy import env
import exceptions, sys, traceback

try:
    prjFile = os.path.join(arcpy.GetInstallInfo()["InstallDir"],
                           "M:/GIS/ArcGIS 10 Coordinate System Files and Projections/ArcGIS 10 Coordinate System Files and Projections/Coordinate Systems/Projected Coordinate Systems/National Grids/Australia/GDA 1994 MGA Zone 55.prj")
    CS = arcpy.SpatialReference(prjFile)
    # Obtain a license for the ArcGIS 3D Analyst extension
    arcpy.CheckOutExtension("3D")
    # Set environment settings
    env.workspace = "M:/GIS/LidarProd/XYZToFeature/Missing Lidar from DSE 21022013/elevation/cep2007-08_srw-90mb/regular_surface/dem_ground/xyz_ascii"
    # Set Local Variables
    inFormat = "XYZ"
    # Name of the output file
    outFC = "90MileBeachPts_from_ASCII.shp"
    # Geometry of the output feature class
    outType = "MULTIPOINT"
    zFactor = 1
    # Coordinate system of the output feature class
    #CS = "Geographic Coordinate Systems/GDA 1994 MGA Zone 55.prj"
    fileSuffix = "mga55.xyz" 
    decSep = "DECIMAL_POINT" # Specifies the decimal delimeter
    # Create list of ASCII files
    txtList = arcpy.ListFiles("*" + fileSuffix)
    # Verify the presence of TINs in the list
    if len(txtList) > 0:
        # Execute ASCII3D_to_Feature_Class
        arcpy.ASCII3DToFeatureClass_3d(txtList, inFormat, outFC, outType, 
                                     zFactor, CS, fileSuffix, decSep)

except arcpy.ExecuteError:
    print arcpy.GetMessages()
except:
    # Get the traceback object
    tb = sys.exc_info()[2]
    tbinfo = traceback.format_tb(tb)[0]
    # Concatenate error information into message string
    pymsg = 'PYTHON ERRORS:\nTraceback info:\n{0}\nError Info:\n{1}'\
          .format(tbinfo, str(sys.exc_info()[1]))
    msgs = 'ArcPy ERRORS:\n {0}\n'.format(arcpy.GetMessages(2))
    # Return python error messages for script tool or Python Window
    arcpy.AddError(pymsg)
    arcpy.AddError(msgs)
0 Kudos
BobMCkay
New Contributor III
Hi,

I placed the appropiate prj file in the workspace. I also placed the xyz data files directly in the workspace.
It then was asked for an average_point_spacing.
I used 2.0 and it all worked.


The figures I had to set the point_spacing;

Avg. Point Density: 0.5 pts/m
Footprint Size: 0.32m

I used the first one to assume the value of 2.0m, Am I correct?

Cheers and many thanks


'''**************************************************************************** Name: ASCII3D_to_Feature_Class Example Description: This script demonstrates how to use the               ASCII3D_to_Feature_Class tool to create a point feature class              from a set of text files in the specified workspace. ****************************************************************************''' # Import system modules` import arcpy, os from arcpy import env import exceptions, sys, traceback  try:     #prjFile = os.path.join(arcpy.GetInstallInfo()["InstallDir"],     #                       "M:/GIS/ArcGIS 10 Coordinate System Files and Projections/ArcGIS 10 Coordinate System Files and Projections/Coordinate Systems/Projected Coordinate Systems/National Grids/Australia/GDA 1994 MGA Zone 55.prj")     #CS = arcpy.SpatialReference(prjFile)     # Obtain a license for the ArcGIS 3D Analyst extension     arcpy.CheckOutExtension("3D")     # Set environment settings     env.workspace = "M:/GIS/data"     # Set Local Variables     inFormat = "XYZ"     # Name of the output file     outFC = "90MileBeachPts_from_ASCII.shp"     # Geometry of the output feature class     outType = "MULTIPOINT"     zFactor = 1     # Coordinate system of the output feature class     CS = "GDA 1994 MGA Zone 55.prj"     fileSuffix = "mga55.xyz"      decSep = "DECIMAL_POINT" # Specifies the decimal delimeter     # Create list of ASCII files     txtList = arcpy.ListFiles("*" + fileSuffix)     # Verify the presence of TINs in the list     if len(txtList) > 0:         # Execute ASCII3D_to_Feature_Class         arcpy.ASCII3DToFeatureClass_3d(txtList, inFormat, outFC, outType,                                       zFactor,CS, 2.0, fileSuffix, decSep)  except arcpy.ExecuteError:     print arcpy.GetMessages() except:     # Get the traceback object     tb = sys.exc_info()[2]     tbinfo = traceback.format_tb(tb)[0]     # Concatenate error information into message string     pymsg = 'PYTHON ERRORS:\nTraceback info:\n{0}\nError Info:\n{1}'\           .format(tbinfo, str(sys.exc_info()[1]))     msgs = 'ArcPy ERRORS:\n {0}\n'.format(arcpy.GetMessages(2))     # Return python error messages for script tool or Python Window     arcpy.AddError(pymsg)     arcpy.AddError(msgs)
0 Kudos