Quantcast
Channel: Forums - Python
Viewing all 2485 articles
Browse latest View live

Python script to derive new cells values from the current ones,

$
0
0
Python script to derive new cells values from the current ones,

I couldn’t figure out how to develop a code that change the values of cells based on If –Then statements.

Suppose that I got a raster where its cells have seven possible values:

1. water,
2. road,
3. commercial,
4. forest area,
5. residential areas,
6. pasture and
7. row crops

and I wanted to derive a new values for the current cells based on the rules below (Sharaf Alkheder and Jie Shan) considering 3x3 window:

1. IF tested pixel under consideration is water, THEN no growth is allowed at this pixel.
2. IF tested pixel under consideration is road, THEN no growth is allowed at this pixel.
3. IF tested pixel under consideration is residential OR commercial, THEN keep this pixel
the same without any change.
4. IF tested pixel under consideration is either (forest OR pasture OR row crops) AND
there are 4 commercial pixels in the neighborhood, THEN change tested pixel to
commercial.
5. IF tested pixel under consideration is either (forest OR pasture OR row crops) AND
there are 4 HEN change tested pixel to residential.


Then how such code can be developed? any hints?


Unfortunately, the built-in tools in the ArcGIS don't do this sort of work (such as focal statistics).


Attachment 23087

Thank you

Best

Jamal
Attached Thumbnails
Click image for larger version

Name:	Clip_710.jpg‎
Views:	N/A
Size:	91.8 KB
ID:	23087  

Traffic Data

$
0
0
I have written a script to attempt to download traffic data but it has shown some errors i have tried to rectify but returning the error.

Here is my script:
# Olawumi Lanlehin
import arcpy
from arcpy import env
#Set local variables
trafficIncidentsStorage = "G:/London_Street/TrafficIncidentsStorage.mdb"
print "OK"
incidentsFeatureClass = "TomTom_Europe_Incidents"
print "OK"
provider = "TomTom Europe"
username = "APIKEY"
password = "lonche8"
#download data
regions = "#"
print "Good"
timeZoneBoundaries = "G/London_Street/TimeZones/euroTimeZones"
timeZonesID = "GMTIMEZONE"
print "On Track"
try:
#Updatte Traffic Data. Use default values for remaining parameters
arcpy.na.UpdateTrafficIncidents(provider,username,password,regions,trafficIncidentsStorage,incidentsFeatureClass,timeZoneBoundaries,timeZonesID)
except Exception as e:
#if an error occured, print line number and error message
import traceback, sys
tb = sys.exc_info()[2]
print "Error in line %i" % tb.tb_lineno
print str(e)

and here is the error message:

Error in line 20
Failed to execute. Parameters are not valid.
ERROR 000732: Time Zone Boundaries: Dataset G/London_Street/TimeZones/euroTimeZones does not exist or is not supported
ERROR 000308: Invalid field type
Failed to execute (UpdateTrafficIncidents).

Help!



Regards,


Ola

CSV Field Types

$
0
0
Newbie to Python, but have written a script to concatenate multiple CSV files into one file and add a couple of computed fields. I was wondering if there is a way specify field types in python where the finished CSV file would not require a schema.ini file to import fields in the correct format such as: date, Long, Double and also control the field width.

script tool for df.time.currentTime ???

$
0
0
I'm getting this error when I run my script tool.


Traceback (most recent call last):
File "C:\Users\Courtney\Desktop\ScriptTool.py", line 233, in <module>
df.time.currentTime = arcpy.GetParameterAsText(6) #datetime.datetime(2009, 01, 1, 00, 00)
File "c:\program files (x86)\arcgis\desktop10.1\arcpy\arcpy\arcobjects\_base.py", line 92, in _set
(attr_name, self.__class__.__name__))
NameError: The attribute 'currentTime' is not supported on this instance of DataFrameTime.

Failed to execute (ScriptTool).

my code is :

df.time.currentTime = arcpy.GetParameterAsText(6) #datetime.datetime(2009, 01, 1, 00, 00)
endTime = arcpy.GetParameterAsText(7) #datetime.datetime(2009, 01, 1, 23, 59)
interval = arcpy.GetParameterAsText(8) #arcpy.time.EsriTimeDelta(1, 'hours')
#or #interval = datetime.timedelta(hours=1)

I don't understand why it says "currentTime" is not supported.

Any assistance is appreciated.

Thank you

New feature class and saving data

$
0
0
I'm very new to Python and I have a question about building an add-in for ArcMap. I've looked all over for a tutorials, but there are none that answer my question.

I would like to build an add-in where the user is prompted to click on the map and creates a new point. This point is then saved to a database. Any new points created after the first are then appended to the existing database. Eventually, I would like to make this function work with polygons as well. Unfortunately, I have no idea where to begin with this.

Any help would be greatly appreciated. Thanks!

Mulitvalue string parameter with drop-down list in Python Script Tool

$
0
0
I am trying to build a script tool using ArcGIS's 10.0 built-in python functionality. I have been trying to create a multiple value string parameter with a pre-determined set of values that each of the multiple values can take. For instance, I might give the user a value list including ['up', 'down', 'left', 'right'] and then in the tool dialog the user should be able to choose from that list multiple times, with repeats. For instance, the user might choose ['up', 'up', 'left'] as three separate inputs.

I cannot seem to get this to work. I do not want what ArcGIS considers a "MultiValue" "String" with a "Value List" filter. This only allows the user to select multiple values in the value list, without repeats.

Alternatively, I cannot get a satisfactory result when I create a "MultiValue" "String" with no filter. In this case, the user is completely unable to add to or remove values from the list (because, for some reason, the "Add Value" button is always disabled). How does that make any sense?

A third option, which I consider a huge failure if I have to resort to it, is to create two parameters, where the first parameter is a non-multivalue dropdown list and the second parameter is a multi-value string that successively appends choices from the first parameter to its values.

Is there a simple way to achieve what I am asking?

Intermittent error on CostDistance_sa loop-calculations

$
0
0
Hi All,

I'm newbie in python geoprocessing.
I created CostPath calculation permutations.
The problem is it runs sometimes and errors on different "set" of permutations.
It's an intermittent issues.. simillar like on this unanswered thread here [0].

Below are the codes:

Code:

# Import modules
import arcpy,os,time,itertools

############################################
#        USER DEFINED VARIABLES            #
############################################
# Unique ID, can not contains invalid chars
uniqueID = "Sumatera"

# Points
points = ['BandaAceh', 'Jambi', 'Bengkulu']

# References dir of cost surface - as cost surface input dir (#2)
cost_surface = "C:/Projects/CNG/CostSurface/costsurface" # Sumatera

# Environment workspace and set as input dir (#1)
arcpy.env.workspace = "C:/Projects/CNG/Source"

# Ouput dirs
baseOutput = "C:/Projects/CNG/Output-" + uniqueID + "/"

############################################
#      DO NOT EDIT BELOW THIS LINE        #
############################################

# Final output dissolved/merged shapefiles
OSHP = baseOutput + uniqueID + ".shp"

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

# Allow overwritten of output
arcpy.env.overwriteOutput = True

# Calculate number of posibly permutations
lengthCombinations = len(list(itertools.permutations(points, 2)))
i = 0

# Create output dirs
if not os.path.exists(baseOutput):
    os.makedirs(baseOutput)
    print "Creating folders Spatial ouput: " + baseOutput + "\n"
               
# Temp files / scratch workspace -- default settings
#CostDis_shp9 = "C:/Users/Billydekid/Documents/ArcGIS/Default.gdb/CostDis_shp9"
#COSTBACKLINK = "C:/Users/Billydekid/Documents/ArcGIS/Default.gdb/COSTBACKLINK"
#CostPat_shp6 = "C:/Users/Billydekid/Documents/ArcGIS/Default.gdb/CostPat_shp6"

print "START geoprocessing...\n"
print "------------"

#
# Permutations of each points
for comb in itertools.permutations(points, 2):
    i += 1
    print "Processing [" + str(i) + "/" + str(lengthCombinations) + "]: " + comb[0] + "-" + comb[1]
   
    SPath = comb[0] + ".shp"
    DPath = comb[1] + ".shp"
    ShpPath = baseOutput + comb[0] + comb[1] + ".shp"
    DissolvePath = baseOutput + comb[0] + comb[1] + "_dis.shp"
   
    CostDis_shp9 = "C:/Users/Billydekid/Documents/ArcGIS/Default.gdb/CostDis_shp9_" + str(i)
    COSTBACKLINK = "C:/Users/Billydekid/Documents/ArcGIS/Default.gdb/COSTBACKLINK_" + str(i)
   
    CostPat_shp6 = "C:/Users/Billydekid/Documents/ArcGIS/Default.gdb/CostPat_shp6_" + str(i)
   
    # Process: Cost Distance
    arcpy.gp.CostDistance_sa(SPath, cost_surface, CostDis_shp9, "", COSTBACKLINK)
   
    # Process: Cost Path
    costPath = arcpy.gp.CostPath_sa(DPath, CostDis_shp9, COSTBACKLINK, CostPat_shp6, "EACH_CELL", "FID")
   

   
    print "End Processing: " + comb[0] + "-" + comb[1] + "."
    print "------------"
    #====================================
    # END OF PERMUTATIONS LOOP
    #====================================

And the errors happens, like as follows:

Code:

START geoprocessing...

------------
Processing [1/6]: BandaAceh-Jambi
End Processing: BandaAceh-Jambi.
------------
Processing [2/6]: BandaAceh-Bengkulu
End Processing: BandaAceh-Bengkulu.
------------
Processing [3/6]: Jambi-BandaAceh
End Processing: Jambi-BandaAceh.
------------
Processing [4/6]: Jambi-Bengkulu
End Processing: Jambi-Bengkulu.
------------
Processing [5/6]: Bengkulu-BandaAceh
Cost Distance mapping Failed
Traceback (most recent call last):
  File "C:\Projects\CNG\permBestRoute_CNG_JawaSumatera2.py", line 113, in <module>
    arcpy.gp.CostDistance_sa(SPath, cost_surface, CostDis_shp9, "", COSTBACKLINK)
  File "C:\Program Files (x86)\ArcGIS\Desktop10.1\arcpy\arcpy\geoprocessing\_base.py", line 484, in <lambda>
    return lambda *args: val(*gp_fixargs(args, True))
arcgisscripting.ExecuteError: ERROR 999999: Error executing function.
Workspace or data source is read only.
Workspace or data source is read only.
The operation was attempted on an empty geometry.
ERROR 010029: Unable to create the raster C:\Users\Billydekid\Documents\ArcGIS\Default.gdb\CostDis_shp9_5. Cost Distance mapping Failed
ERROR 010067: Error in executing grid expression.
Failed to execute (CostDistance).

In my code above, I try to create each raster database on each permutations rather than only single table to prevent locking issues.

Or..

The error "Workspace or data source is read only." is related to my arcpy.env.workspace issue?

Anyone have ideas or hints for this problem?

Thanks in advance.

[bayu]

[0] http://forums.arcgis.com/threads/783...Dis_src_1-quot

select max value python or vb script

$
0
0
hello, i'am have some problem with my task. i want to try create model builder from my shp layer.
how to select max value in field prio with VB script or Pyhton in model builder ?

Attachment 23112
Attached Thumbnails
Click image for larger version

Name:	field.png‎
Views:	N/A
Size:	17.9 KB
ID:	23112  

Please read: How to post Python code

$
0
0
Please try to post code in code blocks in the forums.

This is especially important with Python scripts, as indentation is part of the syntax!

Here's how:

Method 1:

(This is the method to use in the forum's "WYSIWYG mode")

1. Paste your code
2. Select your code
3. Click the "#" button in the interface

([CODE][/CODE] "tags" will be inserted before and after the selection.)

Method 2:

(This method is more suited for old-school types who edit posts in "Source mode".)

1. Enter: [CODE] [/CODE]
2. Paste your code in between [CODE] and [/CODE]

Your post (in "source mode") should look something like this:

[CODE]
try:
import arcpy
except:
print "Houston, we've had a problem."
raise
[/CODE]

Now, click the Preview Post button at the bottom of the page to make sure you did it right. Your code should display in a code block widget:

Code:

try:
    import arcpy
except:
    print "We have a problem"
    raise

For more details on ArcGIS forum post formatting using BB codes (including some not included as buttons in the forum's "WYSYWYG mode") with examples, visit the BB Code List page. The ArcGIS forum supports most, but not all, of these BB codes.

Thank you!

Python calculates incorrect date

$
0
0
Using the python expression time.strftime("%d/%m%Y"), my date is calculated as 12:00 am. If I drop off the day and month variables, i.e. time.strftime("%Y"), I get the date claculated as July 5, 1905. Any ideas why this might be happeneing and how I can restore the calculation to the current date.

copy user privilege / role access to gis object across database

$
0
0
Hi,

I can use python to copy dataset , feature class, table from one database to another database using a script similar to this article :

http://support.esri.com/en/knowledge...s/detail/40831

My question is : is there anyway through python I can "copy" the privilege / role access to the object which i copied across the databases as well ? (providing that the user,role already defined in both database)

Thank you in advance for any pointers.

Michael

Clipping a raster and renaming it

$
0
0
I am still pretty much a beginner when it comes to python, so go easy on me. I am trying to clip a raster to a tiled polygon layout. I have a feeling that my errors: ERROR 000628: Cannot set input into parameter rectangle. and Error 000622 are happening when I am trying to use the geometry of one feature to clip my raster, and then renaming it to that tile name in the "text" field.

Any help would be much appreciated, and please let me know if anything needs to be clarified.

Thanks!!

Code:

desc = arcpy.Describe(DEMpoly)
shapefieldname = desc.shapeFieldName

rowCursor = arcpy.SearchCursor(DEMpoly)

for row in rowCursor:
    feat = row.getValue(shapefieldname)
    arcpy.Clip_management(OUTraster, feat, row.getValue(Text) + ".img")
    cursor.next()

python version 2.7.3 usable?

$
0
0
The current documentation for 10.1 says that Python version 2.7 is compatible with ArcGIS, but does that mean 2.7.x? Wondering because I am thinking of installing the current version of GeanyPy, a Python plug-in for Geany -- text editor similar to PyScripter but with code folding =0, however missing interpreter functionality, hence GeanyPy. This plug-in requires the installation of Python 2.7.3, and will likely upgrade to 2.7.4 in the future (if it comes out). I need to know if ArcGIS 10.1 will like these newer flavors of 2.7 before I mess everything up. Thanks.

Delete dbf fields

$
0
0
I have a dbf table with four fields: OID,TYPE,FREQUENCY,COUNT.

I only want to keep TYPE. I got this script off this forum and modified it to fit my data but it is not working. Is that because it is a dbf file? It returns the correct fields for the "print field" command. Any other suggesestions?

Code:

test_dbf = "C:\\TempData\\testdata.dbf"

data_description = arcpy.Describe(test_dbf)
fields = [f.name for f in data_description.fields if f.type not in ["Geometry", "Raster", "Blob"]]

#fields = [f.name for f in arcpy.ListFields(test_dbf)  <> 'Geometry'] # This didn't work either
print fields

for i,f in enumerate(fields):
    if f == 'OID' or f == 'FREQUENCY' or f == 'COUNT':
        del fields[i]

Thank you in advance

Creating Polygons with MouseDown

$
0
0
I would like to create an add-in using the "onMouseDown" and create polygon shape files. I have done this with model builder, but I'm not sure how it works with Python. I exported the Python code from the model, but it still didn't seem correct. Has anyone had any experience creating custom polygons using mouse clicks? Thanks.

Facing Problem while Join managment through Python

$
0
0
Hi,

I am automating LAYER dissolve process through pyhthon almost done.But faced some strange thing today.

While running the python script from ARCMAP every thing is running fine(PFA screenshot), but when I am running same script from PYSCRIPTER or COMMAND Prompt. It shows me Error 000840.

While I am abel to loacte the new created Feature table through catalog, any Idea for same.

Following is the Script for same


# PermanentJoin.py
# Purpose: Join two fields from a table to a feature class
# Author: ESRI
# Import system modules
import arcpy
from arcpy import env
import os
import sys
# Set the local parameters
conStr=r"C:\Users\174314\AppData\Roaming\ESRI\Desktop10.1\ArcCatalog\SDE@ME5P.sde"
# Set the current workspace
env.workspace = conStr
levelNameIntial="AZ_US_"
alignment_id=111113
joinField = "ZIP"
joinTable = r"C:\PythonScripts\CSV\lilly_iAlign_10_qc.csv"
csvFileName="lilly_iAlign_10_qc.Csv."
fieldList = []
levelStartCounter=1
levelFielStartCounter=1
totLevel=5
mapEnviornment="QC"
alignmentDataJoinField="zip_code"
#outWorkspace = "c:/Output/output.gdb"
outWorkSpace=""
dissolveFieldName=""
alignmentDatotLeveltaJoinField="ZIP_CODE"
baseZipPoly='SDE.C_ZIP_POLY_2008_ESRI'
mxdFilePath=r'C:\GISWORKAREA\Python'
#Set Qualified name to fase for ommiting longer column name
env.qualifiedFieldNames = False
symbFilePath=r'C:\PythonScripts\Symbology'
connectionFilePath = r'C:\Users\174314\AppData\Roaming\ESRI\Desktop10.1\ArcCatalog\CTSUSADCGISPOC.ags'

def CreateFeatureDataSet(connectiontr,dataSetname):
print 'Feature Dataset creation process start'
sr=""
try:
sr = arcpy.Describe(baseZipPoly).spatialReference
arcpy.CreateFeatureDataset_management(conStr, dataSetname, sr)
except IOError:
print 'Fail to Create Dataset', sys.exc_info()[0]
print 'Feature Dataset creation process start Dataset Name-' + dataSetname

def CreateZipPoly(baseZipPoly,dissolveTableName):
print("ZIP Poly file Creation Start")
try:
arcpy.Copy_management(baseZipPoly,dissolveTableName)
#print(dissolveTableName)
except:
print "Unexpected error While copying ZIP Poly:", sys.exc_info()[0]
print("ZIP Poly file Creation End")


#Creating FeatureDatset


def JoinTable(dissolveTableName,joinField,joinTable, alignmentDataJoinField):
print("Joining Process Start" + dissolveTableName + joinTable)
try:
arcpy.AddJoin_management(dissolveTableName,joinField,joinTable, alignmentDataJoinField,"KEEP_COMMON")
except:
print "Unexpected error While Joining data:", sys.exc_info()[0]
raise
print 'Join process end'





dataSet_name = levelNameIntial + mapEnviornment + "_" + str(alignment_id)
outWorkSpace = os.path.join(conStr, dataSet_name)
dissolveTableName=levelNameIntial + mapEnviornment + "_ZIP_POLY_" + str(alignment_id)
dissolveTableName=os.path.join(outWorkSpace, dissolveTableName)

#Create Data Set
CreateFeatureDataSet(conStr,dataSet_name)


#Create a new ZIP Poly by copying from one existing please ensure baseZipPoly is exist on current schema
CreateZipPoly(baseZipPoly,dissolveTableName)

#Append SDE in front of Dissolve Table for join process
dissolveTableName= "SDE." + levelNameIntial +mapEnviornment + "_ZIP_POLY_" + str(alignment_id)
#Join Process
JoinTable(dissolveTableName,joinField,joinTable, alignmentDataJoinField)
Attached Thumbnails
Click image for larger version

Name:	JOinError.PNG‎
Views:	N/A
Size:	16.9 KB
ID:	23121   Click image for larger version

Name:	AddJoinSuccess.jpg‎
Views:	N/A
Size:	76.7 KB
ID:	23122  

Update Cursor "Instance has no attribute" error

$
0
0
I am looking to use an Update Cursor over a feature layer in a map document to, well, update a handful of attributes. I seem to be getting an error that tells me the instance of my object does not have the attribute of the cursor's name...

Here is the problem code:

Code:

class Intersections():
    def __init__(self):
        self.path = arcpy.GetParameterAsText(1)
   
    def updateAttributes(self):
        self.intersections = arcpy.UpdateCursor(self.path)
        self.centerlines = Centerlines()

        arcpy.AddMessage("Updating node attributes...")
        try:
            for self.intersection in self.intersections:  #THIS IS WHERE IT FAILS


The error reads: Intersections instance has no attribute 'intersection'


Oddly enough, in the same script, I have this code that does work properly:

Code:

def __init__(self):
        self.path = arcpy.GetParameterAsText(2)

    def copyAttributes(self):
        self.addressRanges = arcpy.InsertCursor(self.path)
        self.centerline = Centerlines()
        self.centerlines = arcpy.SearchCursor(self.centerline.path)
        arcpy.AddMessage("Copying new address ranges...")
        try:
            for self.centerline in self.centerlines:


Thanks

EDIT: I was able to pinpoint the error, which was happening lower in the code. I was trying to delete the cursors, which did not exist at that point.

how to use pythonwx in python-addin

$
0
0
I am using Python-addin under ARCMAP10.1
I want to use Media player , i found pythonwx has window media player control. I have develop a program using that control.I want to add this code as python-addin in ARCMAP 10.1 but i do not know how to import wx in python-addin. any suggestion is appreciatedregards
nadeem

Esri python arcpy.da.UpdateCursor - create cursor has failed (script error)

$
0
0
Hi,

I'm working with the arcpy.da module for the first time and just trying to get a handle on how it operates. I have a PostgreSQL database with a simple table that includes these fields: id, field1, field2, field3, field4. At this point the table is not registered with the geodatabase or SDE (I want to do simple unversioned table edits). For the most part I've been trying to follow the ArcGIS 10.1 help examples.

I have been able to successfully use arpy.da.SearchCursor to list records. This works:

Code:

# List records using search cursor (snippet)
table_to_select_from = r"/home/engine/scripts/connections/ARCSDE101-DEV1-PG-DC-GDRS_DEV-GDRS-DEFAULT.sde\gdrs_dev.gdrs.test_arcpy_da"
field_list = ["id", "field1", "field2", "field3", "field4"]
try:
    with arcpy.da.SearchCursor(table_to_select_from, field_list) as search_cursor:
        for row in search_cursor:
            print("{0}, {1}, {2}, {3}, {4}".format(row[0], row[1], row[2], row[3], row[4]))
except Exception as err:
    print(err)
    exit(1)

I can also successfully insert new records using arcpy.da.InsertCursor:

Code:

# Insert record (snippet):
table_to_insert_into = r"/home/engine/scripts/connections/ARCSDE101-DEV1-PG-DC-GDRS_DEV-GDRS-DEFAULT.sde\gdrs_dev.gdrs.test_arcpy_da"
field_list = ["field1", "field2", "field3", "field4"]
values_list = ["Test arcpy.da.insertRow", "Hello World!", 10, "2013-03-23"]
try:
    with arcpy.da.InsertCursor(table_to_insert_into, field_list) as insert_cursor:
        insert_cursor.insertRow(values_list)
except Exception as err:
    print(err)
    exit(1)


So far so good. However when I attempt to update rows, I cannot successfully create an update cursor. The exception message: "create cursor has failed" is returned. I'm sure this is something simple, but I've been banging my head on it and hope you can help point me in the right direction. In this example I attempt to multiply the value in an integer field by 2:

Code:

table_to_update = r"/home/engine/scripts/connections/ARCSDE101-DEV1-PG-DC-GDRS_DEV-GDRS-DEFAULT.sde\gdrs_dev.gdrs.test_arcpy_da"
field_list = ["field3"]
try:
    with arcpy.da.UpdateCursor(table_to_update, field_list) as update_cursor:
        for row in update_cursor:
            row[0] = row[0] * 2
            update_cursor.updateRow(row)
        del row, update_cursor
except Exception as err:
    print(err)

the string object err which is printed is: "create cursor has failed"

I tried placing this block inside an arcpy.da.Editor block, but no change in the error result.

Any thoughts? Thank you!

SCRIPT TOOL ERROR - TRYING TO GET USER TO SPECIFY TIME FRAME ON DATA FRAME

$
0
0
Layer time is only read access. in order to specify the data frame time (ie time slider options) I need to be able to have the user
select the time frame they would like. Data frame time has read and write access bc the funtions are specified via the time slider
window.

my question is not how to change the layer time bc that is not possible. I want the user to select the dataframetime (time slider)
but my GetParameterAsText format is obviously incorrect since I keep getting an error when I run the script.

which is: Traceback (most recent call last):
File "C:\Users\Courtney\Desktop\ScriptTool.py", line 233, in <module>
df.time.currentTime = arcpy.GetParameterAsText(6) #datetime.datetime(2009, 01, 1, 00, 00)
File "c:\program files (x86)\arcgis\desktop10.1\arcpy\arcpy\arcobjects\_base.py", line 92, in _set
(attr_name, self.__class__.__name__))
NameError: The attribute 'currentTime' is not supported on this instance of DataFrameTime.

Failed to execute (ScriptTool).


SCRIPT:
mxd = arcpy.mapping.MapDocument(arcpy.GetParameterAsText(0))
env.workspace = arcpy.GetParameterAsText(1)
df = arcpy.mapping.ListDataFrames(mxd)[0]

df.time.currentTime = arcpy.GetParameterAsText(2) #datetime.datetime(2009, 01, 1, 00, 00)
endTime = arcpy.GetParameterAsText(3) #datetime.datetime(2009, 01, 1, 23, 59)
interval = arcpy.GetParameterAsText(4) #arcpy.time.EsriTimeDelta(1, 'hours')
#or #interval = datetime.timedelta(hours=1)
Viewing all 2485 articles
Browse latest View live