Thursday, October 28, 2010

Dynamic Label Tip

When working with data driven pages, you might want to put the adjacent grid cells on the page layout. What happens is the cell is empty? By default, the value "[EMPTY]" will appear, which is not very pleasing. To get around this issue, there is a property called emptystr. If you set the emptystr=" " you will see nothing instead of "[EMPTY]."


Code sample below:

< dyn emptystr=" " property="PageNumber_E" type="page" >

Tuesday, October 26, 2010

Assigning Alias to Custom Toolboxes

I create lots of custom scripts and toolboxes to help out with various tasks, and I noticed the following message the other day when I exported a script from model builder to python:
# Warning: the toolbox toolbox.tbx DOES NOT have an alias.
# Please assign this toolbox an alias to avoid tool name collisions
# And replace arcpy.gp.toolname(...) with arcpy.toolname_ALIAS(...)

Basically, the system is asking for an Alias to provide an additional unique identifier because tools within the same toolbox cannot have the same name, but tools in other toolboxes can have the same name. 

To define an alias, open ArcCatalog and right click on the tbx file.  Select properties, you'll see this:

Enter in an alias and press ok.

That easy!
Enjoy

Friday, October 8, 2010

Alternate Access Mapping for SharePoint

Alternate Access Mapping enables you to access your Sharepoint site via a typical URL like http://mysharepoint.com instead of hitting the server name at http://mysharepointserver. In combination with DNS A host entries you can also define URLs like http://mysite.mysharepoint.com even though your My Site web application is hosted on a different port.


Let's start:

  1. Go to Central Administration 
  2. Click on the Operations Tab
  3. Click on Alternate Access Mappings under Global Configuration
  4. You should now see a list of your web applications, switch over to the one you want to map to the new URL by selecting it from the drop down on the right side.
  5. Click on Edit Public URLs and change the desired zone URL type to your new domain name. You can also change your internal URLs also by clicking Add Internal URLs.
  6. Now you’ll have to switch over to your DNS server.
  7. Within the DNS Management Console and Under Forward Look up Zones:
  8. Add a new Primary Zone with your new domain name.
  9. Add a new Host (A) to the records and point the IP Address to the SharePoint server.
Enjoy

SharePoint 2007 - Enable Anonymous Access

1). To enable anonymous on the IIS web site do the following:
  • Launching Internet Information Services Manager from the Start -> Administration Tools menu
  • Select the web site, right click and select Properties
  • Click on the Directory Security tab
  • Click on Edit in the Authentication and access control section
1a). Or enable anonymous in SharePoint using the Central Administration section:
  • First get to your portal. Then under “My Links” look for “Central Administration” and select it.
  • In the Central Administration site select “Application Management” either in the Quick Launch or across the top tabs
  • Select “Authentication Providers” in the “Application Security” section
  • Click on the “Default” zone (or whatever zone you want to enable anonymous access for)
  • Under “Anonymous Access” click the check box to enable it and click “Save”
NOTE: Make sure the “Web Application” in the menu at the top right is your portal/site and not the admin site.
You can confirm that anonymous access is enabled by going back into the IIS console and checking the Directory Security properties.
2). Enable anonymous access in the site.
  • Return to your sites home page and navigate to the site settings page. In MOSS, this is under Site ActionsSite SettingsModify All Site Settings. In WSS it’s under Site ActionsSite Settings.
  • Under the “Users and Permissions” section click on “Advanced permissions”
  • On the “Settings” drop down menu (on the toolbar) select “Anonymous Access”
  • Select the option you want anonymous users to have (full access or documents and lists only)
Now users without logging in will get whatever option you allowed them.
A couple of notes about anonymous access:
  • You will need to set up the 2nd part for all sites unless you have permission inheritance turned on
  • If you don’t see the “Anonymous Access” menu option in the “Settings” menu, it might not be turned on in Central Admin/IIS. You can manually navigate to “_layouts/setanon.aspx” if you want, but the options will be grayed out if it hasn’t been enabled in IIS
  • You must do both setups to enable anonymous access for users, one in IIS and the other in each site

Thursday, October 7, 2010

Searching Esri ArcObject Help With Google

Here is a great tip I've picked up over the last couple of months.  When working with the online help system for ArcObjects, you can sometimes get tons of search results for unrelated topics.  For example, say you search Point or Polygon, you will get about 10,000 results from the forums, other help topics.  It's basicly information overload!

Let's say you need to search the .NET ArcObjects help, so to streamline the search process, you can utilize Google's search engine by doing the following:
  1. In order for google to work, you need the site.  For this example, we will use http://help.arcgis.com/en/sdk/10.0/arcobjects_net/ao_home.html. You can to remove the http:// and the ao_home.html for your site reference.
    • The result should be this: help.arcgis.com/en/sdk/10.0/arcobjects_net
  2. With our site in hand, navigate to google (http://www.google.com/) and create a new search entry as follows: "site:help.arcgis.com/en/sdk/10.0/arcobjects_net TEST" 
  3. Copy the resulting URL and ignore the search results
For IE:
  1. Go to: http://www.microsoft.com/windows/ie/searchguide/en-en/default.mspx
  2. Paste the resulting Google Search URL into the URL box
  3. Give it a descriptive name. Ex: Search .NET ArcObjects
  4. Click install
Enjoy

Tuesday, October 5, 2010

Counting Values Script - Finding Likely Voters

It's election time in the United States, and some of you might be helping out with campaigns.  A colleague of mine who helps out with campaigns asked for my advice on how to make a quick utility to examine who voted in the last four general elections.  From that information, he would categories likely, unlikely, very likely voters. 

Of course I said use python.  It's quick, easy, and reusable:

####################
# Input Parameters #
####################
inputTable = arcpy.GetParameterAsText(0)
CountFields = arcpy.GetParameterAsText(1)
VotedValues = arcpy.GetParameterAsText(2)
###################
# Local Variables #
###################
ElectionCountFieldName= "ElectionCount"
###################
# Logic #
###################
fields = arcpy.ListFields(inputTable)
for field in fields:
if field.name == ElectionCountFieldName:
arcpy.DeleteField_management(inputTable, ElectionCountFieldName)
break
del fields

arcpy.AddField_management(inputTable, ElectionCountFieldName, "TEXT")

rows = arcpy.UpdateCursor(inputTable)
splitVal = VotedValues.split(',')
for row in rows:
count = 0
for f in CountFields:
if str(row.getValue(f)) in splitVal:
count = count + 1
row.setValue(ElectionCountFieldName,str(count))
rows.updateRow(row)
del row, rows
arcpy.SetParameterAsText(3, inputTable)

where the inputTable is the table which contains the data you wish to sum up, CountFields is a collection of field names (multi-value object), and VotedValues is a comma separated string (value1,value2, etc...) that represents the values of a voter voted.

Now that the script is created, you need to create the toolbox in ArcCatalog or ArcMap:



Parameter NameSetup
1Input Table/FCType: Feature Class or Table
2FieldsType: Field,
Obtained From: Parameter 1,
MultiValue: Yes
3Voted ValuesType: String
4Return Table/FCType: Table/FC,
Direction: Output


Enjoy and Happy GISing