ArcGIS Server Code Challenge

Hey everyone.  I hope to see you in Palm Springs at the 2007 ESRI Developer's Summit.

If you have not heard already, there is going to be an ArcGIS Server Code Challenge.  Give it a shot and let us know if you have any questions.

Share your development creativity and expertise
with the GIS developer community by submitting your original code sample to the
ArcGIS Server Code Challenge! 
You and your peers will have an opportunity to
review and vote for the top three entries based on originality, creativity,
applicability, and relevance of the code sample. Entries could include a simple
task or tool or an attribute or spatial query. 

Read more on the ArcGIS Server Code Challenge
 

Jeremy 

 

Posted in Services | Tagged | Leave a comment

Antialiasing with multiple cached resources

Combining multiple cached map services is one of the more powerful aspects of the ADF for ArcGIS Server.  High performance mapping applications can be built off of multiple fused cached map services combined within the ADF.  Lets build on the cached aerial photography example from the other day and add a cached dataset of a street network.  In order to get the best performance when combining cached datasets in the Web ADF for the Microsoft .NET Framework you need to ensure that your cache configurations are identical (same scales, projection, tile size, etc) and that the map services share similar dataframe extents.  When building a map cache you have the option of taking advantage of Antialiasing to smooth the edges of labels and lines for improved display quality).  Of course you want to have smooth lines and labels!  So what does antialiasing really do?  Let's look at some comparisons of similar tiles with and without antialiasing.

   

The image on the left is without antialiasing enabled.  The image to the right has been built using antialiasing.  See the difference?  The image with antialiasing of the 2000 Census Roadways dataset looks crisper, not as choppy.   Antialiasing is designed to minimize jagged, blocky aliasing when representing higher resolution data at a lower resolution.  So let's see what happens when we publish the data on top of our ortho cache…

 

 Wait a minute…where did my roads go?  Let's look at the same area without antialiasing…

 

 

That is what I get for implementing something without understanding the logic behind the process!  The way we have implemented antialiasing from ArcGIS server is to generate tiles four times as large as the specified tile size so that we can average the RGB color of the four pixels that intersect the feature or label.   So instead of a tiled pixel being completely black or not, it will be an average of the subpixels contained by the pixel.  What does it average if it is just a line that is either black or not black?  It uses the background color of the dataframe to compute the average pixel value.  The background color is used as the transparent color by cache generation process and if you don't set the background color of your map the default is to set the background equal to 253,253,253 or almost white.  So in my example I have ended up with gray roads (which don't show up well on a dark image) instead of what I originally designed as black roads.  If I rebuild my map cache of my road dataset with a background color set to an average color within the image of the ortho tile (RGB: 129,129,116–pulled from this slick freeware tool) I end up with a tile that looks like this…

  

 

Try the application with each of the antialiasing options here:   http://serverx.esri.com/antialiasingexamples/

Jeremy 

Posted in Services | Tagged , | 1 Comment

Embedding globe services within other globes

James posted a comment regarding publishing Globe services with other embedded Globe services.  This can be done, but it is not the recommended workflow.  Sterling from the Server Dev team wrote up this response.

 

As you create 3D views using ArcGIS Explorer and ArcGlobe, you may want to use a layer from someone else’s globe service in addition to your own. For example, you might want to get your base layers from an ArcGIS Online globe service, and your thematic layers from your own globe service.

Resist the temptation to create a new globe service that embeds one or more other globe services. Your client applications will perform better and you will avoid redundancy of caches on your server if you have the clients connect to the globe services directly. The workflow below explains how you can create an easily-distributable globe that will allow clients to connect directly to all of the globe services it contains. This example uses an ArcGIS Online service, but you could substitute any globe service that you might want to embed in your own globes:

  1. Create a new ArcGIS Explorer map (NMF) or ArcGlobe document (3DD) and add the ArcGIS Online service
  2. Add your local data to a separate ArcGlobe document and publish it as an ArcGIS Server globe service.
  3. Add your globe service to the ArcGIS Explorer map or ArcGlobe document that you created in Step 1.
  4. Distribute the ArcGIS Explorer map or ArcGlobe document. Optionally, you can publish the ArcGlobe document as a PMF file so that clients with ArcReader can view the globe. Both ArcGIS Explorer and ArcReader are available as free downloads from ESRI.


 

 

 

Posted in Services | Tagged , | Leave a comment

ArcGIS Server Service Pack 1

ArcGIS Server Service Pack 1 is out and available for download.  It has many fixes along with some very key enhancements.  One of the biggest enhancements is the ability to create map caches in different image type formats.  At 9.2 final you only had the option of creating PNG24 images for you map cache.  While PNG24 images are visually appealing and work well with images with a lot of vector data they are inefficient for continuous raster images like aerial photography or satellite imagery.  For example here are two tiles of orthophotography in both png (on the left) and jpeg (on the right):

PNG    JPG

 

The JPEG tile is 16.39kb.  The PNG tile is 85.93kb.  That makes the JPEG in this case 1/5 the size of the PNG.  While that does not really make that much difference while you are on an internal network, it makes a big difference for web applications.  It is important to note that JPEGs do not support transparency so PNG images would be ideal for map caches that need to be transparent (a roads cache on top of an ortho cache for example). 

Try out a demo here:  http://serverx.esri.com/dgaerialsws

This example uses 2 meter FSA NAIP color imagery and six inch black and white orthophotos courtesy of the City of Lawrence, Kansas

Jeremy 

 


 

Posted in Services | Tagged , , | 8 Comments

Using the Callback control framework with a map resource

Let's build on the sample that Ryan put together and use the callback control framework to refresh a map control.  In this case we need to send back callback results of the map control to the control being called back to (the callback button).  To illustrate this lets add a map, map control, and a couple of Callback Button controls to the map design time in Microsoft's Visual Studio 2005.  We want to give the user the ability to add and remove a dynamic dataset via the CallbackButtonCustomControl.
 

To do this we need a method that adds a dynamic resource to the MapResourceManagerInstance.
 

private void createAndAddResource(string resourceName, GISResourceItemDefinition definition, bool insertIntoBeginning)

    {

        MapResourceItem resourceItem = new MapResourceItem();

        resourceItem.Definition = definition;

        resourceItem.Name = resourceName;

        resourceItem.DisplaySettings = new ESRI.ArcGIS.ADF.Web.DisplaySettings();

        resourceItem.DisplaySettings.Visible = true;

        resourceItem.DisplaySettings.Transparency = 20;

        resourceItem.DisplaySettings.DisplayInTableOfContents = false;

        resourceItem.DisplaySettings.ImageDescriptor.TransparentBackground = true;

        resourceItem.DisplaySettings.ImageDescriptor.TransparentColor = System.Drawing.Color.FromArgb(1, 2, 3);

        if (insertIntoBeginning)

        {

            Map1.MapResourceManagerInstance.ResourceItems.Insert(0, resourceItem);

        }

        else

        {

            Map1.MapResourceManagerInstance.ResourceItems.Add(resourceItem);

        }

        resourceItem.CreateResource();

        Map1.InitializeFunctionalities();

    }

 

 

Within the CallbackButton1_Clicked event we call the method to create and display the dynamic resource and then use the callback control framework to pass the CallbackResults from the map to the control.
 

  string resourceName = "Dynamic Data";

        GISResourceItemDefinition definition = null;

        definition = new GISResourceItemDefinition();

        definition.ResourceDefinition = "(default)@DGCountyAerialPhotos";

        definition.DataSourceDefinition = "http://localhost/arcgis/services";

        definition.DataSourceType = "ArcGIS Server Internet";

        definition.DataSourceShared = true;

        createAndAddResource(resourceName, definition, false);

        if (Map1.ImageBlendingMode == ImageBlendingMode.WebTier)

        {

            Map1.Refresh();

        }

        else

        {

            Map1.RefreshResource(resourceName);

        }

        CallbackButton1.CallbackResults.CopyFrom(Map1.CallbackResults);

 

So now we can add dynamic data to a map on a callback.

Try the sample app out here:  http://serverx.esri.com/callbackbuttonsample/map.aspx 

Jeremy 

Posted in Services | Tagged , | 2 Comments

Using the Callback control framework

Ryan Olson of the Web ADF development team contributed the following code sample that demonstrates how to use the callback framework from within the ESRI Web ADF for the Microsoft .NET Framework. 

This control is very useful for testing things during the context of a callback.  When called, it fires a server-side event in the context of a page callback so that you can attach to that event at design time or programmatically and act on the event.  You can return "javascript" as the event argument to execute a JavaScript function or you can refresh the contents of a non-AJAX-enabled control (like the Gridview) without having to write a line of JavaScript.  

The code is extremely simple and yet it shows how to use the Web ADF CallbackResults and the WebControl base class Callback implementation.

 

Here is some sample code to execute some javascript

    protected void CallbackButton1_Clicked(object sender, EventArgs args)

    {

        CallbackButton1.CallbackResults.Add(new ESRI.ArcGIS.ADF.Web.UI.WebControls.CallbackResult(CallbackButton1, "javascript", "alert('hello');"));

    }

Here is some sample code to refresh a control that doesn’t inherit from our webcontrols with the CallbackButton (like a gridview):

    protected void CallbackButton1_Clicked(object sender, EventArgs args)

    {

        CallbackButton1.CallbackResults.Add(RefreshControlHtml(GridView1));

    }

    private CallbackResult RefreshControlHtml(Control control)

    {

        System.IO.StringWriter sw = new System.IO.StringWriter();

        HtmlTextWriter writer = new HtmlTextWriter(sw);

        control.RenderControl(writer);

        string htmlContent = sw.ToString();

        sw.Close();

        return new CallbackResult(control, "content", htmlContent);

    }

 

Try out a sample application illustrating the usage here:  http://serverx.esri.com/callbackbuttonSample/ 

 

Posted in Services | Tagged , | 2 Comments

Publishing globe services to enhance your ArcGIS Explorer base map

Sterling Quinn of the ArcGIS Server team contributed the following post.  The ability to publish data as a globe service and to have that data be consumed in a rich client like ArcGIS Explorer is very powerful.
 

As you work on projects with ArcGIS Explorer, you’ll probably want to improve the default image and terrain resolution to create a suitable base map for your area of interest. Globe services are an efficient way to get high-resolution imagery and terrain data to your Explorer maps.

 

If you’ve worked with ArcIMS and ArcGIS Server before, you’re probably familiar with map services, which are two-dimensional. A globe service is three-dimensional, and represents an ArcGlobe document that is being made available to network and Internet clients through an ArcGIS Server system. In fact, the default satellite image you see when you open Explorer is from a globe service hosted by ESRI.  

 

To create a globe service, you need ArcGlobe, some data, and ArcGIS Server. After you create the globe service, you can improve its performance by creating a globe cache. 

 

This example uses two globe services created from publicly-available data:

  1. A globe service displaying 1-foot resolution color orthoimagery of Bountiful, Utah. This imagery was created by the United States Geological Survey (USGS) and is made available through the Utah Automated Geographic Reference Center (AGRC). In this example we’ve added four images to an unmanaged raster catalog so that ArcGlobe treats them as one layer.
  2. A service containing 1/3 arc second (about 10 meter) resolution elevation data obtained from USGS Seamless Data Distribution.
     

  1. A globe service displaying 1-foot resolution color orthoimagery of Bountiful, Utah. This imagery was created by the United States Geological Survey (USGS) and is made available through the Utah Automated Geographic Reference Center (AGRC). In this example we’ve added four images to an unmanaged raster catalog so that ArcGlobe treats them as one layer.
  2. A service containing 1/3 arc second (about 10 meter) resolution elevation data obtained from USGS Seamless Data Distribution.
     
  1. A globe service displaying 1-foot resolution color orthoimagery of Bountiful, Utah. This imagery was created by the United States Geological Survey (USGS) and is made available through the Utah Automated Geographic Reference Center (AGRC). In this example we’ve added four images to an unmanaged raster catalog so that ArcGlobe treats them as one layer.
  2. A service containing 1/3 arc second (about 10 meter) resolution elevation data obtained from USGS Seamless Data Distribution.
     
  1. A globe service displaying 1-foot resolution color orthoimagery of Bountiful, Utah. This imagery was created by the United States Geological Survey (USGS) and is made available through the Utah Automated Geographic Reference Center (AGRC). In this example we’ve added four images to an unmanaged raster catalog so that ArcGlobe treats them as one layer.
  2. A service containing 1/3 arc second (about 10 meter) resolution elevation data obtained from USGS Seamless Data Distribution.
     
  1. A globe service displaying 1-foot resolution color orthoimagery of Bountiful, Utah. This imagery was created by the United States Geological Survey (USGS) and is made available through the Utah Automated Geographic Reference Center (AGRC). In this example we’ve added four images to an unmanaged raster catalog so that ArcGlobe treats them as one layer.
  2. A service containing 1/3 arc second (about 10 meter) resolution elevation data obtained from USGS Seamless Data Distribution.
     
  1. A globe service displaying 1-foot resolution color orthoimagery of Bountiful, Utah. This imagery was created by the United States Geological Survey (USGS) and is made available through the Utah Automated Geographic Reference Center (AGRC). In this example we’ve added four images to an unmanaged raster catalog so that ArcGlobe treats them as one layer.
  2. A service containing 1/3 arc second (about 10 meter) resolution elevation data obtained from USGS Seamless Data Distribution.
     
  1. A globe service displaying 1-foot resolution color orthoimagery of Bountiful, Utah. This imagery was created by the United States Geological Survey (USGS) and is made available through the Utah Automated Geographic Reference Center (AGRC). In this example we’ve added four images to an unmanaged raster catalog so that ArcGlobe treats them as one layer.
  2. A service containing 1/3 arc second (about 10 meter) resolution elevation data obtained from USGS Seamless Data Distribution.
     
  1. A globe service displaying 1-foot resolution color orthoimagery of Bountiful, Utah. This imagery was created by the United States Geological Survey (USGS) and is made available through the Utah Automated Geographic Reference Center (AGRC). In this example we’ve added four images to an unmanaged raster catalog so that ArcGlobe treats them as one layer.
  2. A service containing 1/3 arc second (about 10 meter) resolution elevation data obtained from USGS Seamless Data Distribution.
     
  1. A globe service displaying 1-foot resolution color orthoimagery of Bountiful, Utah. This imagery was created by the United States Geological Survey (USGS) and is made available through the Utah Automated Geographic Reference Center (AGRC). In this example we’ve added four images to an unmanaged raster catalog so that ArcGlobe treats them as one layer.
  2. A service containing 1/3 arc second (about 10 meter) resolution elevation data obtained from USGS Seamless Data Distribution.
     
  1. A globe service displaying 1-foot resolution color orthoimagery of Bountiful, Utah. This imagery was created by the United States Geological Survey (USGS) and is made available through the Utah Automated Geographic Reference Center (AGRC). In this example we’ve added four images to an unmanaged raster catalog so that ArcGlobe treats them as one layer.
  2. A service containing 1/3 arc second (about 10 meter) resolution elevation data obtained from USGS Seamless Data Distribution.
     
  1. A globe service displaying 1-foot resolutio
    n color orthoimagery of Bountiful, Utah. This imagery was created by the United States Geological Survey (USGS) and is made available through the Utah Automated Geographic Reference Center (AGRC). In this example we’ve added four images to an unmanaged raster catalog so that ArcGlobe treats them as one layer.
  2. A service containing 1/3 arc second (about 10 meter) resolution elevation data obtained from USGS Seamless Data Distribution.
     

To create a globe service like the ones we’ve used in this example, you’ll need to do the following:

 

Add your data to an ArcGlobe document. Symbolize it just the way you want the clients of your globe service to see it. Save the globe document to a location that’s visible to all of the machines in your ArcGIS Server system. If you’re creating a globe service that will just provide elevation measurements, remove all other layers from your globe document.

 

Below are some views of the two globe documents that we'll publish as services to enhance our Explorer base map. The second view shows a wireframe because that service will contain elevation only.

 

 

 

 

 

Use ArcGIS Server to publish the globe document as a globe service. You can easily do this in ArcGIS Server Manage, or you can use ArcCatalog. If you need detailed instructions, consult the Globe Services topic in the ArcGIS Server Help: http://webhelp.esri.com/arcgisserver/9.2/dotNet/index.htm#manager/publishing/globe_service.htm

 

Create a globe cache for the service. A globe cache consists of pre-created globe tiles that exist on the server and can be distributed quickly to clients who request them.

 

When you display the globe service’s properties in ArcCatalog, there’s a Caching tab that contains the tools you need to create globe caches. It's not always practical to generate a full cache for all layers, but generating a cache for as many levels of detail as possible can improve performance for the first users that access the service. If you can’t create a full cache, the tiles that you do not create are created on demand as they are visited by clients. The map imagery cache in this example was cached from State (1:312500) to City Block (1:610) Note: Elevation globe services need the full cache built before you can use the service.

  

Once you’ve created the globe document, published the service, and created the cache, you can add the globe service to your Explorer maps. Below is what our image and elevation globe services look like in Explorer.

 

 

 

 

Of course, the power of Explorer lies in its ability to display your own data and perform GIS analysis on it. A high-resolution base map can enhance the effectiveness of your GIS work. Consider your impressions of the two screen captures below that overlay a geologic fault lines shapefile with the Explorer base map. The first image uses the original Explorer base map, while the second image uses the enhanced base map. Not only does our enhanced base map look more realistic, but specific buildings and streets crossed by the faults are more easily identifiable, providing for clearer analysis.

 

 

 

 

 

Try it out for yourself here:  http://serverx.esri.com/ArcGIS/explorer/maps/bountiful.nmf

 

What do you think?

 

 

Posted in Services | Tagged , | 1 Comment

Querying ArcGIS Server Web Services

One of the ways to connect to ArcGIS Server is through Web services.  When you make an Internet connection to the server, you will use a URL in this format:  http://<server name>/<instance name>/services 

This is an endpoint to your ArcGIS Server service catalog url. 

Where <server name> is the name of your server, which can be an IP address, a domain name (serverx.esri.com), or simply “localhost”.  The <instance name> is the name of your ArcGIS Server instance.  The instance gets defined when you install ArcGIS server.  You can review it by looking at server properties at your root folder in ArcCatalog.
 

So what can I do with this services catalog URL?  This URL can be used to establish an Internet connection to an ArcGIS Server instance in ArcCatalog.  It can be used as a connection in the ArcGIS Server Web ADF.  It can also be used in custom applications that work with Web services.  Today I am going to build a simple web application using the Microsoft .NET Framework in ASP.NET that consumes the catalog URL for my ArcGIS Server instance and lists the services, types, and service URL in a simple web page.

The first step after creating your new web site is to register the services catalog URL for your ArcGIS Server Web service.  To do this you need to add a web reference to your project (in VS2005 right click on the project name and Add Web Reference).  In the web reference dialog enter your server catalog URL. 


 

Once we have registered the Web service we just need to use it. 
 

//Create an instance of the service catalog web service

WebCatalog.Catalog webCat = new WebCatalog.Catalog();

//Set the url to your ArcGIS Server services url

String serverUrl = “http://localhost/arcgis/services”;

webCat.Url = serverUrl;

//Get the all the service descriptions from the Catalog

WebCatalog.ServiceDescription[] sds = webCat.GetServiceDescriptions();

//extract the name, type, and URL for each service in the

//servicedescriptions array

foreach (WebCatalog.ServiceDescription sd in sds)

{

  Response.Write(“<b>Service Name</b> = “ + sd.Name + “<br>”);

  Response.Write(“<b>Service Type = </b>” + sd.Type + “<br>”);

  Response.Write(“<b>Service URL  = </b>” + sd.Name + “<br>”);

  Response.Write(“<br><hr>”);

}

So try it out here:  http://serverx.esri.com/InterrorgateServer 

You can download the Visual Studio project here

Over the next few weeks I will explore working with the Web services for some of the ArcGIS Server service types (MapServer, GPServer).

Jeremy
 

 

 

Posted in Services | Tagged , , | 6 Comments

Publishing and using a geoprocessing model within a map document

One of the exciting new aspects of ArcGIS Server 9.2 is the ability to publish geoprocessing models and scripts to the server.  A model can be published either as a tool that can be used directly on top of any map service, or it can be published with an associated map service so that you can control the symbology of the generated layer. 

 

To illustrate the power of geoprocessing on the server, I built an example that uses a map service and an embedded model that allows users to execute an interpolation on the server and view those results in the web mapping application.  The map service contains a point dataset describing the potential water yield from water wells drilled in Douglas County, Kansas (data courtesy of the Kansas Geological Survey and the Kansas Geospatial Community Commons).  The model takes in the water well dataset and a user-defined cell size.  This information is passed as input parameters to the Natural Neighbors GP tool.  The output is a raster dataset.  The output is then rendered using a predefined layer symbology file (a layer file).

 

 

If you looked closely, you may have noticed that the model includes an embedded Python script.  This script allows me to put a limit on the input cell size parameter.  I want to allow the user to set the cell size (in meters) of the output raster dataset from within the web application.  However, I want to make sure that the user does not enter so small of a cell size that it will negatively affect the speed of the web application.  The script ensures that if the user enters anything less than 30 meters, the application will default to a cell size of 30 meters.  I will have more on this in a future post. 

 

Here are some key steps to remember when publishing a geoprocessing tool embedded in a map service.

 

  • Create an MXD with the input layer and any other background layers that you want in your map service.
  • Create a toolbox in your project directory.
  • Add a new model to your new toolbox.
  • The model should use one of the layers in the map document as an input parameter.
  • Ensure that your map document and input map layers are at the same projection.
  • Your output dataset should be written to the scratch workspace.
  • Set your toolbox scratch workspace environment variable equal to a directory that is visible to your ArcGIS Server Object Container (SOC) account.
  • Move your finished model to your ArcMap table of contents. This is called a tool layer.
  • Execute the model from within ArcMap and verify the results.
  • Turn off the output layer in ArcMap and publish to the server.

 

The easiest way to publish a map service with an embedded geoprocessing service is to publish the map document (using the right-click option on the map document, “Publish to ArcGIS Server”).  ArcGIS Server will see that the map service has a tool layer and will load that tool as a geoprocessing service. 

 

Once deployed to the server, it is relatively straightforward to deploy the map service and associated geoprocessing task as a web application using ArcGIS Server Manager. 

 

Check it out here:  http://serverx.esri.com/interpolationexample

 

Try building and publishing your own models.

 

What do you think?

Jeremy

Posted in Services | Tagged , , | 6 Comments

Configuring accounts and permissions in a distributed installation

Sterling Quinn of the ArcGIS Server team contributed the following post.  This information will ultimately end up in the ArcGIS Server Help site in a few weeks. 

 

ArcGIS Server for the Microsoft® .NET Framework has a scalable architecture that allows you to distribute its components among multiple machines. When you set up a distributed installation, there are a number of post installs, accounts, and operating system groups that you’ll need to configure. These requirements have changed at 9.2, so even if you have configured a distributed installation in the past, you may not be familiar with the latest requirements.

Below is a guide that shows what you’ll need to do on each machine. Each machine in the diagram contains some green text denoting which post install you must run on that machine. Items in blue are accomplished by the post install. Items in red are things that you must do. Note especially that you must manually add the ArcGIS Web services account on each dedicated SOC machine.

 

 

 

Posted in Services | Tagged , | 2 Comments