GridIndexFeatures - syntax error

1208
7
Jump to solution
12-07-2012 06:35 AM
nimitz
by
Frequent Contributor
Hi all,
I am trying to create a grid with this GridIndexFeatures tool. I keep getting a syntax error on the parameter for the "polygonWidth" and "polygonHeight".
I'm doing this in IDLE: here is what I got so far:
###script for the intersection of the 2 shapefiles ###  ###import the basic mods for the geoprocessor  import arcpy, sys, os, traceback, math, string  ###set up the workspace you're going to work in  from arcpy import env  arcpy.env.workspace = "C:\GIS_Data\PGE_MLPP\intergrid.shp"  #set local variable outFeatureClass = "intersection" inFeatures = "NonAOC" polygonWidth = "528 feet" polygonHeight = "528 feet"  ###Execute the Grid  arcpy.GridIndexFeatures_cartography(outFeatureClass, inFeatures, "", "", "",                                     polygonWidth, polygonHeight)  ###Print print "Done"   


Here is the error:
Traceback (most recent call last):
  File "C:/Users/RLong/Documents/intersect1", line 23, in <module>
    polygonWidth, polygonHeight)
  File "C:\Program Files\ArcGIS\Desktop10.0\arcpy\arcpy\cartography.py", line 787, in GridIndexFeatures
    raise e
ExecuteError: Failed to execute. Parameters are not valid.
ERROR 000732: Input Features: Dataset NonAOC does not exist or is not supported
ERROR 000398: Value must be positive
ERROR 000398: Value must be positive
ERROR 000892: The numeric value is outside of the valid range.
ERROR 000892: The numeric value is outside of the valid range.
Failed to execute (GridIndexFeatures).


I've done this script (and variants of it) several times, but SINCE I'VE INSTALLED SP5 this is happening. just sayin...

Any help is apprecieated.
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
T__WayneWhitley
Honored Contributor
Yes I saw that too... try specifying the output file with the '.shp' extension.  If you're still having problems, post your code again.

...and what is 'NonAOC' - your input will come from your workspace as well, shouldn't it have a '.shp' file extension too?  Does it exist?  If you're intent is to pull inputs from elsewhere, then you need to specify that.

View solution in original post

0 Kudos
7 Replies
T__WayneWhitley
Honored Contributor
Your workspace setting doesn't look right - it is set to your shapefile in the sample code you posted...
0 Kudos
nimitz
by
Frequent Contributor
Your workspace setting doesn't look right - it is set to your shapefile in the sample code you posted...

Bear with me, but should I just truncate the file path? I want to place the resultant grid in the directory...

Thx,

oops...I just tried to truncate the file path and "EOL -String Literal error popped up"

Maybe I should set up a GEODB and do it that way? It seems like I can have a safe workspace in the GEODB.
0 Kudos
T__WayneWhitley
Honored Contributor
It can be the root, say (if that folder exists):

env.workspace = r"C:\GIS_Data\PGE_MLPP"

...or you can designate, say for example, a file gdb (if it exists as well):

env.workspace = r"C:\GIS_Data\PGE_MLPP\stage.gdb"


EDIT:  Just one more thing, what is 'intergrid.shp'?  When you set the workspace, remember that is where inputs will be read, and outputs will be written - unless otherwise specified.  In other words, your script will look for inFeatures from your workspace and write the result, intersection, there --- which I note, if your workspace is set to a folder, you need to specify a shapefile, intersection.shp.
0 Kudos
nimitz
by
Frequent Contributor
Thanks Wayne. I tried the root folder and that error has stopped, HOWEVER, the original error about the "polygonWidth" and "polygonHeight" is still coming up
File "C:/Users/RLong/Documents/intersect1", line 23, in <module>
    polygonWidth, polygonHeight)


I don't get it. Should the "intersect1" be the resultant file? I did not create it.
0 Kudos
T__WayneWhitley
Honored Contributor
Yes I saw that too... try specifying the output file with the '.shp' extension.  If you're still having problems, post your code again.

...and what is 'NonAOC' - your input will come from your workspace as well, shouldn't it have a '.shp' file extension too?  Does it exist?  If you're intent is to pull inputs from elsewhere, then you need to specify that.
0 Kudos
nimitz
by
Frequent Contributor
Wayne,
You're right, I had to put the ".shp" extension.

Worked like a charm...

Many thanks and 1,000 karma points for you!
0 Kudos
T__WayneWhitley
Honored Contributor
That's great...
Have a good weekend!

-Wayne
0 Kudos