Select to view content in your preferred language

Variable question

1902
8
12-06-2011 11:04 AM
by Anonymous User
Not applicable
Original User: luke.kaim

I am getting errors when I run this bit of code and can not figure out why. Is this because of the variables I am using?

import arcpy, sys, os, re, time
from arcpy import env
from arcpy.sa import *
import arcpy
print "Start time = " + time.asctime()
arcpy.env.overwriteOutput = True
arcpy.env.workspace = "C:\\Users\\Luke Kaim\\Documents\\university_of_maine\\research4\\test7"

# Check out any necessary licenses
arcpy.CheckOutExtension("spatial")




APPROACH_ContourLine_Clip="C:\\Users\\Luke Kaim\\Documents\\university_of_maine\\research4\\test5\\APPROACH_HARBOR_DEPCNT_line.shp"

# Check out any necessary licenses
arcpy.CheckOutExtension("spatial")

APPROACH_ContourLine_Project_shp = "APPROACH_ContourLine_Project.shp"
Generalize_ContourLine5meter_shp = "Generalize_ContourLine5meter.shp"
allinputpoints_shp = "allinputpoints2.shp"
test = "test.shp"





# Process: Simplify Line
arcpy.SimplifyLine_cartography(APPROACH_ContourLine_Clip, Generalize_ContourLine5meter_shp, "POINT_REMOVE", "5 Meters", "RESOLVE_ERRORS", "NO_KEEP", "CHECK")



# Process: Feature Vertices To Points
arcpy.FeatureVerticesToPoints_management(Generalize_ContourLine5meter_shp, test, "ALL")


# Process: Add Field (4)
arcpy.AddField_management(test, "input", "SHORT", "", "", "", "", "NON_NULLABLE", "NON_REQUIRED", "")

# Process: Calculate Field (4)
arcpy.CalculateField_management(test, "input", "4", "PYTHON_9.3", "")


print "start projection"


# Process: Project (5)
arcpy.Project_management(test, APPROACH_ContourLine_Project_shp, "PROJCS['NAD_1983_UTM_Zone_19N',GEOGCS['GCS_North_American_1983',DATUM['D_North_American_1983',SPHEROID['GRS_1980',6378137.0,298.257222101]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]],PROJECTION['Transverse_Mercator'],PARAMETER['False_Easting',500000.0],PARAMETER['False_Northing',0.0],PARAMETER['Central_Meridian',-69.0],PARAMETER['Scale_Factor',0.9996],PARAMETER['Latitude_Of_Origin',0.0],UNIT['Meter',1.0]]", "NAD_1983_To_WGS_1984_1", "GEOGCS['GCS_WGS_1984',DATUM['D_WGS_1984',SPHEROID['WGS_1984',6378137.0,298.257223563]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]]")

print "finsihed projection"
0 Kudos
8 Replies
by Anonymous User
Not applicable
Original User: mzcoyle

Importing arcpy twice can't be good for your health.

Other than that, try posting the errors you got and that may help narrow it down.
0 Kudos
by Anonymous User
Not applicable
Original User: luke.kaim

Thank you for the fast reply. I deleted import arcpy. Feature to vertices is not converting all line segments to points though.

This is the error I am getting. I also am attaching the data as well.

 
Traceback (most recent call last):
  File "C:/Users/Luke Kaim/Documents/university_of_maine/research4/contourlinesTEST.py", line 48, in <module>
    arcpy.Project_management(test, APPROACH_ContourLine_Project_shp, "PROJCS['NAD_1983_UTM_Zone_19N',GEOGCS['GCS_North_American_1983',DATUM['D_North_American_1983',SPHEROID['GRS_1980',6378137.0,298.257222101]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]],PROJECTION['Transverse_Mercator'],PARAMETER['False_Easting',500000.0],PARAMETER['False_Northing',0.0],PARAMETER['Central_Meridian',-69.0],PARAMETER['Scale_Factor',0.9996],PARAMETER['Latitude_Of_Origin',0.0],UNIT['Meter',1.0]]", "NAD_1983_To_WGS_1984_1", "GEOGCS['GCS_WGS_1984',DATUM['D_WGS_1984',SPHEROID['WGS_1984',6378137.0,298.257223563]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]]")
  File "C:\Program Files\ArcGIS\Desktop10.0\arcpy\arcpy\management.py", line 4927, in Project
    raise e
ExecuteError: Failed to execute. Parameters are not valid.
ERROR 000365: Invalid geographic transformation.
Failed to execute (Project).



Thank you
Luke Kaim (SIE)
Lucas.Kaim@maine.edu
(914)263-7866
�??Everything should be made as simple as possible, but no simpler�?� (Albert Einstein).
0 Kudos
ChrisSnyder
Honored Contributor
Transforming between NAD83 to WGS84 requires a datum transformation method, and it looks as if you are not supplying that parameter. If you are in the lower 48, "NAD_1983_To_WGS_1984_5" should work.

See: http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//003r00000010000000.htm
0 Kudos
by Anonymous User
Not applicable
Original User: mzcoyle

I don't see a geographic transformation defined, this is not optional in the projection you are doing.

Error code 000365

Project tool syntax

You may need this resource to help you choose the correct transformation.
0 Kudos
by Anonymous User
Not applicable
Original User: luke.kaim

That still does not work though.

# Process: Project (5)
arcpy.Project_management(test, APPROACH_ContourLine_Project_shp, "PROJCS['NAD_1983_UTM_Zone_19N',GEOGCS['GCS_North_American_1983',DATUM['D_North_American_1983',SPHEROID['GRS_1980',6378137.0,298.257222101]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]],PROJECTION['Transverse_Mercator'],PARAMETER['False_Easting',500000.0],PARAMETER['False_Northing',0.0],PARAMETER['Central_Meridian',-69.0],PARAMETER['Scale_Factor',0.9996],PARAMETER['Latitude_Of_Origin',0.0],UNIT['Meter',1.0]]", "NAD_1983_To_WGS_1984_1", "GEOGCS['GCS_WGS_1984',DATUM['D_WGS_1984',SPHEROID['WGS_1984',6378137.0,298.257223563]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]]")
0 Kudos
MathewCoyle
Honored Contributor
Try executing the projection you want in Arc using the Project tool, and copy the python snippet after it is run to see where there are differences.

Also, avoid using spaces in your file names or paths, that causes nothing but problems.
0 Kudos
by Anonymous User
Not applicable
Original User: luke.kaim

That is what I did.
0 Kudos
MathewCoyle
Honored Contributor
Try moving your workspace to something with a shorter path and no spaces.
0 Kudos