Dumb question - can I write standalone python script to run without arcgis?

8150
31
05-18-2010 11:54 PM
jimparsons
New Contributor III
I need to open a raster, thin it, and save it. Can I do that in a script outside of arcgis, or does arcgis need to be running for the script to work? I have it installed on the system, so it would obviously be running on my computer.

Sorry this question is really simple. I don't really understand how to run a script outside of arcgis...or even if it's possible. I'm hoping someone will say yes or no! Thanks
0 Kudos
31 Replies
DannyLackey
New Contributor II
Found a piece to grab the area I want...again, works in ArcGIS, but not from cmd window.

import arcpy
mxd=arcpy.mapping.MapDocument("I:\GIS_Workspace\Ventura_Area\Danny\SAPTList.mxd")
mainDF = arcpy.mapping.ListDataFrames(mxd, "Layers") [0]
mainDF.zoomToSelectedFeatures()
arcpy.RefreshActiveView();arcpy.RefreshTOC()
arcpy.mapping.ExportToPDF (mxd,"I:\GIS_Workspace\Ventura_Area\Danny\SAPT_MAP.pdf")

I get an invalid syntax error in CMD window.
0 Kudos
RaphaelR
Occasional Contributor II
your paths won´t be read correctly by python at the moment:
you have to use one of these ways, simple backslashes won´t work:
"c:\\path1\\path2"
"c:/path1/path2"
r"c:\path1\path2"

import arcpy
mxd=arcpy.mapping.MapDocument(r"I:\GIS_Workspace\Ventura_Area\Danny\SAPTList.mxd")
mainDF = arcpy.mapping.ListDataFrames(mxd, "Layers") [0]
mainDF.zoomToSelectedFeatures()
arcpy.RefreshActiveView();arcpy.RefreshTOC()
arcpy.mapping.ExportToPDF (mxd,r"I:\GIS_Workspace\Ventura_Area\Danny\SAPT_MAP.pdf")
0 Kudos