Wednesday, October 26, 2011

Working with Date Field (simple example)

Say you want to update a date field on a file geodatabase and it is in the format of: "Tue, 25 Oct 2011 18:44:39 +0000".  To insert this date, you need to convert it using the datetime module and provide the correct date format:
import datetime
def convertTime(timestring,format):
    return datetime.datetime.strptime(timestring, format)

where the format in this case would be "%a, %d %b %Y %H:%M:%S +0000".  You can then take the datetime object and insert the value into the date field.

You can find more on formatting times here in section 8.1.7.

Enjoy

Friday, October 14, 2011

SP3 for ArcGIS 10 is Here

SP3 is out, go download it here: http://resources.arcgis.com/content/patches-and-service-packs

Turn off Minimize and Maximize Transitions on Windows 7

Transition animation annoys me when windows are maximized and minimized.

To disable this do the following:

  1. Right click on My Computer
  2. Select Properties
  3. Select Advanced System Settings
  4. Click the Advanced Tab 
  5. Under performance click Settings
  6. Uncheck 'Animate windows when minimizing and maximizing'
  7. Press OK -> apply -OK
That's it!
 Enjoy

Wednesday, September 28, 2011

Turning on labels through ArcPy

The Layer object in the ArcPy module allows python developers to turn on labels of a feature class on and off at run time.  This is especially helpful if you are exporting maps and you want to control what Layers are labeled.
Example: Turning on Labels
import arcpy
from arcpy import mapping
fc = r"c:\temp\fc.shp"
tempLayer = "tempLayer"
arcpy.MakeFeatureLayer_management(fc, tempLayer)
#   Make the Layer Object
#
layer = mapping.Layer(tempLayer)
layer.showLabels = True
#   Show the changes in ArcMap
#
arcpy.RefreshActiveView()
del layer 


Enjoy

Tuesday, September 27, 2011

Usage() - Arcpy

Usage() is a helpful tool that will return the syntax for a specific tool.  It's a great thing to use in IDLE when writing a python script and you forget what variables go where.

Example:
>>> import arcpy
>>> print arcpy.Usage("Buffer_analysis")
Buffer_analysis(in_features, out_feature_class, buffer_distance_or_field, {FULL | LEFT | RIGHT | OUTSIDE_ONLY}, {ROUND | FLAT}, {NONE | ALL | LIST}, {dissolve_field;dissolve_field...})
Buffer Features
>>> print arcpy.Usage("MakeFeatureLayer_management")
MakeFeatureLayer_management(in_features, out_layer, {where_clause}, {workspace}, {field_info}) Create a Feature Layer

Pretty help for those who don't have to refer to the help document all the time.
Enjoy!

Monday, September 19, 2011

A Quick Note on Multiprocessing

If you create a multiprocessing script and you want to use the python script in ArcToolbox, ensure the following settings are set on your script:
1. Show command window when executing is unchecked
2. Run python script in process is unchecked

Your python script should now multi-process if you wrote it correctly.

Enjoy