ArcGIS Server Code Challenge offers cash prizes for best original code samples

Dollar billsThis week, ESRI announced this year’s ArcGIS Server Code Challenge. If the developer community decides that you’ve submitted one of the top three original code samples, you’ll win a cash prize!

  • First Place—$15,000
  • Second Place—$7,500
  • Third Place—$2,500

The deadline for submissions is February 29, 2008. Winners will be announced at the 2008 ESRI Developer Summit in Palm Springs.

See this page for official information about the Code Challenge including a link to all the rules.

Posted in Services | Tagged , | 2 Comments

Working with Result Groups

ArcGIS Explorer 440 includes result management enhancements, making it easier to manipulate and work with results. One of the enhancements is that you can change the properties for a group of selected results.

You can select or unselect contiguous collections of results by using the <SHIFT> key. You can also add or remove results using the <CTRL> key.

Right-click the results to export the selected set to an NMF, remove them from the list, or edit their properties.

See the Help topics Organizing Results and Result Properties for more information.

Posted in Uncategorized | Tagged | Leave a comment

Guidelines for minimum size for text and symbols on maps

By Aileen Buckley, Mapping Center Lead

There are some general guidelines you can follow regarding the size of text and symbols on a map.  The key is legibility – that is, ability to be seen AND recognized.  Legibility can be affected by:

  • Size of symbols and type
  • Contrasting colors and shapes
  • Familiarity
  • Perfect vision and perfect viewing conditions Continue reading
Posted in Mapping, Migrate | Tagged , | Leave a comment

Changing the transparency of GeoprocessingTask results in a Map

Rex Hansen contributed this discussion about working with results of the .Net Web ADF GeoprocessingTask programmatically:

An ArcGIS Server geoprocessing service can contain server tools which generate feature output (e.g. feature class, feature layer, etc.) to be rendered in a map.  The Web ADF includes an out-of-the-box GeoprocessingTask control which can be used to interact with a server tool as a geoprocessing resource in a Web ADF application.  

As part of the Web ADF Task framework, a GeoprocessingTask can interact with a server tool, display tabular results in a TaskResults control, and display feature results in a Map control.   When a server tool generates feature results, either the raw feature data can be returned to the client, or a map service buddied with the geoprocessing service can be used to draw the results on the server.  The GeoprocessingTask maintains the boolean property DrawResultsOnMapServer to determine where feature results are drawn.  

In either case, one or more map resources must be created at runtime to draw results in a Web ADF Map control.   Upon successful execution of a GeoprocessingTask, the map resources are added to a MapResourceManager through the Task-TaskResults-Map-MapResourceManager buddy relationship.

If results are drawn using a map service, one ArcGIS Server map resource item is created for each set of result features when a geoprocessing job completes successfully.  The results are packaged as map resources in MapResourceNodes (in ESRI.ArcGIS.ADF.Web.UI.WebControls) by the GeoprocessingTask for display within a TaskResults control.   The internal framework of the TaskResults control manages adding the resources for you and eventually displaying the results in a map.

If results are drawn by the client, results are converted to Web ADF feature graphics layers in the GeoprocessingTask.  Upon display in a TaskResults control, the feature graphics layers are packaged as GraphicsLayerNodes (in ESRI.ArcGIS.ADF.Web.UI.WebControls).   The TaskResults control will create Web ADF graphics map resource items to contain the graphics layers; one resource item for each feature type.  

For example, assume a GeoprocessingTask is buddied with a TaskResults control named “TaskResults1” and a job initiated by the task generates a polygon feature set.  When the job is complete, a Web ADF graphics layer created from the polygon feature set will be added to a graphics resource item named “TaskResults1 Polygon Results”.  The graphics layer associated with each GraphicsLayerNode will be added to the graphics map resource item based its feature type (e.g. Point, Line, Polygon).  If a graphics map resource is already available for a certain type, all graphics layers of the same type are merely added to it.  All GeoprocessingTasks which share the same TaskResult control will also share the same graphics map resources.   The internal framework of the TaskResults control manages displaying the graphics map resource for you.  

By default, the transparency setting for all map resources created for MapResourceNodes and GraphicsLayerNodes is 25 (25%).   In addition, by default the symbols for features in a feature graphics layer created by the GeoprocessingTask have a transparency value of 0 (0%).  Note that map resources and graphics layers are two different entities.  A Web ADF graphics map resource can contain many Web ADF graphics layers.   The transparency settings of a feature layer renderer will be coupled with transparency defined for a map resource as a whole.   The GeoprocessingTask does not maintain a public property to change the transparency of results.  Consequently, the GeoprocessingTask must be subclassed to interrogate and change the results generated by the task before they are rendered in a Map.

To borrow a phrase from The Narrator in the movie Fight Club, let’s create a “single-serving” task only for use within the Web application it resides.  The custom task will override the transparency of results generated by a GeoprocessingTask.  Note that the techniques introduced in this example can also be applied to other Web ADF tasks.

  1. Create a new Web application (C#). Add MapResourceManager, Map, and TaskResults
    controls to the page. Buddy up the Map-MapResourceManager and TaskResults-Map.
  2. Add a TaskManager and Menu control to the page. Buddy up the TaskManager-Menu
    control. This step is not essential, but makes it easier to reinitialize the
    task by clicking on a menu item at runtime.
  3. Add a GeoprocessingTask to the TaskManager and buddy it up with the TaskResults
    control. In this example we will modify the out of the box GeoprocessingTask,
    so it’s easiest to start with one in the page and replace the reference once we
    have the custom task built.
  4. Add a map resource and geoprocessing resource. The outputs from the
    geoprocessing resource should be in the same coordinate system as the map. At
    this point, the application should appear similar to the following:

    Layout in Visual Studio

  5. Create a new class file in the Web application’s App_Code folder. Name the file
    CustomGeoprocessingTask.cs. The next set of steps will discuss adding code to
    this file. See the sample included with this post to view the code.
  6. Create a class named CustomGeoprocessingTask that subclasses the
    ESRI.ArcGIS.ADF.Web.UI.WebControls.GeoprocessingTask class and wrap it in the
    namespace CustomTasks.

    namespace CustomTasks
    {
    public class CustomGeoprocessingTask :
    ESRI.ArcGIS.ADF.Tasks.GeoprocessingTask
    { . . .

  7. Add a property to retrieve the first TaskResults control buddied to the custom
    task. This will require you to work with the TaskResultsContainers property of
    the task. In the sample, two internal methods are used to iterate through the
    controls in the page to locate the appropriate TaskResults control.
  8. Override the GetCallbackResults() method to work with results generated by the
    custom GeoprocessingTask. Call GetCallbackResults() in the base class first -
    this will generate a set of results based on user inputs. The Results property
    of the task will store the output results to be read by the TaskResults control
    and rendered by the Map control. The Results property will usually contain a
    set of TreeViewPlusNodes.

    If results are to be rendered by the client, GraphicsLayerNodes will contain Web
    ADF feature graphics layers with the output features. Change the transparency
    value of the selected renderer symbol associated with the feature graphics
    layer. Since the graphics layer is added to the map as part of a resource, find
    the dynamic Web ADF graphics map resource that contains the graphics layer and
    change the transparency of its display settings. Each feature graphics layer
    created as a result from a geoprocessing job is given a unique name.

    If results are rendered on the server, MapResourceNodes will reference dynamic
    map images generated on the server. Find the dynamic ArcGIS Server map resource
    generated to render the results and change the transparency of its display
    settings.

  9. Once finished, compile the Web project. Then add the following reference to the
    top of the aspx page:

    <%@ Register Assembly="App_Code" Namespace="CustomTasks" TagPrefix="customTasks" %>
  10. In the aspx page, change the tag associated with the out-of-the-box GeoprocessingTask to reference the custom GeoprocessingTask.

    Change the open and close tags from:

    esriTasks:GeoprocessingTask

    -to-

    customTasks:CustomGeoprocessingTask

As an example, the following screenshots illustrate the difference between the default transparency values associated with results from the GeoprocessingTask and a transparency value of 0 (not transparent) associated with a custom GeoprocessingTask. In this example, the results were drawn on the server.

Default transparency values:

Task results with default transparency value

Custom transparency value of 0:

Task result with custom transparency value of 0

Download the code

Posted in Services | Tagged , , , , | Leave a comment

Exploring New Resource Center Results and Tasks

The Explorer Resource Center has been expanded with the release of Explorer 440, and now includes results and tasks that you can add directly to your map. Choose File > Resource Center to open the Contents tab, and then click Results or Tasks to view them.

Click any of the listed results or tasks, and they’ll be added to your map. Here we’ve chosen to add the Sate Capitals and Facts, which includes links to the USGS Science in Your Backyard Web site with more information on each state.

Posted in Uncategorized | Tagged , | Leave a comment

How to apply saved representation rules in other layers

By Charlie Frye, Esri Chief Cartographer

Loading a rule from a style into the current representation class

A question was posed on Ask a Cartographer about using representation rules that you have saved in a style in another map on a different layer.  The online help for this topic didn’t provide much assistance. The topic on organizing representation rules in a style explained how to load the rules in to a new layer, but it didn’t explain how to make use of them, i.e., how to make the features with the newly loaded rule. Continue reading

Posted in Mapping | Tagged , , | Leave a comment

Launching a Browser via Popup Links

One of the changes to results in Explorer 440 is that links within the result popup will open a new browser window, rather that open within the popup itself. This allows you to use the browser’s navigation tools, and other tools you may have in your browser, in conjunction with result popups.

First, let’s create a result. For this example we’ll do this by using the Find Address task, but you can create results in many other ways. Type an address to create a result, we’ll use our favorite 380 New York Street, Redlands, CA:

Click on the result to open its popup. You’ll see something like this:

Now right-click the result and choose properties, and take a look at the Popup Content. You’ll see the address plus some HTML tags which together create the popup content you saw when you clicked the result.

Let change the Popup Content to include a link to an external Web site, in our example we will use the ESRI web site. We begin by adding the starting HTML tag to the first line of the Popup Content. This isn’t required at this latest release, but is good practice, and ensures that even those that haven’t updated to the latest Explorer will also see your popup contents as intended. We’ll add an extra line break after the address, then add the link, and close the html tag as shown below:

When you open the popup, you’ll now see a link, and when you click the link it will open a new browser window.

For more information refer to the Help topics on Results Window item properties and HTML markup for notes, results, and files.

Posted in Uncategorized | Tagged , , | Leave a comment

Updating your map caches automatically: The key to caching dynamic data

For the fastest performance of your ArcGIS Server map services, we recommend
that you use
map caching
wherever it’s appropriate. A map cache is a picture of your
map at one point in time. Map caches are obviously appropriate for maps that
don’t change frequently, such as street maps and imagery. But thanks to the
update tools included with ArcGIS Server, you may still be able to use caching
even if your data changes more often.

The Update Map Server Cache geoprocessing tool helps you update an existing map cache. You can
write a script that uses this tool, then schedule the update to run on a
regular basis. Even if you’ve never written a script or scheduled a task
before, it’s worth the effort to learn how because of the performance
improvements you can get from using a cached map. This post walks you through
the process.

Deciding if you should cache your changing data

To understand whether your frequently-changing map can still be cached, it helps
to ask these questions:

  • How up-to-date does my map need to be?

    If the data you see on the map needs to be live, with no time delay acceptable,
    then caching is not appropriate. However, if a short delay is acceptable and
    the cache updates can be performed within that time window, you can still use
    caching.

  • How big is my cache?

    A larger cache takes more time to update. But if you can isolate the areas of
    change, you may be able to shorten the update time.

    For example, Jeremy Bartley wrote
    a script that updates areas based on feature extents
    , instead of
    updating the entire cache. If you’re editing data in national parks, but you
    need a map of the entire country, you use this script to update your cache in
    the national parks only. This can save an enormous amount of time and server
    resources.

    When you use this script, remember that if data and symbology are frequently
    changing throughout your map, the update will take longer than if the changes
    were confined to a few specific areas.

To summarize, if the update can keep up with the changes in an acceptable amount
of time, the map is appropriate for caching.

Scenarios

The following scenarios might give you an idea of what types of maps are
appropriate or inappropriate for caching.

  • National and regional weather maps

    Probably appropriate for caching. A map viewed at a national or regional scale
    does not require many tiles and can be updated before the weather drastically
    changes.

  • Cadastral maps of a city that change on a daily basis

    Probably appropriate for caching because a city is not a large area and the
    cache can run overnight. However if no delay is acceptable, the map might not
    be appropriate for caching.

  • Maps that update vehicle or ship positions every 10 minutes

    May be appropriate if the cache can be updated in less than 10 minutes. This
    depends on the size of the map, the cache scales, and available server
    resources.

  • Maps for 911 dispatchers that display incidents and responders in real time

    Probably not appropriate for caching because no time delay is
    acceptable.

Preparing to write the script

When you initially create the map cache, note how long it takes. This will give
you an idea of how long it would take to update the entire cache.

After the cache generation tool runs, you may want to copy the text from the
geoprocessing message box and paste it into Notepad. This isn’t required; it’s
just for convenience when writing your update script. You can copy and paste
some of the parameters from the message box into your script.

Writing a script to update your cache

To automate cache updates, you can create a Python script that runs the Update
Map Server Cache tool. You can write the Python inside of Notepad, or you can
use a development environment such as IDLE or PythonWin.

The script does not have to be complex. It just needs to define the parameters
for the tool and run it. The following Python script runs the Update Map Server
Cache tool to re-create an entire cache:

# This script updates all tiles in an ArcGIS Server 9.2 map cache

# Access the geoprocessing tools
import arcgisscripting
gp = arcgisscripting.create()

# Set up all of the variables for the update tool
server_name = "myserver1"
object_name = "Precipitation"
data_frame = "Layers"
layers = ""
constraining_extent = ""
scales = "32000000;16000000;8000000;4000000;2000000"
update_mode = "Recreate All Tiles"
thread_count = "2"
antialiasing = "NONE"

# Run the Update Map Server Cache tool
try:
print 'Starting Cache Update'
gp.UpdateMapServerCache(server_name, object_name, data_frame, layers, constraining_extent, scales, update_mode, thread_count, antialiasing)
print 'Finished Cache Update'

# Get the error messages if the tool fails
except:
gp.AddMessage(gp.GetMessages(2))
print gp.GetMessages(2)

If you’re just getting started with scripting you can just copy the above into
Notepad, substitute your own variables, and save it with a .py extension. If
you need help understanding the variables, see the
Geoprocessing tool reference for Update Map Server Cache
.

Scheduling the update to run automatically

Once you’ve saved your Python script, you can run it on any machine that has ArcGIS Server and Python installed by double-clicking the .py file in Windows Explorer. (Python
is included with ArcGIS Desktop so you may already have it installed. Otherwise
visit www.python.org to get Python.)
Running the script manually in this way can be useful for testing, but in most
cases you’ll want to schedule the script to run on a regular basis.

Your operating system contains utilities that help you schedule tasks such as
running a script. You’ll need to provide the location of the script file, how
often you want it to run, and the name and password that the task will run as.

The
Scheduled Task Wizard
in Windows walks you through the process of
setting up the task. Open the wizard by clicking Start > All Programs >
Accessories > System Tools > Scheduled Tasks > Add Scheduled Task.

The Scheduled Task Wizard 

If you want a few more options than the wizard provides, you can schedule the
task from the command prompt. Just open Start > All Programs >
Accessories > Command Prompt and enter your command: like the following,
which schedules a Python script to run every 30 minutes:

schtasks /create /sc minute /mo 30 /tn "Update My Cache" /tr C:92CachingScriptsUpdate.py

If you need help creating a command like this, see the
Microsoft documentation for the schtasks command
.

Dedicating server resources to the update

At this point you may wonder if your server can handle the cache updates and
fill user requests at the same time. Updating a cache definitely uses server
resources because the server is required to continually draw map tiles during
the update. However, the update doesn’t have to tie up your entire server.

Each service has a maximum number of instances of the service that are allowed
to run, which you can adjust in the Service Properties. You can also use the
caching tools to specify how many of those instances will be dedicated to
caching (this is the “thread_count” variable in the script above). If you’re
short on server resources, you can lower the number of instances dedicated to
caching so that others can continue to use your service while the update
occurs.

In summary, if you want others to continue using your service while you are
updating, make sure that the number of instances dedicated to caching is less
than the maximum allowable number of instances.

Setting the maximum number of instances 

It’s also important to note that running Update Map Server Cache forces two
restarts of the service – once before the update starts and once after the
update finishes. Your services may be momentarily unavailable during the
restarts.

Scheduling your update to run on nights or weekends can also lessen the chance
of the update interfering with regular server traffic. Many organizations have
nightly backup or update processes, into which you could incorporate your cache
update script.

-Sterling Quinn

Posted in Services | Tagged , , , , | 3 Comments

A Note About Graphics Card Drivers

We’ve noted a couple of complaints about ArcGIS Explorer 440 crashing on startup, when earlier releases worked just fine. We’ve been able to determine that the cause is the graphics card driver, and have found that a driver update normally solves the problem. If you’re experiencing trouble on startup, check for an update for your graphics card.

A thread on the Explorer Discussion Forum, and post by Mark Bockenhauer, provide additional details.

Posted in Uncategorized | Tagged | Leave a comment

A little texture please: Creating fill symbols with feeling

By Charlie Frye, Esri Chief Cartographer

Depicting natural areas such as vegetation or complex hydrography such as swamps and estuaries can be accomplished by merely using solid green fill and blue fill symbols. However, such symbols are arguably bland, and certainly do not convey relative density, ruggedness, or texture.
Marker fill symbols can create many effects, ranging from replacing many of the old bitmap patterns on topographic maps to very modern styles of symbology. Continue reading

Posted in Mapping | Tagged , | Leave a comment