Tag: Snapping

Pro 1.1: Why Do I Need to Click “Download?”

Pictometry 3D Scene

On Friday, July 17th, many ArcGIS Pro users saw a small window pop up on their computer screen. It announced to them, and to the world that a new version of Pro is available to download. I often find myself … Continue reading

Posted in ArcGIS Pro, Uncategorized | Tagged , , , , , , , , , , , , , , , , , , , , , , , , , | Leave a comment

Snapping to features in basemap layers and feature services

snapping_options_fs_bm

ArcGIS 10.1 provides options for you to choose whether to snap to features in basemap layers and feature service layers when working in ArcMap. Previously, snapping was always enabled for all available layers, which caused performance to decrease in some … Continue reading

Posted in Editing, Mapping | Tagged , , | 5 Comments

Incorporating snapping into custom tools

If you are writing a custom tool in ArcMap to select features or create geometry a certain way, then you’ll often need to make it snap to existing features on the map. In the past, snapping was restricted to editing and was somewhat cumbersome for developers to implement. However, ArcGIS 10 provides the ArcGIS Snapping Environment, which offers users a simplified experience in ArcGIS Desktop or ArcGIS Engine and gives developers a straightforward application programming interface (API) to enable snapping in custom tools. This blog entry introduces you to the snapping API and provides sample code that demonstrates how you can incorporate snapping into your own tools.

To implement snapping in a tool, there are two options available depending upon if the tool will be used while editing. If your tool will be used both inside and outside an edit session, you can implement snapping directly by going through the snapping extension. If your tool will be used exclusively within an edit session, you can access snapping indirectly through the Editor object, which takes care of most of the initialization work for you.

Implementing snapping via the extension
First, I am going to show you how to access the snapping environment directly using its extension. This is applicable for a tool that can be used both inside and outside of an edit session. To demonstrate this, I develop a simple tool that reports the x,y location of a mouse click at its snapped location.

I start by creating a tool add-in by following the directions from the SDK help topic, Building add-ins for ArcGIS Desktop. Then, with the help of Working with the ArcGIS snapping environment, I add the code required to enable snapping in the tool. After adding a reference to the ESRI Controls assembly, I can access and initialize the snapping environment in my tool’s Click event. For add-in tools, this event is the OnActivate method.

Next, I can use the cursor location returned from the tools MouseMove event and determine if it actually snaps to anything. If it does, then I update a variable with the snapped position.

The complete code sample is shown below.

using ESRI.ArcGIS.Controls;

using
ESRI.ArcGIS.esriSystem;
using ESRI.ArcGIS.Geometry;

namespace
ToolWithSnapping

{


public
class
ShowMapCoordinates
: ESRI.ArcGIS.Desktop.AddIns.Tool


{



ISnappingEnvironment m_SnappingEnv;



IPointSnapper m_Snapper;



ISnappingFeedback m_SnappingFeedback;



IPoint m_Position;


public ShowMapCoordinates()


{


}


Protected override
void OnActivate()


{



//Get the snap environment and initialize the feedback



UID snapUID = new
UID();



snapUID.Value =
“{E07B4C52-C894-4558-B8D4-D4050018D1DA}”
;



m_SnappingEnv = ArcMap.Application.



FindExtensionByCLSID(snapUID) as
ISnappingEnvironment;


m_Snapper =
m_SnappingEnv.PointSnapper;



m_SnappingFeedback = new
SnappingFeedbackClass();



m_SnappingFeedback.Initialize(ArcMap.Application,
m_SnappingEnv, true);


}


protected override
void OnMouseMove(MouseEventArgs
arg)


{



//Get the current position in map units



//This is the cursor location before snapping


m_Position
= ArcMap.Document.ActiveView.



ScreenDisplay.DisplayTransformation.ToMapPoint(arg.X, arg.Y);


ISnappingResult snapResult =
null;


//Try to snap the current position


snapResult
= m_Snapper.Snap(m_Position);


m_SnappingFeedback.Update(snapResult, 0);



if (snapResult != null)



//Snapping occurred



//Set the current position to the snapped location



m_Position = snapResult.Location;


}


protected override
void OnMouseDown(MouseEventArgs
arg)


{



System.Windows.Forms.MessageBox.Show(“Map units:rnX: “



+ m_Position.X.ToString() + “rnY: “ +
m_Position.Y.ToString());


}


protected override
void OnRefresh(int
hDC)


{



if (m_SnappingFeedback !=
null)



m_SnappingFeedback.Refresh(hDC);


}


}

}

In my code, the variable m_Position holds the snapped position of the cursor. If my tool were creating geometry or updating screen feedback (such as with INewLineFeedback), then I would use the m_Position variable rather than the mouse position (MouseEventArgs) as the update point.

Implementing snapping in an edit session
As I mentioned before, if you are developing a tool that will be used exclusively in an edit session, implement snapping with the help of the Editor object. The main advantage of doing this is that the Editor will work with either the ArcGIS Snapping Environment or editing classic snapping, but only in an edit session, of course. Classic snapping refers to the snapping functionality that was available during an edit session in ArcGIS 9 and allows you to set up snapping in a more complex manner on a layer-by-layer basis. The ArcGIS Engine edit sketch and any custom tools that derive it are limited to the classic snapping environment.

Generally speaking, there two types of Editor tools you can build: those that use the edit sketch and those that don’t. You would typically use the edit sketch in a tool if you wanted to use the sketch to help you create some geometry or feedback on the screen. You can then take that geometry and use it as the basis to create a feature with it or use it for selections. If you are creating an ArcMap tool that uses the edit sketch, you don’t have to worry about snapping at all since the Editor handles it entirely for you. The edit sketch also comes with its own context menu (the one used by the Polygon or Line construction tools) and shape constructors, so it’s convenient for developers. In ArcGIS 10, you can only build a tool that uses the edit sketch through COM, which creates a .dll.

If you are not using the edit sketch in your tool, which is most likely because it doesn’t provide the geometry you need, then there is a bit more work involved because you have to create your own geometry using mouse clicks and implement snapping yourself. This type of tool can be made into an add-in or COM .dll.

For the sample code, I’ll use the same example of an add-in tool that reports the x,y position of the snapped location. In this case, I only have to reference the Editor and not the Controls assembly to enable snapping.

using
System;

using
ESRI.ArcGIS.Editor;

using
ESRI.ArcGIS.Geometry;

namespace
ToolWithSnappingES

{


public
class
ShowMapCoordinatesES
: ESRI.ArcGIS.Desktop.AddIns.Tool


{



IEditor m_Editor =
null
;



IPoint m_Position =
null
;


public ShowMapCoordinatesES()


{


m_Editor =
ArcMap.Application.FindExtensionByName(“esriEditor.Editor”)
as
IEditor;


}



protected override
bool OnDeactivate()


{



if (m_Position != null)



m_Editor.InvertAgent(m_Position, 0);


m_Position
= null;



return true;


}



protected override
void OnMouseMove(MouseEventArgs
arg)


{



if (m_Position != null)



m_Editor.InvertAgent(m_Position, 0);


m_Position
= m_Editor.Display.DisplayTransformation.ToMapPoint(arg.X, arg.Y);



//Get the snap environment from the editor



ISnapEnvironment se = m_Editor
as ISnapEnvironment;



Boolean snapped = se.SnapPoint(m_Position);



m_Editor.InvertAgent(m_Position, 0);


}



protected override
void OnMouseDown(MouseEventArgs
arg)


{



System.Windows.Forms.MessageBox.Show(“Map units:rnX: “



+ m_Position.X.ToString() + “rnY: “ +
m_Position.Y.ToString());


}



protected override
void OnRefresh(int
hDC)


{



if (m_Position != null)



m_Editor.InvertAgent(m_Position, hDC);


}



protected override
void OnUpdate()


{


Enabled =
(m_Editor.EditState == esriEditState.esriStateEditing);


}


}

}

The code is very similar to the extension example, where the variable m_Position holds the snapped position and would be used to create geometry or update feedback. In this case, I have to be careful with refreshing the feedback. The code calls InvertAgent, which essentially paints the screen with the feedback of a blue dot. To erase the feedback, I need to call InvertAgent again. If I get out of sync, I can be left with feedback graphics on the screen that will not go away until I refresh the screen. Normally, though, if you are working with ArcGIS Snapping, the environment takes care of this for you.

For more information
To learn more about developing with the ArcGIS Snapping environment, see Snapping in ArcGIS in the ArcGIS Developer Help.

To view some example editing tools that incorporate snapping, see the Editing Labs group on ArcGIS.com (make sure to filter by Show: All Content at the top of the page).

Post content from Sean (Editing Team)

Posted in Developer, Editing | Tagged , , , , , , , , , , | Comments Off

Constructing features with precise measurements

In many scenarios, particularly in the built environment, you need to construct new features based on a series of measurements and offsets from existing features in your data.  Although ArcGIS supports a variety of ways to create features using a combination of snapping and constraints, more permanent construction geometries are appropriate in some scenarios.

Rather than resorting to storing construction lines in a feature class, an alternative method to support construction lines is with the temporary guide functionality available by installing the Construction Guides add-in written by Esri’s Editing development team. You can use the guides to build a series of geometries to assist you with completing complex constructions for use while creating new features and modifying the shape of existing features. The guides can be created with common editing constraint capabilities, such as making geometry parallel to an existing feature, at distance from a known location, or at a specific x,y coordinate. You can use snapping both when placing the guides and creating features in relation to them, allowing you to precisely locate a position based on the construction guide geometry.

To use the Construction Guides add-in, download it from the Editing Labs group on ArcGIS.com and double-click the file to install it on your machine. When you start ArcMap you have access to the Guides toolbar, which hosts all the tools to create and manage the temporary geometries that can be used in constructions. Creating construction guides is a straightforward process. You just click the type of guide on the Guides toolbar and define its geometry on the map.  You can do this interactively, or if you have specific values to enter, the tools support the ability to specify them using keyboard shortcuts.


To illustrate how the guides can be utilized during feature creation, I am going to digitize a new residential building with them. Once I position the guides, I use the regular feature construction tools to create the building feature. I have been given several measurements that I can use to place the guides, and ultimately, the new building. The northwest corner of the building is 12.5 feet from the corner of the lot. To locate this position, I first use a circle guide and snap to the corner of the lot to place the center point of the circle.  I then drag a circle, but rather than clicking to define the circle’s diameter interactively, I can press the R key and enter 12.5 to define the radius. I also know that the edge of the building is offset eight feet from the western lot boundary.  I can use the Line Guide tool to create a guide from that lot boundary and specify a distance of eight feet by pressing the D key. Similar to entering values in built-in editing dialog boxes, guide measurements are entered in map units.

With these two guides in place, I can now begin to create the building feature. Since the rresidential building is rectangular in shape, I can use the Rectangle construction tool to create it. To place the first corner of the building, I need to turn on Intersection Snapping from the Snapping toolbar and snap to the intersection of the circle and line guides.

Once I have created the corner of the building at that intersection, I set the orientation of the building in the lot by snapping along the line guide I created from the lot boundary. I can then right-click to access a menu that allows me to enter the length and width dimensions of my building.

The building feature is completed once I finish entering the measurements. The guides remain after the feature is created, so I could continue to use them for other editing tasks. In this case, I don’t need them any longer, so I can click Clear Guides to remove all the guides.

This is just one illustration of using guides to locate features precisely.  In future blog posts, I’ll explain how this sample was developed and how you can extend your own code to utilize some of the same capabilities shown here.

Introducing Editing Labs on ArcGIS.com
The Construction Guides add-in is one example of how Esri’s Editing development team is building tools, prototypes, and practical examples and sharing them with you. We are adding these to an ArcGIS.com group called Editing Labs, which provides an opportunity, along with the ArcGIS Ideas site, for you to share feedback on some work that the Editing team is investigating. Tell us what you think about Construction Guides and our other samples by adding comments on the individual items in the Editing Labs group.  We’ll be adding new content regularly to Editing Labs, so check back often.

Content provided by Doug (ArcGIS Editing Team)

Posted in Editing | Tagged , , , , , , | Comments Off

Preparing a map for editing: Using basemap layers effectively

When editing, you can incorporate basemap layers into your map to increase productivity. If you have a complicated map, such as a water utility network containing many detailed features and underlying background layers, you can spend a lot of time waiting for the map to refresh whenever you pan or zoom. With ArcGIS 10, you can minimize this by creating a basemap layer containing the contextual reference layers that you are not editing, such as imagery or streets.

A basemap layer is a special type of group layer that is drawn using optimized map display logic that utilizes a local cache to refresh the map quickly. Basemap layers also help reduce network traffic since ArcMap does not need to contact the server repeatedly to retrieve the map extent. To create a basemap layer, right-click the data frame name in the table of contents, click New Basemap Layer, and drag the layers into it. Although a basemap layer can contain any layer format, such as feature classes, shapefiles, Web services, or rasters, some content types are more appropriate for use in basemaps. This post shows you how to identify layers suitable for basemaps, use the editing environment with basemaps, and improve your basemap performance.

Choosing the layers to be in a basemap layer

To use basemap layers effectively, they should truly form a basemap beneath the layers that you are editing. If you edit data for a water district, your operational layers, such as manholes, water main lines, and valves, cannot be part of a basemap layer because you need to edit them and have the features be drawn dynamically to access the latest updates from their data sources. However, any supporting reference layers that you normally display underneath the utility data can be placed in a basemap layer for enhanced performance. For example, you could include a land base of parcel boundaries, buildings, streets, and other built features, as well as imagery layers, in one or more basemap layers. The layers in the basemap look the same as they did before; they just draw faster now. Here is an example table of contents showing the kinds of underlying layers that could be basemap layers.

Basemaps tend to be relatively static and typically are updated on an infrequent basis. Rasters and service layers are good candidates for basemap layers because they are stable and can benefit greatly from improved drawing speed. ArcGIS Online, for example, provides imagery, topography, streets, and other content from several different sources that you can use in your maps. If you click the arrow next to the Add Data button and click Add Basemap, you can add layers from ArcGIS Online directly into a new basemap layer.
Editing when basemap layers are in the map
Because basemap layers are cached, there are limitations on what you can do with them. For example, you cannot edit the layers in a basemap or change the layer symbology. If you need to make edits or layer updates, drag the layer out of your basemap, make the changes, and drag the updated layer back into the basemap layer.

If you attempt to start an edit session with an editable layer in the basemap, ArcMap shows you a warning message. You can edit all the other layers in that workspace, but you cannot edit the layers in the basemap even if they belong to the same geodatabase. If the basemap contains any layers that are related to other editable layers through relationship classes, topologies, geometric networks, or parcel fabrics, or shares data sources with layers outside the basemap, you cannot start editing at all until you move the layer out of the basemap. You can double-click an entry in the Start Editing dialog box to open an ArcGIS Desktop Help topic containing more information on how to fix these and other issues that occur when you start editing.

Although you cannot edit the layers inside a basemap, you can snap to feature layers in a basemap layer. For example, if you were creating a new waterline in relation to building locations, you can still snap to the Building Footprints layer even though it is inside the basemap.

Improving basemap layer display and performance

With basemap layers, you can pan continuously and smoothly by pressing the Q key or holding down the mouse wheel. The rest of the map layers are redrawn once you release the key or the wheel button. If you find that the layers on top of the basemap are difficult to see, you can dim the display of the basemap using the Effects toolbar. This makes the basemap appear washed out and partially transparent, helping your operational layers stand out more. This can be useful for editing, especially in cases where your basemap layers contain orthographic images or other richly colored content that may obscure the details of layers on top of them.

Once you create a basemap layer, you can run diagnostic tests to check its performance. You can do this by right-clicking the basemap layer and clicking Analyze Basemap Layer to display a window listing ways you can speed it up even further. You might see messages indicating that the layer is being projected on the fly or uses complex symbology, which can slow down drawing. For example, the message “Layer draws at all scale ranges” is a suggestion to set a visible scale range on the layer since there is no need to display the layer when the features are too detailed or too coarse at certain map scales. You can right-click an entry to open the Layer Properties dialog box, where you can resolve many of the issues to get the most out of basemap layers.

Data used in the examples is modified from the Water Network Utilities Template by Esri and Fort Pierce, Florida.

For more information, see Working with basemap layers and About edit sessions in the ArcGIS Desktop Help.

Posted in Editing, Imagery | Tagged , , , , , , , , | Comments Off

Using snapping effectively in ArcGIS 10

Snapping allows you to create features that connect to each other so your edits are more accurate, with fewer errors. In ArcGIS 10, you can choose from one of two snapping environments to use when you are editing. The default is the new Snapping toolbar, which is flexible, easy-to-use, and has more snapping types, more options, and better feedback. Alternatively, you can enable classic snapping, which provides fine-grained control over the snapping environment. This post provides an overview of each environment, so you can decide which one allows you to get your editing done most effectively.

Snapping toolbar (the default snapping environment)
The Snapping toolbar is the central location where you manage the snapping settings. There is minimal setup required, since the most common snapping types are enabled by default. The Snapping toolbar environment is used by the editing tools, but is also available outside of an edit session and is used by other parts of ArcGIS, such as georeferencing and the Measure tool. Snapping is also part of ArcGIS Engine, so you can build custom applications that utilize snapping.

Snapping is managed at the map level, so whenever a snap type is turned on, you can snap to any visible feature layer. This also includes layer types that are not editable, such as basemap layers or CAD files. You cannot snap to features that are hidden from the map, though, including when the layer is turned off, has a definition query (visible features in the layer can still be snapped to), and is beyond the layer scale range. Snapping is useful when creating new features or when editing existing ones, such as by reshaping edges, splitting lines or polygons, moving features, or editing features in a topology.

The Snapping toolbar has buttons to enable snapping to points, edges, vertices, and ends, which are all on by default. The order in which snapping occurs to certain types is determined automatically; the highest priority is given to snapping to sketch elements. To turn on or off individual snap types, click them on the toolbar. If you want to stop snapping temporarily, hold down the space-bar. To turn off snapping altogether, uncheck Use Snapping on the Snapping menu.

To set options for working with the ArcGIS 10 snapping environment, click the Snapping menu and click Options. From there, you can set the snapping tolerance in pixels, which is the distance your pointer needs to be from a feature for snapping to occur, or customize the snapping feedback. As you move your mouse pointer, you get visual cues in the form of pop-up SnapTips and the pointer icon to tell you the layer you are snapping to and with which snapping type. You can change the color of the icon and the content, font, and color of SnapTips. When you are working over imagery, add a background to the SnapTip to place a solid fill behind the text so it is easier to read. Your snapping settings apply to all your ArcMap sessions since they are saved in the registry for the application.

Each snapping type (vertex, edge, endpoint, intersection, and so on) has its own pointer icon, which matches the buttons on the Snapping toolbar. For example, the pointer is a square with lines inside it when you are snapping to an endpoint and becomes a box with diagonal lines when you are snapping to an edge. In the following example graphics showing streets and parcels, you can see the SnapTips with the layer name and the snap type. When creating a new road, snap to the existing endpoint (Streets: Endpoint) so the segment connects to it. If you need to create a building footprint at a parcel boundary, snap to the Parcels: Edge.

On the Snapping menu, you can enable snapping to an intersection, segment midpoint, or curve tangent point. These additional snap types are only available with the new snapping environment. For example, intersection snapping allows snapping to locations where two features intersect but there may not be any defined vertex or endpoint there. You might use intersection snapping when you are adding points at street intersections or dividing a feature where it meets another feature. If you need to split a park where a stream crosses it, you can turn on intersection snapping, then select the park polygon, click the Cut Polygons tool on the Editor toolbar, snap to the first intersection, and use Trace to follow along the stream’s edge. When you have traced across the park, snap to the other intersection and finish the sketch to cut the park into two features.

Since you can snap to any visible features in a layer, you may need to spend some time authoring your map. If you find you are snapping to layers you don’t want to snap to, make sure you need that layer to be displayed in the first place. By turning off unnecessary layers, disabling certain snap types, setting layer scale ranges, and making sure your labels and symbols are as descriptive as they can be, you can use the Snapping toolbar more effectively.

Classic snapping
Classic snapping is the snapping environment that you may be familiar with from ArcGIS 9. Classic snapping is available to you in cases where you need more control over the way snapping occurs or if you are working with a part of ArcGIS that uses only classic snapping, such as tracing with the ArcScan for ArcGIS extension and editing in ArcScene and ArcGlobe. When classic snapping is enabled on the Editing Options > General tab, editing tools only use the classic snapping environment. However, georeferencing tools, the Measure tool, and other non editing tools continue to use the snap settings on the Snapping toolbar.

Classic snapping allows you to manage the individual snapping types, layers, and priorities. In classic snapping, snapping settings are specified for each layer and type (vertex, edge, or end) in the Snapping Environment window, which you open by clicking the Editor menu, pointing to Snapping, and clicking Snapping Window. No snapping occurs until you check some boxes in the window. You can drag and drop layers up and down the list to change the snapping order; layers at the top will be snapped to before layers further down the list. To snap to points, check the Vertex box since there is no specific point snap type in classic snapping.

To set options for classic snapping, click the Editor menu, point to Snapping, and click Options. From there, you can change the snapping tolerance in either pixels or map units and turn on SnapTips, which are off by default. SnapTips with classic snapping cannot be customized (they will always show the layer and type) and are opaque yellow, rather than the semitransparent SnapTips available with the Snapping toolbar. The setting for enabling classic snapping is stored in a map document; its options are saved in the ArcGIS registry.

Enabling classic snapping is most useful for complicated maps with lots of overlapping layers. When working with complex utility data, for example, classic snapping may be beneficial because you have many features in one location, but need to snap easily to a particular feature and in a certain order. If you are creating water mains, you could move that layer up in the list so new mains snap to existing mains first and set whether they should snap at vertices, edges, or ends. Since utility data often has many point features, you can reorder the point layers in the list so new lines connect to certain points, such as system valves or hydrants, before they snap to other types of point features. If you do not want to snap to a particular layer at all, uncheck it from the list. However, features not visible because of definition queries can still be snapped to when you are using classic snapping.

This kind of fine management of the snapping environment is only possible with classic snapping. However, this also takes a lot of work to maintain and set up, considering that each layer in the map is listed in the window and has three separate boxes to check. So, if you are trying to snap to a feature but no snapping occurs, you have to sort through a potentially lengthy list of layers and checkboxes to enable the snapping. With the Snapping toolbar, snapping is on for all layers.

Summary
Each snapping environment has trade-offs of ease versus control that you need to evaluate. Some users have reported that they were skeptical of the Snapping toolbar at first and immediately went back to classic snapping because they were familiar with it, but eventually spent time using the Snapping toolbar and loved it. The Snapping toolbar might take some time to get used to, but its simplicity and power should meet the needs of most editing tasks. However, you can switch between the snapping environments at any time on the Editing Options dialog box so you can use the one that is most appropriate for your current work.

Data credits:
Data used in the examples is from the Water Network Utilities Template by Esri and Fort Pierce, Florida.

For more information:
About snapping
About the editing classic snapping environment

Content provided by Rhonda (Editing Team)

Posted in Editing | Tagged , , , , , , | 5 Comments