A Maxent Script Tool for ArcGIS

As part of my PhD research at the University of Arizona where I study biogeography, biodiversity and macroecology, I have been part of a group looking at large-scale biodiversity questions for New World plants. In this role, I have been responsible for generating many species distribution models using Stephen Phillip’s Maxent software (and R with the Dismo package). I also use ArcGIS quite often to prepare environmental data for Maxent modeling, and wanted a way to perform and integrate Maxent modeling into my ArcGIS workflows.

Maxent Tool User InterfaceWhen working with data and analysis, my rule is that if I have to do something complicated more than twice, it’s generally worth it to develop an automated workflow. So for my species distribution modeling needs, I wanted a Maxent script tool that I could use as a standalone geoprocessing tool or embed within a ModelBuilder model for use more complicated workflows. For example, one of my most common workflow is iterating through a list of species and running a species distribution model for each one.

To accomplish this, I wrote an ArcGIS script tool in Python that collects a variety of common Maxent parameters in a typical ArcGIS geoprocessing user interface and populates a command string to execute Stephen Phillip’s maxent.jar Java application via a Python call to execute a system command. The resulting script tool uses the arcpy model, so it works like any other ArcGIS geoprocessing script tool. It can operate as a standalone tool to generate a species distribution model for a single species, or can be placed into a ModelBuilder workflow and linked to input parameters as shown in the example below.

Maxent Tool in a ModelBuilder Model

In this example, the script tool is parameterized with a species occurrence dataset obtained from the iterator object in which each dataset is named genus_species.csv. The tool then generates a species distribution model for each species and saves the model to a separate directory within a designated output directory, naming each directory by the genus and species name specified in the name of the input occurrence dataset.

A partial example of the Python script that obtains the parameters from the input datasets is shown below.

Maxent Tool Python Script

These parameters are then appended to a string object that is a system command call:

myCommand = "java -mx512m -jar \"" + maxent + "\" -e \"" + climatedataFolder + "\""
myCommand += " -s \"" + csvFile + "\" -o \"" + newOutputFolder + "\""
myCommand += " outputformat=" + optOutputFormat.lower() + " outputfiletype=" + optOutputFileType.lower()

Finally the command is executed via a call to the os.system Python interface that executes the maxent.jar Javascript application with the appropriate options:

result = os.system(myCommand)

When the maxent.jar Java application launches, you’ll see the typical Maxent GUI that you would see if you launched maxent.jar directly and ran a model manually. Except in this case the maxent.jar application launches and starts the model automatically, as shown below.:
Maxent Running

Of course there are some additional script lines that are not shown in the examples above add other maxent parameters to the command string and evaluate the result of the os.system call to determine whether the command executed correctly or not.

However, I have placed a copy of a simple ArcGIS Toolbox and the associated Python script in a zipfile that you can download for your own modeling uses at the link below. There are different versions for each version of ArcGIS you may be using. While newer versions of ArcGIS can read older toolboxes, older versions of ArcGIS cannot read newer toolboxes. So be sure to download the file below that is most appropriate for your ArcGIS version.

Maxent Tool in ArcCatalogIf you like the tool, please let me know if you have any questions or comments/ideas. This is a fairly simple first implementation that I built to get through a lot of modeling quickly. However, I have a few ideas for additions to the tool that would enable it to handle species occurrence point data directly (instead of using saved CSVs) and perhaps leverage Maxent cache (.mxe) files instead of using the environmental data ASC files for each model iteration. At the moment, I’m too busy to add these, but it may be something I add in the future to round out the tool better.

Landing a GIS Job and GIS Skills Development in 2013

Note: This post is a 2013 update to my earlier post on Learning GIS and Getting a GIS Job – Some Tips and Tricks which was originally posted in 2009.

In 2009 I wrote a post on how to obtain a GIS job that focused on pathways to learn GIS, critical skills every GIS analyst should know and ways to augment traditional learning pathways to set you apart from other job candidates. Even though this post is well over 3 years old, it’s still read by people interested in the topic and I still receive comments.

I recently re-read the post and decided that an update was in order. Software has changed and old skills need to be replaced with new skills to keep up with the evolving GIS software industry. For brevity, I’ve focused this new post on changes and revisions to the recommendations I made in my earlier post.  I’ve also added links to resources and elaborated on some topics I introduced last time. So, please be sure to read that post before this one so you have the complete picture for what’s changed.

For simplicity, I’ve focused on skills needed for a GIS Analyst/Specialist position. GIS developers and GIS database manager positions have a different set of skills that may overlap with some of these, but also include specific skills that are not part of the everyday toolkit of GIS Analysts and are not included here.

Learning Pathways

There are a variety of reasons why you want to learn GIS. You may be employed in a non-GIS field and are learning GIS as part of your job. Maybe you are switching careers or retraining yourself to find a new job in the growing geospatial industry. Perhaps you are a student who wants to learn GIS to support your field of study, or you are a student majoring in GIS or geography with aspirations of landing a job doing GIS.

Depending upon your goal, there are different pathways to get started learning GIS:

Formal GIS/Geography Degree

If you want to obtain a bachelor’s or master’s degree majoring in GIS or geography, you should start at a community college or university where you can take accredited GIS courses that will apply to your major’s requirements.

Professional, Continuing Education

If you’re seeking GIS skills for your current job or want to re-tool yourself for immediate employment, you may be better served by finding a professional certificate program in GIS at a local community college or university extension. These programs are usually non-accredited, which means that they will not likely count towards satisfying the requirements for a formal degree in GIS, but they are a great way to learn GIS quickly and gain readily employable skills to help you enter the marketplace. In addition, many professional certificate programs are taught by professionals working in the field, so you will get first-hand information about how GIS is used by the people who use it daily. These programs are also fantastic places to network with potential future employers.

If the professional certificate track is what you need, check with local community colleges and universities in your area to see if they have a professional, extended, or continuing education certificate program in GIS or geospatial sciences. If there is no school in your area offering certificates or degrees in GIS, there are a number of excellent online programs available today, including:

This list is by no means complete, so if you know of other programs not listed, please add them as a comment to this post.

Both URISA and ESRI maintain a list of universities as well, so you may also want to check their websites as well:

There are also a number of specific free short-courses and technical workshops available on the ESRI Virtual Campus website.

Learn What Employers Want

Do not necessarily trust that your GIS certificate or degree program will teach you all the skills you need to know to land a GIS job. I’ve interviewed too many candidates who graduated from a GIS certificate program but only knew how to operate ArcGIS. While proficiency with ArcGIS is a critical skillset to have as a GIS analyst, there are a number of other hard and soft skills/techniques you should know to be a worthy job candidate.

Minimum Skills

At a minimum you should be proficient with the use of ESRI ArcGIS software (and extensions such as Spatial and 3D Analyst) and you should be able to produce cartographically pleasing outputs. However, GIS Analysts and Technicians are also expected to know the following: 

  • Cartographic production
  • Data creation
  • Geodatabase design and creation
  • Data editing
  • Topology
  • Projections
  • GIS analysis
  • Geoprocessing
  • GPS data capture
  • Aerial photography interpretation
  • Georeferencing
  • Data conversion
  • Metadata implementation

Employers also expect GIS Analysts to have experience with:

  • At least one non-spatial, database management system (Microsoft Access, Oracle, MySQL, etc.)
  • Microsoft Office (Excel, Word, Outlook, PowerPoint and Access).

Finally, most job advertisements also require GIS Analysts to have a Bachelor’s degree in Geography, Geographic Information Systems (GIS), Cartography, Computer Science or a related discipline. (Related disciplines can be landscape architecture, urban planning, geology, etc.). In many cases employers will accept a degree in an unrelated field with evidence of completion of a GIS certification program or demonstrable experience with GIS. While GIS technician positions often require very minimal years of experience, it’s typical to see employers require at least 3 years of GIS experience for GIS Analysts.  However, don’t let these numbers dissuade you from applying for any position. In most cases these are “desired” qualifications for a “perfect” candidate. “Perfect” candidates are rare, so employers frequently accept lesser qualified candidates, and it’s here that you can shine with your experience and skills.

Preferred Skills

In addition to the minimum skill sets, the following skills are commonly listed in advertisements for GIS Analyst positions:

  • SQL
  • Programming/scripting with Python
  • ArcGIS Server / SDE
  • Model builder
  • Trimble Pathfinder
  • ArcGIS Mobile
  • AutoCAD and integration of GIS and CAD
  • Adobe Photoshop
  • Adobe Acrobat Pro
  • Adobe Illustrator
  • Experience with web-application development (Net, Java, Python, PHP, HTML, JavaScript or Flex)

Soft Skills

Finally, it’s not just about technical abilities; employers also look for GIS people who:

  • Can to learn new technologies, skills and software platforms/extensions quickly with minimal oversight
  • Are good at problem solving and troubleshooting
  • Are self-motivated and pro-active
  • Can multitask and balance priorities with work load
  • Can be flexible in working on unplanned projects/events
  • Can work both independently and function well in a team environment
  • Are able to communicate complex GIS concepts to entry level users.
  • Show attention to detail and process
  • Show initiative in working efficiently and seeking out work
  • Have a customer focused/value added approach
  • Have strong verbal and written communication skills

Domain expertise, don’t just be a GIS jockey, know how to apply it to some government or industry such as environmental analysis, utilities, planning and urban development, marketing, etc. Whatever your interest, learn how to use GIS in your area. It will make you a more valuable and interesting person than just someone who knows how to use ArcGIS.

Read GIS Magazines and Websites

GIS website portals and magazines are a great way to get a sense of what direction the industry is moving, which topics are hot and how people and organizations are implementing GIS. They’re also useful for keeping up with the latest GIS-related news. So, explore some of the magazines and websites that are available. Some of the more well-known sources include:

Magazines

Portals

Attend User Group Meetings

I said this in my earlier post, but I’ll say it again because it’s important: Virtually everyone I know working in GIS got their first or subsequent job as a result of networking at a local or regional user group. Find one and attend them often. Ask questions, talk to people – these are (or will be) your colleagues and peers.

To get started, check the following websites to see if there is a user group in your area:

If there isn’t a local or regional User Group in your area, start one. There are probably lots of GIS people working in your area that would love to attend a user group. This is a great way to make contacts in the GIS industry very quickly. Many agencies can get the use of their meeting rooms for free. Most local vendors will jump at the chance to market their product to a room full of potential customers, so vendors can be helpful in filling presentation slots and getting the word out. With a little bit of tact you can usually get a vendor to sponsor snacks if they are presenting.

 

Get Real-World Experience and Build a Portfolio

In my earlier post I mentioned the need to get real-world experience to set you apart from other job candidates who only have GIS classwork experience. Today, more schools are integrating GIS into their curricula, and more schools offer GIS courses and certificates than they did a few years ago. This means there are potentially more people competing for a GIS job with you, so what will set you apart from the others is your experience.

So get real-world experience, read what I wrote in my earlier post as it’s important to develop real-world skills that will set you apart from your competition.

In addition, build a portfolio of your work that you can take to interviews. My first portfolio consisted of printed 8.5 x 11 copies of maps that I had made, scripts I had written, and reports or documents I had developed. I placed these items in clear plastic sleeves made for a 3-hole binder and brought the binder with me to interviews. Later I made PDFs of my maps, reports and scripts and burned them to CDs that I would give to potential employers when interviewing – but I still brought my binder so I could show these items during the interview.

So create a portfolio and bring it with you to interviews. It provides a great way to show off your discuss your experience and show off your cartographic skills. These will set you apart from most of the competition that will just show up to an interview with a copy of their resume.

Auxiliary skills

These days everyone applying for a GIS job can use ArcGIS Desktop. Sorry but that skill alone doesn’t make you special anymore (it doesn’t make me special anymore either). So potential employers are going to be asking what else you can do.

Databases

Any GIS person worth their salt knows how to set up and manage a database. Whether it’s Microsoft Access, SQL Server, Oracle, MySQL, or PostGreSQL, if you don’t know how to use a database, learn to.

If you are not familiar with databases, then learn Microsoft Access. It’s a good database system that’s easy to learn and use. Plus many organizations commonly use it and many people already have it on their computers – as it comes with many versions of Microsoft Office.

If you don’t have a copy of Microsoft Access and can’t justify buying one, Open Office Base offers many of the same features as Microsoft Access and can serve as a suitable replacement for learning about databases. You can download Open Office at: http://www.openoffice.org/

From there you can graduate to the workgroup and enterprise systems such as Microsoft SQL Server, Oracle, MySQL, PostGreSQL, etc. All of these database management systems offer free versions for development or personal use that you can download to get experience using them. See the links below for each software application:

Model Builder

There are many actions we routinely perform in GIS which can be manually repetitive. Consider the example where you are given a disk with 100 shapefiles that are in the WGS84 projection and you need to import them into your GIS data library (a geodatabase). To do this you’ll need to re-project them to the coordinate system you use (NAD 83, UTM Zone 11). You could do this manually in ArcCatalog or ArcMap but it would be better to construct a workflow that could automate the process and do it 100 times.

Model Builder is perfect for this kind of task. ModelBuilder is an application you use to create, edit, and manage workflows that string together sequences of geoprocessing tools, in which the tools feed the output of one tool into another tool as input. ModelBuilder is a visual programming language for building these workflows.

Why learn it? Model Builder is a key GIS Analysis skill because:

  • Performing actions like manually importing 100 shapefiles is tedious and not a good use of your time.
  • Complicated analyses often require a lot of geoprocessing actions and you’ll often find that you may need to repeat an analysis. If you need to run a complex analysis again and you didn’t build a model, you’ll have to re-do all your geoprocessing tasks manually and hope you took really good notes of your processing steps.
  • If you’re working with large datasets, geoprocessing tasks can take a long time. In this case, it’s best to construct a model to perform these tasks after hours instead of doing each task step by step (by hand) and waiting long periods for the output.
  • Models can be incorporated into ArcGIS Toolboxes and easily distributed to other users so they can quickly repeat an analysis.
  • Models can be uploaded to ArGIS Servers to enable processing of files on a server or in the cloud.
  • Finally, savvy employers know about Model Builder and it shows up as either a required or desired skill in job advertisements.

To get started learning Model Builder, visit the following links:

ArcGIS Server

If you are going after a GIS job in a large organization with an existing GIS program, there’s a chance that you’ll be asked about your experience with ESRI’s ArcGIS Server product. ArcGIS Server is a web server application that allows you to share GIS resources (maps, globes, tools, geoprocessing workflows, etc.) over the web. These resources are hosted on the ArcGIS Serve to facilitate sharing data that is centrally managed, supports multiple users, and contains the most up-to-date information.

ArcGIS Server skills are in demand these days and it’s a key skill to learn if you can. However, learning ArcGIS Server isn’t easy. Installing, managing and operating ArcGIS Server requires knowing a little about how to manage a file server and web server and active directory permissions.  Realistically the best way to learn about ArcGIS Server is to take a class. Many in-person and online programs offer a course in ArcGIS Server; ESRI’s Virtual Campus has courses in ArcGIS Server as well.

If you’re not familiar with ArcGIS Server, visit the links below to get a general introduction to ArcGIS Server and its capabilities.

If you can’t get experience working with ArcGIS Server, one thing you can do (in addition to reviewing the links above) is to register for a free personal account on www.arcgis.com. ArcGIS.com is a subscription based online platform for sharing geographic information and maps. ESRI offers a free personal account that provides limited access to features and 2 GB of storage space. With this account and a copy of ArcGIS you can upload data and maps to ArcGIS.com and experience a little bit of what it’s like to work with an ArcGIS Server from a user perspective.

In addition, reviewing the samples and information on the ArcGIS Server Javascript API provides a perspective on how to program web applications for ArcGIS Server.

Excel

Yeah, it’s not and ESRI product, but Microsoft Excel can be a critical component of your data scrubbing workflow. I use it often to view, manipulate and clean data before I import it into ArcGIS because it’s powerful, fast and can be used to make many data changes quickly and easily.

When learning GIS, we work with prepared datasets that have been cleaned and optimized to work in our exercises with minimal issues. In the real-world, data is messy; it contains a mixture of values in a variety of formats. Knowing how to quickly clean up a dataset is an essential GIS skill. So I use excel to change data from UPPERCASE to lowercase to replace portions of data with other values, to trim data, and to combine and split data. However, I rarely make these changes manually. Instead I use powerful functions in Excel that automate these corrections across rows and columns.

While Excel has many functions, I typically use only several for my data cleansing. So learn how to use functions in Excel; how to write them, copy and paste them. In particular, start with the following functions, as they are most commonly used to manipulate data:

  • Concatenate
  • Left
  • Right
  • Mid
  • Trim
  • Substitute
  • Replace
  • Upper
  • Lower

To learn more about Excel functions, simply search Google or Bing for “learning excel functions”. A good tutorial for getting started is also here: http://blogs.mccombs.utexas.edu/the-most/2009/05/07/learn-excel-functions/

Scripting

In my earlier post I recommended learning a scripting language because knowing how to write a script comes in handy when you need to scrub huge databases or perform actions like correcting addresses for better geocoding accuracy, reformatting data, exporting and importing large datasets, and other manually repetitive activities GIS people are routinely tasked with.

Back in 2009, I suggested that Visual Basic for Applications (VBA) was a good way to get started. Since that post ESRI has deprecated support for VBA in ArcGIS 10.x and VBA is not the preferred way to script in their latest product lines.

Today, scripting in ESRI is all about Python. Python is a free, cross-platform, open-source programming language that is widely used and supported in the open source and esri GIS environments.  It is become the scripting language of choice for geoprocessing users and ESRI has fully embraced Python for ArcGIS. So I would advise anyone in GIS who doesn’t know Python to learn Python. Here are some links to get started learning about Python in ArcGIS:

Finally, while ESRI may not support VBA anymore, VBA is still widely used in Microsoft’s Office product line though it’s being slowly replaced by Microsoft’s Visual Studio Tools for Applications: http://msdn.microsoft.com/en-us/library/cc175562(v=vs.90).aspx

 

Reports for ArcGIS

In my previous post, I wrote about the virtues of learning Crystal Reports. Crystal Reports is a powerful reporting tool that can read databases and spreadsheets, perform queries, sort and summarize data and generate professional looking PDF or live reports. Crystal Reports used to be included with ArcGIS Desktop, however at ArcGIS 9.3, ESRI stopped including the full Crystal Reports product; and the Crystal Reports Wizard is no longer included in ArcGIS 10.x.

As a replacement, ESRI now offers a reporting application built into ArcGIS Desktop that provides much of the same functionality that Crystal Reports offered. However the reporting application cannot be accessed or used outside of ArcGIS Desktop and must be used from the ArcGIS Desktop user interface.

You may be wondering whether it is still important to learn Reports for ArcGIS. Yes, because it’s not always about the map; in fact, it often isn’t about a map at all. I know us GIS people got into GIS because we like to make great looking maps, but the mistake we make is thinking that everyone else likes maps too. When I started working in government GIS, I was amazed at how often I was asked to create a report showing the results of my analyses (for example, a report containing a table summarizing the number of acres of different vegetation types that will be impacted by a proposed development). No map; no polygons on a nice aerial photo – just a table of numbers representing the results of a geographic analysis. There was still a lot of cool GIS analysis that went into generating the report, but the end product wasn’t a map.

While the software may have changed, the need hasn’t  so I’ll continue to recommend learning how to design and create reports of your GIS analyses. Today, we would accomplish this with Reports for ArcGIS. So to learn how to use the integrated reporting tools, see the following links:

2013 Conclusion

While I’ve written this post within the context of obtaining skills you need to land a GIS job, these are equally appropriate skills for those already employed in GIS. The industry continues to change rapidly, and you can get rusty pretty fast if you’re not keeping up. Each new software version brings new features that offer new opportunities for learning a new skill or adding to our existing knowledge base.  For example, I recently learned how to write and deploy ArcObjects applications in ESRI’s new ad-in framework and plan to learn how to use the new Python ad-in framework in ArcGIS 10.1.

Learning these employable GIS skills is also a very good investment. GIS jobs are still ranked very high in job growth outlook – the Bureau of Labor Statistics lists an expected 35% growth in jobs for “Geographers” (http://www.bls.gov/ooh/life-physical-and-social-science/geographers.htm). Whether you’re looking for your first GIS job or looking to move to a new organization, these skills will make you much more marketable than your typical competition.

Finally, I’ve tried to identify those skills that I view as important for obtaining and maintaining a GIS position.  I’ve also focused on skills a GIS Analyst or Specialist should know. If you’ve read this and can think of other important skills I didn’t mention, please leave a comment to benefit the larger community.

Thanks for reading.

A Script Tool for Unzipping Files in ArcGIS

I was recently working with the SWReGAP data DVDs and wanted to develop an ArcGIS geoprocessing model to copy the DVD data, clip the rasters to the state of Arizona boundary and reproject them.

Because the DVDs contained a raster dataset for each species that was stored as a zip file, I wanted a way to decompress each raster within my model rather than simply decompressing all the zip files to a folder on my hard drive and using the uncompressed files in my model. (This is because each DVD was filled to capacity with 2+ GB zip files, so decompressing the DVD contents to my hard disk first filled up the remaining space on my hard drive. So I decided that I should decompress each file individually and delete it when I was finished.)

So I set about developing a script tool to decompress each zip file so that I could incorporate the script tool into my ArcGIS geoprocessing model. I tried using the zipfile libraries built into Python, but ran into problems decompressing these files because each zip file was too large for the readfile buffer used by the Python routines.

This led me to 7-Zip, an open source to WinZip. While 7-Zip contains a user interface, I was particularly interested in the 7-Zip Command Line Version as this made it possible for me to call the command line from my ArcGIS script too.

With the 7-Zip Command Line Version installed and a few lines of Python, I had a script tool that was capable of extracting a zip file and could be included in an ArcGIS geoprocessing model. I then developed a second script to decompress a whole folder of zip files, and a third script for zipping a feature class.

import os
import arcpy
infile = arcpy.GetParameterAsText(0)
outpath = arcpy.GetParameterAsText(1)

# create 7zip command
zipcommand = “7za e -tzip \”%s\” -o\”%s\”” % (infile, outpath)

try:
      # execute command
os.system(zipcommand)
arcpy.AddMessage(“Finished”)
except Exception as e:
      print e.message
arcpy.AddError(e.message)

I then added the script to a toolbox in ArcGIS as a script tool and set two parameters: 1) Zipfile Name as a file, and 2) Output Location as a folder. When clicked, the script tool appears like the one below:

I was pleased enough with the resulting tool that I developed a simple model that incorporated the tool into an iterator to loop through a folder of zip files and extract each one. That model is illustrated below:

Finally, I also created a second script tool that decompresses an entire folder of zipfiles to a specified location.

Since these have been helpful in automating my workflow I thought I would offer them to the GIS community as a zip file that contains a folder with an ArcGIS Toolbox, two script tools and a sample mode. You can download them from my website at: http://www.johndonoghue.net/ecology/resources.html

To use the ArcGIS Script tools:

There are a couple of things you need to do before the tools will work. Follow the simple steps below to obtain a copy of 7-Zip Command Line Version and modify your system paths.

  • Download and install 7-Zip Command Line Version. When you download the application it will consist of a zip file. decompress the zip file to a folder on your hard disk. I highly recommend extracting the files to a folder in your root directory named something like C:\7Zip or the default C:\7za920. If you extract them into a folder inside your program files folder on 64-bit systems, you may not be able to run the scripts as Python cannot find the executable even with the path statement.
  • Add the path to your 7-Zip installation to your Windows PATH environment variables – add it to both the System PATH variable and the User PATH variable . For example, my path was: C:\7za920; (see http://www.computerhope.com/issues/ch000549.htm if you need help doing this).
  • Finally,download the  Tools from my website and extract them to a folder on your hard drive. You should then be able to use them as you would any ArcGIS script .

I hope you find these tools helpful in your work.

Are Some Parts of ArcGIS Getting More Difficult to Use?

I got a call from a colleague who was having dificulty getting ArcGIS to calculate the value of a field in an attribute table. He was building a model in ModelBuilder and wanted to perform a conditional (If Then) calculatuion to evaluate whether a field’s value was Zero (0) before he tried to divide another value with it.

In response to his question, I quickly provided him the following VBA code for his field calculator tool:

Pre-Logic Script Code:

if ([SUM_weeks] <> 0) then
    newval = [SUM_deliv] / [SUM_weeks]
else
   newval = .001
end if

Assignment Code:

[NewField] = newval
Field Calculation Example with VBA

Field Calculation Example with VBA

While this worked fine, he mentioned that he would rather have Python code, since it is rumored that esri is removing VBA in future releases of ArcGIS. In response, I initially tried to simply convert the Pre-Logic code block to the following Python code:

if (!SUM_weeks! <> 0):
    newval = !SUM_deliv! / !SUM_weeks!
else:
    newval = .001

Much to my surprise this code generated a parsing error, and try as I did, I could not change it in a way that would work, despit the fact that it appears to be perfectly valid Python code.

After reviewing some portions of the ArcGIS Desktop help file, I learned that in order for me to execute the same statement in Python, I needed to write a Python function and then pass the field values into that function. So I composed the following Python code to send my colleague:

Pre-Logic Script Code:

def DoMath(field1, field2):
   if (field2 == 0):
       newval = .001
   else:
      newval = field1 / field2
   return newval

Assignment Code:

DoMath(!SUM_delive!, !SUM_weeks_!)
Field Calculation Example with Python

Field Calculation Example with Python

This worked fine but I was really surprised that I could not just use the field names within the code block. We’ve always been able to do this in esri projects. We coudl do it in VBA and even Avenue (for those who remember the ArcView 3.x Query Builder), AML allowed this too.  But not anymore, why?

As a long time esri user, this kind of stuff concerns me. I’m not worried that they going to lose their customer base or market share. But it seems that as ArcGIS has grown more powerful some portions of it have grown more difficult for casual users. Replacing dialogs and functions that worked well for casual users with Python code blocks works well for programmers and power users, but it leaves casual users to struggle with stuff they used to know how to do.

Users shouldn’t have to write a Python function and then pass an attribute field value into that function to edit a field. This kind of editing used to be easier and I hope someone at esri figures this out and simplifies it again.

P.S.  Don’t get me wrong, it’s not that I hate change or dislike Python; I use it often. I should point out that there are some wonderful simplications to field editing in ArcGIS 9.x and 10 that esri programmers should be commended for. I greatly enjoy and make frequent use of the Calculate Geometry functions and appreciate not haveing to write the VBA code blocks that I used to write to add X and Y coordinates to attribute tables or calculate polygon areas. Actually I only wrote the code once and then saved the query expressions for subsequent uses, but still, it’s much easier to use the newer Calculate Geometry functions.