|
POST
|
I see you are on a newer OS than XP, so here is my scheduled task action that works in win7. [ATTACH=CONFIG]24984[/ATTACH] and this is the contents of the oracle.bat file:
cd C:\Python27\ArcGIS10.1
Python C:\arcgisserver\python\oracle.py
Exit
This is working for me. Also, if you are opening Notepad on execute, then I'd bet that your file association has changed somehow (maybe editing .py files in Notepad?). In windows explorer, if you right-click on a .py file and select Properties, on the General tab, it should say Type of file : PY File (.py) Opens with: (If this says Notepad, there is the issue), needs to be python. However, since I am on a 64 bit machine with server, both 32 and 64 bit versions are on my computer, so, in order to get it to run the 32 bit (so I have access to catalog paths), I have the Opens with set to idle.bat (which is this one C:\Python27\ArcGIS10.1\Lib\idlelib\idle.bat), otherwise it trys to run in 64 bit IDE. R_
... View more
06-04-2013
10:53 AM
|
0
|
0
|
3488
|
|
POST
|
I have always had best luck with the scheduler if I set up a batch file that runs my script, then schedule the batch file. my batch files that work on version 10.0 machine is: C:
cd C:\Python26\ArcGIS10.0
Python D:\baks\dont_use\compact1.py
Exit Then just navigate to this bat file in the task scheduler. Will fill in the "Start in" box for you. Just make sure the path is correct for your python, and script. R_[ATTACH=CONFIG]24974[/ATTACH]
... View more
06-04-2013
08:22 AM
|
0
|
0
|
3488
|
|
POST
|
Do you happen to be using the buffer tool in your script? The reason I ask is that I have some python scripts that have been running just fine for a couple years now. Starting 5/29, they all of a sudden started crashing on my buffer operation. No errror, even have a try:/except: and it doesn't catch it. if in IDE, it just "resets" and sits there quitely. Not sure if related to Microsoft updates or what. Still working on this one, just thought I'd ask since the timing is so similar. R_
... View more
06-04-2013
07:53 AM
|
0
|
0
|
4258
|
|
POST
|
I too would be interested in the source once you get it working correctly. for now, on initial load: TypeError: Error #1034: Type Coercion failed: cannot convert mx.controls::VSlider@192b20a1 to spark.components.supportClasses.SliderBase.
at spark.components.supportClasses::SkinnableComponent/skin_propertyChangeHandler()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at mx.core::UIComponent/dispatchEvent()
at widgets.Navigation::NavigationSkin/set slider()
at widgets.Navigation::NavigationSkin/_NavigationSkin_VSlider1_i()
at mx.core::DeferredInstanceFromFunction/getInstance()
at mx.states::AddItems/createInstance()
at mx.states::AddItems/initialize()
at mx.states::State/http://www.adobe.com/2006/flex/mx/internal::initialize()
at mx.core::UIComponent/initializeState()
at mx.core::UIComponent/commitCurrentState()
at mx.core::UIComponent/commitProperties()
at spark.components.supportClasses::GroupBase/commitProperties()
at spark.components::Group/commitProperties()
at mx.core::UIComponent/validateProperties()
at mx.managers::LayoutManager/validateProperties()
at mx.managers::LayoutManager/doPhasedInstantiation()
at mx.managers::LayoutManager/doPhasedInstantiationCallback()
at flash.utils::Timer/_timerDispatch()
at flash.utils::Timer/tick()
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at widgets.Search::SearchWidget/clear()
at widgets.Search::SearchWidget/widgetOpenedHandler()
at widgets.Search::SearchWidget/__wTemplate_open()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at mx.core::UIComponent/dispatchEvent()
at com.esri.viewer::WidgetTemplate/set widgetState()
at com.esri.viewer::BaseWidget/initWidgetTemplate()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at mx.core::UIComponent/dispatchEvent()
at mx.core::UIComponent/set initialized()
at mx.managers::LayoutManager/doPhasedInstantiation()
at mx.managers::LayoutManager/doPhasedInstantiationCallback() Then, if I continue with the debugger window, once I click "Build Rendering", I get: TypeError: Error #1009: Cannot access a property or method of a null object reference.
at widgets.App3d::App3dWidget/show3D()
at widgets.App3d::App3dWidget/__showBtn_click() Then it renders the layer.. R_ IE version 8.
... View more
06-03-2013
01:11 PM
|
0
|
0
|
2097
|
|
POST
|
If using 10.1, the arcpy.da.walk function will give you the dirpath, dirnames, and filenames of all FC/files in a workspace that match your filter: http://resources.arcgis.com/en/help/main/10.1/index.html#//018w00000023000000 Otherwise, you can use os.path.basename to get these: >>> Input = r'\\ITDNAS\MapLibrary\Photos\RRpics\058721Nn.jpg'
>>> filename = os.path.basename(Input)
>>> os.path.basename(os.path.dirname(Input))
'RRpics'
>>> os.path.basename(os.path.dirname(os.path.dirname(Input)))
'Photos'
>>> filename
'058721Nn.jpg'
>>> R_
... View more
06-03-2013
12:10 PM
|
0
|
0
|
3089
|
|
POST
|
Does anybody have any ideas on how to speed this up?
import arcpy
import os
import types
from arcpy import env
#get Parameters from toolbox
#-For Use with Script Toolbox
#inPts = arcpy.getparameterastext(0)
#Animalfield=arcpy.getparameterastext(1)
#SortField=arcpy.getparameterastext(2)
#-For Troubleshooting
inPts = "C:\ArcGIS\Temp\Tester.shp"
AnimalField = "AnimalNum"
SortField = "MSTTime"
#Add Field
print "Beginning:"
arcpy.AddField_management(inPts,"LAST_PNT","TEXT",)
ThesortString = AnimalField + " A; " + SortField + " D"
# Apply Sort
rows = arcpy.UpdateCursor(inPts,"","","",ThesortString)
print "Finished Sorting"
thecount = arcpy.GetCount_management(inPts).getOutput(0)
i=0
lastRow = "Starter"
for row in rows:
print i
i=i+1
#print str(count)
#thecount = thecount - 1
if row.getValue(AnimalField) == lastRow:
row.setValue("LAST_PNT","FALSE")
lastRow=row.getValue(AnimalField)
rows.updateRow(row)
else:
row.setValue("LAST_PNT","TRUE")
lastRow=row.getValue(AnimalField)
rows.updateRow(row)
del row
del rows
In my 10.1 scripts, I do use the da.searchcursor, but in this case, I really don't see a noticable improvement in speed. ALSO, there is a bug/known limitation in the da.UpdatCursor and will not work on non SDE registered database. Also, this original SearchCursor is much easier to code. As far as speeding things up, comment out/remove your print statements, especially the ones inside a loop. doesn't seem like that would be much of a load, but I have scripts that take orders of magnitude longer to run with my debugging print statements than without them. I comment out all print statements once the script is running right. Actually, I put something similar to this in my scripts: debug = "n"
if debug == "y":print "Processing ",infc
That way, I just change the value of debug if I want it to print my statements or not. Of course, even faster if you do the cursor/sort/grab first/last value and assign to variable in one swoop as in my previous post. R_
... View more
06-03-2013
12:01 PM
|
0
|
0
|
2292
|
|
POST
|
Can use a sort field in the Cursors. Below sorts by OID (so the table order is maintained) then sets the variable equal to the last or first table ojbect, depending on which you use. Handy for grabbing fist/last or max/min (just change sort field) values in a table. lastValue = arcpy.SearchCursor(infc, "", "", "", OID + " D").next().getValue(myField) #Get 1st row in cursor - gets last value based on OID
firstValue = arcpy.SearchCursor(infc, "", "", "", OID + " A").next().getValue(myField) #Get last row in cursor - gets first value based on OID R_
... View more
06-03-2013
11:46 AM
|
0
|
0
|
2292
|
|
POST
|
strftime actually has a bunch of directives you can use. See here for the list http://www.tutorialspoint.com/python/time_strftime.htm R_
... View more
06-03-2013
11:31 AM
|
0
|
0
|
1728
|
|
POST
|
have used this version in 3.1 and 3.3. Think it was working in 3.0 also. R_
... View more
06-03-2013
09:19 AM
|
0
|
0
|
2159
|
|
POST
|
Alex, Could use a little more clarification here. So, first of all, are you saying that you want one pdf exported for each FC in your layer or one for each species_ID? IOW, for species_ID = 1, it returns 150 records. Do you want one pdf created that shows all 150 features in the extent, or do you actually want 150 pdf documents, one for each of the species_ID=1 features? (based on last repsonse, I assume you really don't need separate mxd's, just as long as you have separate PDF's ?) Also, need to clarify if you are searching/def query on the voila layer or the poles layer as this code applies it to the cult.shp layer??? need to iterate through the layer you are actually applying query to. As is, will set the definitionQuery on a layer "poles" in DF "Layers" to the value of "voila" from the cult.shp layer attribute table. I normally SearchCursor the same FC I'm applying the definition query to, that way there is always a "match". import arcpy, os
shape = r"K:\Working\Alex_Gole\cult.shp"
output = r"K:\Working\Alex_Gole\test\"
output = "in_memory\" ## to save temp pdf "in memory" to save filespace and speed. Not sure if this will work for the pdf tool. If not, delete unless you need individual PDF's after appending.
finalPdf = arcpy.mapping.PDFDocumentCreate(os.path.join(output, "All.pdf")) #ADJUST FILE PATH METHOD
mxd = arcpy.mapping.MapDocument(r"K:\Working\Alex_Gole\Try_new.mxd")
#MyList = [3, 4, 5, 6, 7]
#for values in MyList:
# whereclause = '"voila"' "= " + str(values) ### this is actually setting your whereclause = "voila" = 7 as it is the last in your list, and there is nothing else to "do" here...
dfs = arcpy.mapping.ListDataFrames(mxd, "Layers")[0] ## Have to adjust if you need the query, etc. on more than one dataframe
titleElem = arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT","Figure name")[0] ## Assuming you have created a text element in mxd with Element Name = "Figure name"
labelElem = arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT","Label")[0] ## Assuming you have created a text element in mxd with Element Name = "Label"
lyr1 = arcpy.mapping.ListLayers(mxd, "poles", dfs)[0] ## Have to adjust if you need the query, etc. on more than one dataframe
sCur = arcpy.SearchCursor(shape)
for row in sCur:
voila_var = str(row.getValue(voila))
letter_var = str(row.getValue(Letter))
fid_var = row.getValue(FID)
whereclause = '"voila" = \'' + voila_var + "' ## creates PDF for each macthing FC
#whereclause = '"FID" = ' + str(fid_var) ## comment out other whereclause and use this one to create PDF for EACH FC, regardless of voila value.
titleElem.text = voila_var
labelElem.text = letter_var
lyr1.definitionQuery = whereclause ## This actually puts defquery on the poles layer using the cult.shp values??
mxd.save() ## need to save chages to mxd before you export to PDF or changes won't be represeted.
#Export each theme to a temporary PDF and append to the final PDFprint "export to pdf"
tmpPdf = os.path.join(output, voila_var + ".pdf") #ADJUST FILE PATH METHOD
arcpy.mapping.ExportToPDF(mxd, tmpPdf, resolution=240)
finalPdf.appendPages(tmpPdf)
print "All done."
del mxd If this workflow doesn't get you on the right track, let us know the other specifics. Have not tested this specifically, but is right our of one of my working scripts, so the basic structure should work. Might have to adjust variable names, syntax, etc., R_
... View more
06-03-2013
09:14 AM
|
0
|
0
|
1598
|
|
POST
|
MayMay, Could be wrong, but I thought I remembered a post by Robert that said he used the pagingQueryTask for his uniquvaluesfromfield as it gets past the limitation by the server. I know in eSearch, I can get way more results that the service is set to. R_
... View more
06-03-2013
08:19 AM
|
0
|
0
|
1841
|
|
POST
|
Marc, This code seems to be working just fine: import arcpy
# Local variables:
temp = "D:\\temp"
ExampleTest__csv = "C:\\Documents and Settings\\rkzufelt\\Desktop\\ExampleTest .csv"
ExampleTest_CopyRows = "in_memory\\ExampleTest_CopyRows"
ExampleTestLayer = "ExampleTestLayer"
# Process: Copy Rows
arcpy.CopyRows_management(ExampleTest__csv, ExampleTest_CopyRows, "")
# Process: Make XY Event Layer
arcpy.MakeXYEventLayer_management(ExampleTest__csv, "Xcoordinaat_RD_", "Ycoordinaat_RD_", ExampleTestLayer, "", "")
# Process: Feature Class To Shapefile (multiple)
arcpy.FeatureClassToShapefile_conversion("ExampleTestLayer", temp) However, I need to make your csv file a "valid" input file first. ESRI tools do not allow special characters in the column headings. So, once I stripped out the spaces and parrenthesis from your header row, all works as expected. It sounds like maybe you are stuck with a particular input filetype/format? If so, you might put some code in there that reads into memory (if you don't want to make a separate copy), but "filters" the results before writing (like don't copy the first three lines, then filter the column heading similar to: input_line = input_line.replace('(','_').replace(')','_').replace(' ','') to strip the bad chars). The above code isn't actually using the copyRows, the MakeXYEverntLayer works just fine on the "cleaned up" csv file, put the copyRows in there as an example of reading into arcpy's in_memory workspace. In the above code, the CopyRows is making an object that isn't used, change the input to the MakeEventLayer tool to the output of the CopyRows in order to utilize the copy vs the original. R_
... View more
06-03-2013
08:12 AM
|
0
|
0
|
4814
|
|
POST
|
If you have that raster assigned to an active variable, it will often lock that dataset. I.e, MyRast = "\\\\wc98466\\D\\baks\\temp.gdb\\MyRaster"
or
sCur = arcpy.SearchCursor( "\\\\wc98466\\D\\baks\\temp.gdb\\MyRaster")
could both lock my dataset to where I can't remove it. So, one has to delete the variable first, that will (or supposed to) remove the lock and let you clobber it (or delete it, for some reason, you can't overwrite some objects, and need to be deleted, then replaced). MyRast = "\\\\wc98466\\D\\baks\\temp.gdb\\MyRaster"
or
sCur = arcpy.SearchCursor( "\\\\wc98466\\D\\baks\\temp.gdb\\MyRaster")
del MyRast
del sCur
Just a thought, R_ Also, if the raster is within a feature dataset in the FGDB, if ANY objects from that feature dataset are in use, it will put a lock on the ENTIRE feature dataset. Can get around this issue by just having them in the base level in the FGDB. Also2, since these are temporary rasters that you are trying to clobber each loop, have you tried storing them as in_memory objects? ("in_memory/TmpRaster") rather than taking time to write to disk? (some tools won't allow this IE, projectRaster)
... View more
05-30-2013
03:04 PM
|
0
|
0
|
3397
|
|
POST
|
That works if you want year_Minutes_day_hour_minutes_seconds. If you want Month_Day_year, something like this works:
>>> from time import strftime
>>> stamp = datetime.datetime.now().strftime("%Y_%M_%d_%H%M%S")
>>> stamp
'2013_56_30_155604'
>>>
>>> dt = strftime("%m_%d_%Y %H:%M:%S")
>>> dt
'05_30_2013 15:56:17'
>>>
>>> dt = strftime("%m_%d_%Y")
>>> dt
'05_30_2013' R_
... View more
05-30-2013
02:57 PM
|
0
|
0
|
1728
|
|
POST
|
Basically you are telling it to create a "copy" of the OutRaster file named outCon and changing the values in it depending on your where clause (looks at each cell of conditional raster and assigns a value based on clause). So, it will create a raster the same size/extent of the OutRaster as it evaluates all cells in the conditional raster layer. To match the extent of the gR raster, you could try the arcpy.env.mask = gR setting before the con statement as SA tools are all supposed to honor masks: http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//001w0000001t000000 If you have problems with mask, another way would be to clip the OutRaster to the extend of the gR raster before the con statement. R_
... View more
05-30-2013
02:41 PM
|
0
|
0
|
788
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 05-14-2026 04:00 PM | |
| 1 | 09-14-2022 07:53 AM | |
| 1 | 09-14-2022 08:23 AM | |
| 1 | 05-21-2026 08:53 AM | |
| 1 | 05-14-2026 04:28 PM |
| Online Status |
Online
|
| Date Last Visited |
Wednesday
|