Utah.govOnline ServicesAgency ListBusiness.Utah.gov

Home arrow GIS Data & Resources arrow Scripts and Code
GIS-Related Scripts and Programming Code

This section provides a venue for sharing GIS-related programming code and custom scripts in a variety of languages. Posts can be viewed by category or as a whole in blog format (below).

Category Links:

GIS Scripts and Code (Weblog format, All Posts):




Python script for outputting the layer order of .axl files PDF Print E-mail
25, Sep. 2008
Last Updated ( 25, Sep. 2008 )
Read more...
 
VBA: Standardize, Automate Common Metadata Elements PDF Print E-mail

Written by Bert Granberg,

Ahhh metadata. You have 35 GIS data layers and need to change your metadata's contact information and disclaimer language for all of them. Metadata is bad enough, right? There must be an easier way to do this than manually/menially/mundanely opening up each layer, one-at-a-time in the ArcCatalog metadata editor?

Luckily, there is an easier way. This VBA script will operate on selected feature classes and/or feature datasets in ArcCatalog and allows for bulk selected updating of metadata element values. The example code shows an update by AGRC of its standard online linkage, disclaimer, and distribution contact elements for SGID data.

Before customizing this script to meet your needs you will need to do two things:

  1. Figure out the mapping from FGDC metadata elements you would like to update to the ArcObjects-based xml tags (ex. FGDC's "Identification_Information/Use_Constraints = ArcObjects "idinfo/useconst". This is not hard but takes some time/effort...here's a list of most of the ArcObjects metadata property elements
  2. BE CAREFUL! This script will operate on all the feature classes that you have selected in the Contents tab in ArcCatalog. Do you really want to override contact info (for example) for all the feature classes? or are there some that need to stay the same? Take a deep breath and give it some thought.

To use this script:

  1. Open ArcCatalog's VBA Editor from the Tools --> Macros -->Visual Basic Editor and open the Project Explorer window from the View menu.
  2. Paste the code below, consisting of 2 subprocedures, into the Normal --> ArcCatalog Objects --> ThisDocument. The code is a little long but it includes many lines required for the current Utah SGID data disclaimer.
  3. Customize the pMetadataXMLPropertySet2.SetPropertyX statements to use and set values for metadata elements you want to chang
  4. In the ArcCatalog Contents view (not the tree view on the left side of AC) select feature class(es) or feature dataset(s) to operate on. Start on a test feature class first!!!
  5. In the VBA editor, put your cursor anywhere in the GetSelectedFeatureClasses() procedure and select Run Sub/UserForm from the Run menu (or hit the F5 key)

Note: I have included, but commented out, a line that will allow you to load a custom layer thumbnail image into the metadata. If you're tired of the standard black dots, black lines and yellow polygons with absolutely no other context information, you might experiment with exporting a better image and customizing this code to get it to load.

 

Comment on this Article
22, Sep. 2008
Last Updated ( 22, Sep. 2008 )
Read more...
 
Python! GUI project directory builder! PDF Print E-mail

Written by Kevin Bell,

In Salt Lake City's Transportation Division, GIS requests come from many different people, and the projects can be revived years later.  In order to organize these projects I made a simple python application that builds up a project directory to hold all of the data.  I have a folder, say C:\gis, that contains a folder for every person in my office that may have GIS needs.  If I'm asked to make a new map or crunch some numbers, I click my app's icon and a wxGUI prompts me for a project name, the requestee, and it also gives me a couple check boxes to open a basemap and/or the new project directory that organizes the information. 

If Bill requests a wattage summary for 1300 E street lights, I click my project builder app, and I type in wattageSummary_1300E, choose "Bill" from the drop down list, and upon clicking the button "BUILD THE PROJECT" a directory is built C:\gis\Bill\wattageSummary_1300E, with a new basemap in the directory named wattageSummary_1300E.mxd...  Also, subdirectories are built for FinalData, TempData, and OriginalData.  See the screenshots.  Organizing your project data makes it much easier to track down your past work!

This sample doesn't do anything with the ESRI geoprocessor, but is utilizing the wxPython GUI library which is useful for cross platform GUI development.  see www.wxpython.org to download this.  After downloading this, you can start the demo which gives code samples for just about every type of GUI widget you'd ever want...  There's everything from data grid controls to drop down lists to sliders to process/event managers.

Happy GUI development!

The project builder GUI

resulting File structure

User Comments (2)
17, Sep. 2008
Last Updated ( 17, Sep. 2008 )
Read more...
 
ESRI Web ADF query data with unknown characters bug PDF Print E-mail

Written by Steve Gourley,

Working with ESRI ArcGIS Server can sometimes be puzzling with unexpected outcomes and issues that are not reproducible.  After many months of working with the software, you can begin to understand the oddities and can know when to expect correct results and when something might give you bogus answers. 

Well, this time it wasn't the software.  It was the data; the second most likely suspect.  Turns out that doing a spatial query with the Salt Lake County boundary on one particular layer of data would return null. Every other layer was fine and this problem layer worked for all the other counties and query methods.  A null datatable when using the web ADF is a sure sign of a problem.  But what could that problem be?  

Upon further investigation and using a polygon search tool, I was able to narrow down the area of where this issue was happening.  I then narrowed it down to one cluster of points.  Opening ArcMap and identifying one of those points, I noticed some unknown characters being displayed as hollow boxes. How did that get there?  Who knows, but ArcMap has the ability to strip those characters and move on with life.  The webADF however breaks and returns null.

unknown characters for jordan valley

The moral of the story:   Make good data!

Comment on this Article
16, Sep. 2008
Last Updated ( 17, Sep. 2008 )
 
<< Start < Prev 1 2 3 4 5 6 7 8 9 10 Next > End >>

Results 9 - 16 of 82

AGRC Contacts | UGIC Contacts

feed image feed image

Utah GIS Portal © 2008 AGRC

Optimized for