Tag: Editing

Implementing a feature template dialog box in your code

In ArcGIS 10, feature templates define all the information required to create a feature, such as the target layer and the attributes the new feature will receive. Most of the time, you interact with feature templates on the Create Features window. However, some editing operations present a dialog box containing templates that you can choose for the output for that particular feature creation workflow. For example, the Select Feature Template dialog box used with the Editor menu > Buffer command allows you to set the feature template that will be used to create the new buffer feature. The list of templates is filtered to show only editable and visible polygon or line layers in the map; feature templates for other templates are hidden and cannot be used for the buffer output.

If you are developing a custom command or tool that requires the user to specify a feature template for the output of your workflow, you have two options for working with or presenting feature templates in the map. You can require the user to select a template from the Create Features window or you can implement a feature template dialog box that works similar to the Buffer command. Often, implementing your own feature template dialog box is the better option, as you can ensure the user has specified a template that meets the criteria of your customization. For example, you may only want the user to choose from templates from certain layers or those that are of a particular geometry type.

If you decide to create your own template dialog box for a customization, you can start by downloading a sample that Esri has created and shared in the Editing Labs group on ArcGIS.com. This sample is a Visual Studio 2010 project written in C# that creates an add-in containing simple dialog boxes to display templates. The sample was modeled after the template dialog box from the Buffer command and contains the same controls and considerations for displaying feature templates. You can use some or all of the functionality from this sample for your own customization. It is important to note that the dialog box can only display existing templates; you must create, delete, and manage templates for layers as usual through the Organize Feature Templates window.

Using the Template Dialog Sample command
The sample creates an add-in command that provides a similar chain of dialog boxes as Buffer: clicking the command opens a dialog box containing a button that opens another dialog box with a list of feature templates. The command is called Template Dialog Sample, which is TemplateAppButtton.cs in the Visual Studio project. To explore the sample’s functionality in ArcMap, compile the project or install the add-in that accompanies the download. Then, drag the Template Dialog Sample command from the Customize dialog box > Commands tab > Editing Labs category and place the button onto any toolbar. The command is only enabled when you are in an edit session.

Click the Template Dialog Sample button on the toolbar to which you added it to display the template application form (TemplateAppForm.cs). Click the Template button on the Template App Form dialog box to open the Template Picker Form (TemplatePickerForm.cs). Similar to the Select Feature Template dialog box opened from the Buffer command’s dialog box, the Template Picker Form allows you to choose a template and search for templates by name, tag, and layer.

In this sample, the Template Picker Form displays feature templates from all visible point, line, and polygon layers in the current editing workspace. If you want to enable filtering by geometry type, for example, you can modify the sample code through an enumeration in TemplateAppForm.cs when calling the TemplatePickerForm.

Most of the internal work in the sample occurs in the TemplatePickerForm class. This class contains a Visual Studio ListView control to display the templates as ListViewItems arranged into ListViewGroups that represent the layers. Selecting a template sets the _currentTemplate variable back on the add-in button, which can be used to set the current Editor template target on IEditor3.CurrentTemplate. The template can then be used to help you create new features as described in the Working with templates section in the Using feature templates help topic.

Content provided by Sean (Editing Team)

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

Implementing topology through Python scripting

Geoprocessing can be used to automate many aspects of data compilation, including implementing a geodatabase topology. In my previous post, I created a model that imports data into a file geodatabase and performs initial data cleanup processing. Now, I will use geoprocessing with Python scripting to build a topology on the imported data. Although many spatial integrity issues were resolved by running the model, a geodatabase topology can help check for and repair any remaining errors.

The dataset I am using is a feature class of parcel lot line boundaries that began as a CAD file full of topological inconsistencies, such as lines that overlapped or did not connect to other lines. Once I create the topology and am sure the lines are correct, I will build parcel polygons from the lines and introduce all the features into my production enterprise geodatabase.

Creating a topology in a script
To build topology in an automated manner, I am going to write a simple Python script, add it to a toolbox, and run it as a regular geoprocessing tool. Essentially, the script just performs the functions of the New Topology wizard, but without requiring my intervention. In fact, this script could be developed without any programming by creating a model to perform these tasks and exporting it from ModelBuilder as a Python script.

When scripting, the ArcPy site package allows Python to access and run any of the geoprocessing tools in the ArcGIS system toolboxes, including the topology tools. The Topology toolset in the Data Management toolbox contains all the tools I need to add a geodatabase topology to the line feature class. The import arcpy statement adds ArcPy to a script and is at the top of every ArcGIS Python script.

Before I start adding the tools to the script, I define variables for the paths to the feature dataset, feature class, and topology. Because I created folders to store my tools and data following the recommendations in A structure for sharing tools, I can make the script more portable by setting these paths in relation to the folder containing the script. Since the folder locations are not hard-coded to match the C: absolute path of my hard drive, the script should run on someone else’s machine regardless of the machine’s directory structure.

With the paths defined, I first use the Create Topology tool to add a topology to the feature dataset. The syntax for the tool in my script is arcpy.CreateTopology_management(featureDataset, topologyName, “”), where CreateTopology is the name of the Create Topology tool,  _management is the toolbox in which it resides, featureDataset is a variable I defined earlier representing the path to the feature dataset, and topologyName is a variable for the name of the topology. When working with topology, it is recommended to use the default cluster tolerance, which is the distance in which vertices are determined to be coincident. Since I want ArcGIS to calculate the cluster tolerance, I left the value blank as “”instead of supplying one.

Although that function creates a topology, it is currently empty and has no classes or rules in it. I can use the Add Feature Class To Topology tool to add my line feature class with the statement: arcpy.AddFeatureClassToTopology_management(topology, featureClass, “1″, “1″). If the topology contained multiple feature classes, I can set ranks so the feature class with the highest accuracy is not adjusted to match vertices in a feature class which is known to be less accurate. However, since I am using only one feature class, I leave the rank parameters as “1″.

Next, I set which topology rules to include by calling the Add Rule To Topology tool. When choosing which rules to add to a topology, there are a few rules that many editors commonly add to every topology, such as the line rule for Must Not Have Dangles. In the script, this rule is coded as arcpy.AddRuleToTopology_management(topology, “Must Not Have Dangles (Line)”, featureClass, “”, “”, “”). Because the rule only applies to one feature class that does not have subtypes and is not a rule between two feature classes or subtypes, the other parameters are left blank. I also want to make sure that the lines do not overlap or intersect themselves, so I include the Must Not Overlap and Must Not Self-Intersect rules as well. If I need to add more rules later, I can run the Add Rule to Topology tool or use the topology’s Properties dialog box in the Catalog window.

Once all the feature classes and rules have been added, my script validates the topology. The Validate Topology tool identifies features that share geometry, inserts common vertices into features that share geometry, then performs integrity checks to identify any violations of the rules that I defined for the topology. Since the topology has never been validated before, I am going to validate the entire extent of the data with the syntax, arcpy.ValidateTopology_management(topology, “Full_Extent”). However, when working in ArcMap, validating the visible extent of the map instead of the full extent limits the area to be validated and can be useful for very large datasets that take a long time to validate.

Finding and fixing topology errors
After the script runs, I add to ArcMap the resulting topology so I can inspect the results and fix any errors using the ArcMap editing tools. However, with all the previous automated QA work from my Import and Clean Lines model, the remaining manual edits are minimal in comparison to what they could have been without running it first.

The errors identified with topology are indicated by the orange-colored squares. Almost all of these are dangle errors that could not be fixed by the original model since they exceeded the tolerance value for the Extend, Trim, or Snap tools. The topology found only two Must Not Overlap errors, which I can fix by deleting one of the overlapping features. There are no violations of the Must Not Self-Intersect rule, indicating that the lines were split properly in the model. Using the editing tools on the Topology toolbar, such as the Error Inspector and Fix Topology Error tool, I can review each error to determine if the built-in topology fixes can be used or if the lines should be edited manually to resolve the topology error.

In some cases, the topology error may need to be marked as an exception, which is a valid violation of a topology rule. One of the most common examples of exceptions to the Must Not Have Dangles rule is a cul-de-sac road, which are dead ends that do not connect to other roads. However, when working with parcel lot lines, there are fewer scenarios that are valid exceptions. I do have some lines at the edges of the dataset that do not connect to other lines. I can either mark these as exceptions or choose to delete the features, depending on whether these features are supposed to connect to existing features in my enterprise database.

If an edit is made to correct a topology error, I have to validate the topology again to make sure the error no longer exists. After I perform a visual inspection and fix all the remaining topology errors, I can create new polygons representing landownership parcels using the geometry of the lines. If I attempted to create polygons from lines that do not connect to each other properly, either no polygons would be created or one large polygon would result where there should actually be two polygons. After creating the new polygons, I add the polygon feature class to the topology and check for any gaps or overlaps and make sure the parcel polygon boundaries are always coincident with the lot lines.

After implementing the topology and making edits in ArcMap, the lines and the polygons created from them meet standards for our spatial data. I can now introduce the features into the production enterprise geodatabase.

While a script tool or model may take time to set up initially, in the long run, it is quicker to automate data compilation tasks through geoprocessing whenever possible. I can run a tool as needed and re-run it later with different parameters and tolerances or apply it to other datasets. Scripts are particularly useful because they can be run at specified times as a scheduled task in Windows. For example, I could combine the tools presented in these blog entries into a Python script that imports a dataset into a geodatabase, processes it, and implements topology. If I set the script to run automatically in the evening after working hours, I am ready to start editing on clean data when I come into the office the next morning.

For more information:
The sample tools and data can be downloaded from the Editing Labs group on ArcGIS.com. An ArcInfo license in required to run the tools.

Content provided by Rhonda (Editing Team)

Posted in Analysis & Geoprocessing, Editing, Python | Tagged , , , , , , , , , , | Comments Off

Cleaning up line data with geoprocessing

Editing and data compilation are less commonly thought of as operations that can be automated through geoprocessing. However, ArcGIS 10 introduced the Editing toolbox, which contains a set of geoprocessing tools to perform bulk edits. These tools combined with others in the geoprocessing environment can automate data import and maintenance work. Automated data compilation tools are especially useful for importing data into a geodatabase but can also be employed on a regular schedule to perform routine quality assurance (QA) checks. In this entry, I will discuss the use of geoprocessing to clean CAD line data as part of the import process.

Importing data with geoprocessing
Lines that are created without the use of spatial integrity measures, such as snapping or topology, almost always contain some inconsistencies. These errors are likely in data that originated in formats such as CAD, shapefile, or KML.  Fortunately, many common topological issues can be resolved in an automated manner by using ModelBuilder to link together tools that will import data into a geodatabase and perform standard data cleanup techniques.

I have a CAD file for a new subdivision that needs to be integrated with my existing GIS parcel data. The GIS data must be kept to stringent accuracy standards, so I need to fix any issues where lines do not connect to each other, overlap, or are duplicated. Rather than risk reducing the quality of the main parcels geodatabase, I can create a local temporary geodatabase where I can preprocess the CAD lines before introducing the features into the production geodatabase. Although the CAD file contains buildings, roads, text, registration tic marks, and other features, I plan to use only the parcel lot lines.

I have built a model that imports the CAD lines into a temporary scratch workspace, cleans and processes the lines, and then copies the corrected lines into an output file geodatabase. When importing CAD data into a geodatabase, I can choose from several available tools, including CAD to Geodatabase or Feature Class to Feature Class. The CAD to Geodatabase tool converts all the geometries in a drawing to individual feature classes, such as a line feature class for the parcel lines, annotation feature class for CAD text, and so on. In my case, I am using Feature Class to Feature Class tool because I need only the lot line geometry from the CAD file. This tool makes the model reusable because it can import many different formats and not simply CAD. In addition, the Feature Class to Feature Class tool allows for an SQL expression so I can further refine the import to include only the CAD features that satisfy an attribute query for lot lines (in this case, “Layer” = ‘LOT-L’).

Performing automated quality assurance on lines
Once the CAD parcel lot lines are imported into a geodatabase feature class, I can begin running tools to perform automated QA processes. Many tools are found in the Editing toolbox, although other toolboxes can be purposed for data compilation QA tasks. For example, I can start by using the Integrate tool in the Data Management toolbox to address minor inconsistencies in the line work. Integrate makes features coincident if they fall within the specified x,y tolerance. By using a small tolerance on Integrate (and other similar tools), I can avoid editing the data beyond the level of cleanup I intended. In addition, since I am running the tools on a copy of the data outside my production database, I can run the tools repeatedly to refine tolerance values to fix more issues in an automated manner. The intermediate data created as the model runs is maintained and can be reviewed in the scratch geodatabase.

After the dataset is integrated, I check for duplicated lines with the Delete Identical tool (Data Management toolbox). The dashed lines connecting to this tool represent preconditions, which are used to control the order of operations in a model. For example, the Integrated Lines output is a precondition to the Delete Identical tool. This way, the Delete Identical tool will not execute until the lines have been integrated.

The next part of the model identifies lines that are dangles. With the Feature Vertices to Points tool in the Data Management toolbox, I create a new point feature class containing the line endpoints that are not connected to any other lines. I can then use Select Layer By Location to identify the lines that intersect these dangling endpoints. The resulting selection represents lines with dangles.

Many of these dangle errors can be fixed by running the Editing toolbox’s Trim Line, Extend Line, and Snap tools. Effective use of the Editing toolbox geoprocessing tools can improve productivity because the tools apply edits in bulk, such as to all features or all selected features. In most cases, the similar editing function applies to only one feature at a time. Because I exposed the tolerances as variables and model parameters, I can easily run the model with different values because the tolerance settings appear as input boxes on the tool’s dialog box. For example, I am willing to extend or trim the lines from this CAD dataset initially up to a maximum length of five feet. After that procedure, I want to inspect the lines visually to see how many issues remain to ensure that I will not be making incorrect edits if I increase the tolerance value. I can change the tolerance as needed depending on the accuracy of the lines I am importing.

In addition, since my organization’s spatial integrity rules indicate the parcel lines should be split and not intersect themselves, I can use a sequence of spatial and attribute queries to find the locations where lines have intersecting endpoints. Lines are often split so that each length can be attributed separately.

Once these processes have run, the lines are output into a feature dataset in a geodatabase and are much cleaner topologically. After the model completes, I can run the Feature Vertices to Points tool again on the cleaned output to see the remaining dangles and compare the current number of endpoints that are dangles (the yellow circles in the graphic) to the number in the original CAD lines (the red circles). While there may be a few remaining issues, there are less than before running the model. At this point, I can build a geodatabase topology to check for and repair any other errors. When I am satisfied that the lines meet the standards for our spatial data, I can import it into the production database.

For more information:
The sample tools and data can be downloaded from the Editing Labs group on ArcGIS.com. An ArcInfo license in required to run the tools.

Posted in Analysis & Geoprocessing, Editing | Tagged , , , , , , , , , | 2 Comments

Managing layer visibility and selections

Managing layer visibility and selections with the table of contents’ List By Visibility mode

The table of contents in ArcGIS 10 has several ways of listing the layers in the map: by drawing order, source location of the data, whether layers are visible, and whether layers are selectable. A particular list type may be more useful than others depending on the current mapping task. For example, List By Drawing Order is best at setting which layers draw on top of others and List By Source works well to help repair broken data links for layers from different workspaces. In an earlier post, I focused on the table of contents’ List By Selectable mode when I wrote about refining the selected features while editing. In this post, I am going to show how I can use List By Visibility to manage layer visibility and selections.

Continue reading

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

A Spatially Enabled Document Management System

We all know managing spatial data, map products, and documents are critical to the success of any GIS work being performed. When producing many versions of your map documents and outputs, current databases and file systems are not well equipped to simultaneously manage these. And it can be a daunting task to manage changes to these files, including knowing which version is the latest and being able to access historical versions if necessary. Also, conflicts may arise when files are not centrally managed which can compromise a schedule or budget, introduce unnecessary risks, and jeopardize the success of your work. Typically, you would use the geodatabase for spatial data storage and management, SharePoint for document management, and maybe a file server for your map product management. If you’re looking for one tool that could do all of these and more, you are reading the right blog post!

Continue reading

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

Fresh additions to the ArcGIS.com Editing Labs group

After hearing your feedback at the 2011 Esri International
User Conference, we on the Editing development team have been busy resolving
some of the workflow issues reported with ArcGIS 10. At your request, we have
developed two new tools for creating smooth curves and another one to cut
circular holes in polygons. You can download these tools from our ArcGIS.com
group called Editing
Labs
, which we use as a repository for prototypes and samples to extend the
ArcGIS 10 editing environment (make sure to filter by Show: All Content at the
top of the page). This blog entry highlights the new add-ins available from
Editing Labs.

Curved Construction
Tool

ArcSketch was a free add-on for ArcGIS 9 to support “back of
the napkin,” GeoDesign-style workflows, such as redlining features and
sketching land-use plans. Features could be created quickly by picking a symbol
on a palette, choosing a tool, and clicking the map to draw it. ArcSketch was deprecated
at ArcGIS 10 when this symbol-based feature creation workflow was incorporated
into the core editing experience through feature templates and the Create
Features window.

A user we spoke to at the UC wants to map zones for receiving
aircraft navigation radio signals by connecting known points with smooth
curves. In ArcGIS 9, he used the Curved Polygon tool in ArcSketch to draw these
features, but we were left scratching our heads about how to perform this task as
easily using the construction tools available in ArcGIS 10. So, we got to work
building a new sample for Editing Labs called the Curved Construction Tool.

Once I download and install the Curved
Construction Tool
, the Curved tool appears in the tools list on the Create
Features window when I activate a line or a polygon feature template. The
Curved tool allows me to create lines and polygons with curves that are splined
through fixed points. In my case, I am going to use the Curved tool to connect
points representing water sampling locations at springs (shown by the blue
circles on the map) to draw a polygon of a hydrologic study area.

I start the curved feature with a single click and add
subsequent points with clicks. I can utilize the snapping environment to snap
to the existing sampling point features when setting the locations through
which the curve passes. After I have digitized all the curves, I finish the
sketch. When creating polygon features, they are closed automatically with a
curved segment.

Each location I click becomes a vertex shared by adjacent Bézier
curves. The curve is defined by the locations of those vertices and additional
control points at the end of blue Bézier handles that radiate from each vertex.
If I want to reshape or move the curves manually, I can double-click the
polygon with the Edit tool.

Auto Complete
Freehand Tool

Several users told us they want to use freehand shapes to
create adjoining polygons. For example, members of a wildland search and rescue
group need to draw search areas and add adjacent polygons as the search
expands. The existing Auto Complete Polygon tool appends new polygons next to
existing ones, but the editor has to click to place each vertex. The Freehand
tool, on the other hand, creates smooth curves that follow movements of the
mouse without needing to click to create vertices, but the tool does not append
to existing polygons. Therefore, we developed the new Auto Complete Freehand
tool to combine the functionality of these tools.

As with the other sample, once I download and install the Auto
Complete Freehand Tool
, the new tool appears in the Create Features window
when I activate a polygon feature template. I am going to use the tool to
digitize adjoining polygons representing vegetation types by tracing over a
basemap image. Starting from the boundary of an existing polygon in the same
vegetation layer, I click once to start the freehand line. I do not need to
hold down the mouse button as I am creating the new polygon’s shape. The new
polygon’s boundary follows the movements of my pointer, although I can hold
down the spacebar if I need to snap to an existing feature.

The new polygon’s boundary must cross or touch the existing
polygon edge at least two times.  I just
need to click once to finish drawing the freehand shape and create the feature.
The freehand line is automatically smoothed into Bézier curves, although the
existing segments that are shared with the new feature are not smoothed. The
vegetation polygons now share a border, but the Auto Complete Freehand tool
allows me to avoid digitizing that edge twice or creating overlaps or gaps
between polygons.

Cut Polygons With
Circle Tool

We heard from a couple of users who want to cut a polygon
with the shape of a circle. For example, one user works with farmlands that are
irrigated by center-pivot systems and needs to cut out the circular-shaped
fields from the surrounding acreage. Another user edits circular oil tanks and
wells that should be cut from the well pad features. These users had found a
simple way of doing their tasks in ArcGIS 9, but ArcGIS 10 requires two steps: drawing
a circle feature and using the Editor menu > Clip command to cut out the
circle. In addition, Clip is inadvertently causing them to edit more features
than intended, since it cuts all visible and selectable polygons underneath the
selected feature. After hearing these scenarios, we created the Cut Polygons
With Circle Tool add-in for Editing Labs so these tasks could be performed
easier in ArcGIS 10.

Using the example of center-pivot irrigation fields, I am
going to cut out actively growing crops from the surrounding perimeters.
Center-pivot is a form of crop irrigation in which equipment rotates around a
hub, creating a circular pattern of irrigated cropland that is often visible in
aerial photography. Once I install the Cut
Polygons With Circle Tool
add-in, I need to open the Customize dialog box
in ArcMap and drag the command onto a toolbar, such as the Editor toolbar.

Next, I select the agricultural field and click the Cut
Polygons With Circle tool on the toolbar to which I added it. Using the imagery
as a guide, I click to place the center of the circle at the field’s central
pivot point. I could have also used the A key to enter x,y coordinates for the
center point. A line representing the radius appears inside the circle as I
draw it. I can drag the circle manually, or since I know that the radius of the
field is 200 meters, I can press R and type the value.

After entering the radius, I press ENTER to finish the
circle and cut the polygon. This leaves me with two features: the outer perimeter
that now is a multipart feature with a hole in it and the inner circle. Since
the circle represents the actively irrigated crop area, I update the feature’s attributes
now that it has a land-use type different from the surrounding field.

Giving us feedback
Please let us know what you think of these tools by adding a
comment to their download pages. We have been uploading samples to Editing Labs
regularly, so check back for new additions. When accessing the Editing Labs
group, make sure to filter by Show: All Content at the top of the page. You can
submit general suggestions on how we can improve the editing experience by adding
to the ArcGIS Ideas site or contacting Esri Support. In addition, we encourage
you to join the ArcGIS 10.1 beta
program
to preview and provide feedback on the next release of ArcGIS.

Special thanks to the UC attendees who spent time helping us
understand their needs.

Post from Rhonda G. (Editing Team)

Posted in Editing | Tagged , , , , , , | 1 Comment

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

Leveraging the Parcel Fabric data structure to improve parcel map annotation workflows

Here is an interesting blog post from the Parcel Editor team for those of you who are looking to optimize your parcel editing workflows and reduce the amount of time you spend annotating your tax parcel maps.

In the parcel fabric, the parcel name text field is used to store the parcel identification number (PIN). This PIN is sometimes called APN (Assessor Parcel Number) or AIN (Assessor Identification Number) and other conventions. This number is usually kept unique by constructing it from the book, page and a sequential number, as well as similar methods. The field might store “264014001” which stands for Book 264 Page 014 Parcel 001 and can be formatted to show “264-014-001”.

Best practices include the use of label classes to show the full PIN when zoomed in and only the last 3 digits when zoomed out.

  • Label expression: to separate the parcel number by dashes you can use a label expression similar to this:  Left([Name],3) & “-” & Mid([Name],4,3) & “-” & Right([Name],3)
  • MapTips:  some users prefer to only label the last 3 digits and use a MapTip to show the parcel number when hovering over the parcel.

 

  • To do so, activate your MapTip in the Layer’s Display Tab.

  

  • To get the MapTip in the example above, use the following expression:
    ” Book: “& Left([Name],3) & vbNewLine & ” Page: “&  Mid([Name],4,3) & vbNewLine & ” APN:  ” & Right([Name],3)
Posted in Local Government | Tagged , , , , , , , , , , , , , , , | Leave a comment

Parcel Editing Workflows at ArcGIS 10 – Alley Vacations (Part 2)

Here is the second part of a blog post from the Parcel Editor Team.  Another approach to alley vacations in ArcGIS 10. 

In a previous post, we talked about how to perform a vacation of an ally or right-of-way parcel using the parcel fabric data model in conjunction with the Local Government Data Model and the Tax Parcel Editing Template from the resource center.  For this post we are going to talk about the same process, but without recreating the original lots.  As with the previous post, we will be working through an example provided by the City and County of Denver.  For this example, the lots currently in the database do not match the legal description (the lots should all be 125 X 25), which is a common occurrence in most databases.

Performing the Vacation without re-creating the original lots
Using the existing lots is the easiest and most straightforward way to go, but not the best-practice.  You could think of this as the quick-and-dirty way to get the tax parcels added and move on with your day.

1. Begin by creating a connection line for the gap between the two disconnected groups.  Use the tool on the Parcel Editor toolbar.  This ensures that a construct from parent process will work, since it requires the group to be connected.

  

2. Use the parcels on the northernmost part of this group, across the gap (alley).  Note the 29’ distance and 87 degree bearing.  The distance measurement should be 30’, with a bearing closer to 90 degrees.  Since we are going with the current set of lots, though, we will simply hit the Apply button to use these numbers.  

   

3. Select just the Tax Parcels that you need to extend to the center of the ROW (Alley) being vacated, right click and select the Construct from parent option.

   

4.Select the Segmented Line Tool at the top of the Parcel Details window.

   

Create a two part segmented line over the top of the connection line that you created.   Take note that the lines as inversed are 14.515ft, not 15.  This is due to the lots/parcels not being repaired prior to the edit.

    

 Note: Be careful, there are two points very close together 81 & 121 in this data.

   

 

5. Same for the southern edge, connecting the midpoints together with another boundary line, to form a centerline running down the middle of the alley/ROW.

   

6. Next step is to create lines across the construction lines used to re-create the ROW (Alley) and the centerline.

a. Start at point 116 as shown here and then place the cursor in the Bearing field

    

b. We want to extend the parcel line along the same bearing, so move the
cursor to snap to the tax parcel line that you want to pick up, hold
SHIFT and then click to pick up the bearing (this will populate that
value in Bearing field).

   

c. Purposely type in something longer than 14.5 (1/2 way point or ROW width)

d.
Use the Planarize command to break the line at the centerline.  Select
the overlapping piece in the grid, right click and choose the Delete
Rows option to remove it.

 

      

7. Continue this process until all the remaining tax parcels have
been extended to the ROW (Alley) center and then merge the smaller
pieces to you existing tax parcels to get you final output.  In this
example, there are no historic ROW parcels created, since they were not
there to begin with.

   

 

Content provided by Larry and Chris (Parcel Editing Team)

 

Posted in Local Government | Tagged , , , , , , , , , , , , , , , | Leave a comment

Labeling Parcels

In the parcel fabric, the parcel name text field is used to store the parcel identification number (PIN). This PIN is sometimes called APN (Assessor Parcel Number) or AIN (Assessor Identification Number) and other conventions. This number is usually kept unique by constructing it from the book, page and a sequential number, as well as similar methods. The field might store “264014001” which stands for Book 264 Page 014 Parcel 001 and can be formatted to show “264-014-001”.

Best practices include the use of label classes to show the full PIN when zoomed in and only the last 3 digits when zoomed out.

  • Label expression: to separate the parcel number by dashes you can use a label expression similar to this:  Left([Name],3) & “-” & Mid([Name],4,3) & “-” & Right([Name],3)
  • MapTips:  some users prefer to only label the last 3 digits and use a MapTip to show the parcel number when hovering over the parcel.

 

  • To do so, activate your MapTip in the Layer’s Display Tab.

  

  • To get the MapTip in the example above, use the following expression:
    ” Book: “& Left([Name],3) & vbNewLine & ” Page: “&  Mid([Name],4,3) & vbNewLine & ” APN:  ” & Right([Name],3)

 

Content for this post from Amir (Parcel Editing Team)

Posted in Editing, Local Government, Mapping | Tagged , , , , , | 1 Comment