User Tools

Site Tools


map_suite_wpf_desktop_edition_faq_spatial_functions

Table of Contents

Map Suite Wpf Desktop Edition FAQ Spatial Functions

How do I clip one polygon layer based on a polygon?

This question has a corresponding sample application(s) associated with it.

Sample:Clipping

This project along with “Spatial Join”, “Dissolve” and “Dissolve with Statistics” show another type of geoprocessing technique that can be applied to a layer. Clipping a layer can be handy in situation where the layer has a geographic extent larger than necessary and you just need a portion of it based on some defined area. For example, you might have the world layer of evergreen but you are working at the national level for Brazil and you don’t need the rest of the world. Clipping the layer will reduce it to the geographic area you are only interested in.
With “Clipping”, you will see how to combine the GetIntersection geometric function with other functions for creating and editing a layer into a coherent one step operation. Notice that this project only deals with clipping polygon based layer. It is also possible to clip line and point based layers. That will be the subject of future projects.

How do I clip one point layer based on a polygon?

Sample:Clipping On Point Layer

After the project “Clipping” where we saw how to clip a polygon layer based on a polygon, in this project we see how to clip a point based layer. Clipping a point based layer is quite a simpler task than clipping a polygon based layer as no geometric functions are necessary such as GetIntersection (overlap) besides the spatial query. It is also a much faster task to run.
After the projects on clipping polygon and point based layers, we will show a project on clipping line based layers.

How do I create a convex hull around a feature?

This question has a corresponding sample application(s) associated with it.

Sample:Convex Hull

ConvexHull is a geometric function that returns the smallest ring containing all the points of a shape. Another way to think about it is to imagine a set of points on a plane as nails pounded into a board. If you wrap the entire set with a rubber band snapping it into place, it will form a convex hull, which is the minimum-energy wrapper that encloses all the points. This is the theory, now you may be wondering what the practical use of this is in GIS. In today’s project, we show how to contruct a convex hull polygon from a set of point in a concrete situation of oil rigs offshore. Creating a convex hull could be used to determine the perimeter for constructing a barrier around the oil rigs to help protect from hurricanes. It could also be used for a barrier to keep spilled oil contained within.

How do I snap line based nodes together based on a tolerance?

This question has a corresponding sample application(s) associated with it.

Sample:Correcting Nodes

As for the projects “Spatial Join” and “Dissolve”, in this project we see how to edit FeatureLayers. In this case, we show some techniques to clean up a line based layer. You may be in a situation where you have to do that on a layer representing a network. Due to a poor digitizing, the end nodes of the lines don’t touch each other showing disconnected when in fact they should be connected. In this project, we show the technique to correct the location of the end vertices (nodes) so that they connect to each other. Keep in mind that the logic for correcting nodes shown here, is very simple and does not take into account various parameters such as tolerance, line order, multi line intersection etc. This logic works in the case of having an ordered sequential network as it is often digitized. The full logic taking into account all the different scenarios is vastly more complicated. We plan to offer this full logic in the future as an API within our core product. Also, notice that we create a custom LineStyle, NodeLineStyle for the purpose of showing the start and end nodes of each line as different color than the body of the line.

How do I create inner rings for track polygon?

This question has a corresponding sample application(s) associated with it.

Sample:Create Inner Ring

In today’s Desktop project, we learn how to create inner rings to a polygon based on another polygon using the GetDifference function. We also learn how to perform Union on a collection of polygon and how to set up the event TrackEnded. To use this app, you need to track a polygon, double click to end it and it will create an inner ring from the unioned result of the polygons completely within the tracked polygon. You can look at the TrackEnded event handler to see all the different operations taking place for that task.

How do I create a polygon programatically?

This question has a corresponding sample application(s) associated with it.

Sample:Create Polygon Programatically

Having a list of vertices with X and Y representing a polygon is a common scenario in GIS. For example, you might have a list of vertices (in Longitude and Latitude) representing plumes from a chemical dispersion. How do I create the polygons from that and how to I display that on the map? In this project, we show how to accomplish this from text files.

How do I draw a pie shape with a sweep angle as in radar applications?

This question has a corresponding sample application(s) associated with it.

Sample:Sweep Angle

For your GIS needs, you might have the need to construct a shape as a pie with a sweep angle for doing spatial analysis similar to radar. In this project, we show how to build a polygon based on a sweep angle and have it dynamically widens the angle while checking the containment of a collection of points. The key function in this project is CreatePie that has all the geometry necessary for creating such a shape.

Sample:Sweep Angle Desktop

The purpose of today’s project is to show how to make a desktop project from a Servicess one. Many of the projects published in the Code Community are in the Servicess edition because the only reference for Map Suite required for running them is MapSuiteCore.dll. That dll comes in any of the Map Suite products. We are taking the example of the “Sweep Angle” Servicess project to show how to adapt it to a Desktop project. With the understanding of some basic concepts such as Overlay, you will be able to easily convert a Servicess project to a Desktop one. So, for this project, you will need the references for both MapSuiteCore.dll and DesktopEdition.dll. Next, we will see how to convert a Servicess project to a Web one.

How do I dissolve a shape file based on a common attribute?

This question has a corresponding sample application(s) associated with it.

Sample:Dissolve on Shapefile

This project shows how to perform some geoprocessing on a shapefile, in this case dissolving a shapefile based on a common attribute. Dissolving shapefiles can be handy in situation where the shapefiles are too broken down for what they are intended to be used for. For example, you may have a shapefile of all the states of the US and they all have attributes for what sales region each belong to. If what really matters to you are the sales regions and not the individual states, it makes sense to dissolve the shapefile.

In this small project, you will see the technique to dissolve a shapefile based on a common attribute using some key methods such as Union static method to efficiently union together a large number of shapes. You will also find useful the code for creating a shapefile from scratch. This project will soon be followed by another project on how to apply statistics when dissolving a shapefile. Also, there will be another related project on how to do Dissolve on a generic FeatureSource.

Sample:Dissolve with Statistics

In the project “Dissolve”, we saw the geometric aspect of the Dissolve operation with the Union function etc. In this project, we going a little further and we apply statistics on the layer while dissolving. For each column of the layer being dissolved, we can apply various statistics such as sum, average, count etc. For example if you are dissolving the states of the US based on what region they belong to, you may want to get the sum of the population of each state within the same region and save that to the output dissolved layer.

How do I split polygon based on an intersecting line?

This question has a corresponding sample application(s) associated with it.

Sample:Split Polygon

Map Suite offers functions such as GetLineOnLine or GetPointOnLine to work to get portion of a line for dynamic segmentation. While this is very useful, many organizations dealing with road networks may have there roads represented as polygons as opposed to lines. This project shows the technique of splitting a polygon based on lines for situation where you have the roads represented as polygons with a center line for the road.

How do I perform spatial join?

This question has a corresponding sample application(s) associated with it.

Sample:Spatial Join

This project shows how to perform a Spatial Join on a point Layer based on a Polygon layer. It adds the relevant info to the point layer based on the spatial characteristics of the features of the point layer in comparison to the polygon layer. For example, we have two layers. One is polygon layer of the countries; the other is point layer of the cities. We don’t have any attribute information about what country each city belongs to. We can perform a Spatial Join to add that info to the point layer. A Spatial Join looks at what country of the polygon layer, each city belongs to using a spatial query. Spatial Join requires handling various techniques such as creating, updating layer and spatial queries in one coherent function. In this project, you will also see the technique of displaying a label based on more then one columns. In this example, we show a Spatial Join based on containing rule. Other types of Spatial Joins can be performed based on proximity, or some other topological rules. Later, we will show other projects of Spatial Joins.

How can I draw a pie shape defined by an ellipse?

This question has a corresponding sample application(s) associated with it.

Sample:Draw a Pie shape

This sample shows you how to draw a pie shape defined by an Ellipse prototype. The pie shape is not a standard shape provided by the Map Suite component, though it could be considered part of the ellipse or circle if special enough. In essence, you can create a pie shape by adding additional points to a given ellipse shape.

For more information, please see the discussion forum post below: http://gis.thinkgeo.com/Support/DiscussionForums/tabid/143/aff/21/aft/6963/afv/topic/Default.aspx

How can I perform dynamic segmentation?

This question has a corresponding sample application(s) associated with it.

Sample:Dynamic Segmentation

The purpose of this project is to give a very quick introduction to Dynamic Segmentation, the area of GIS that has to do with network analysis. This project should interest professionals working in road management, accident analysis and pavement management.

The key method used here is GetLineOnLine that offers many parameters to get a segment of an existing line. In our example, we get a line segment based on a distance from the start and the length. You can see how this could be applied for application such closing a segment of a highway after an accident for example. This project will be followed by other more advanced projects related to Dynamic Segmentation.

How do I suppress features from being drawn in a layer?

This question has a corresponding sample application(s) associated with it.

Sample:FeatureIdsToExclude

The purpose of this project is to show how to use the FeatureIdsToExclude collection of FeatureLayer. In the project, you will see how you can exclude some features from being part of the GetFeaturesNearestTo function. Using that collection is a handy method for not taking into account some features in doing spatial queries, searching and even drawing without having to change the structure of the layer or create another layer.

How do I find a feature the user clicked on?

This question has a corresponding sample application(s) associated with it.

Sample:Get Feature Clicked On(Desktop)

The purpose of this project is to show the technique for finding the feature the user clicked on. To give the user the expected behavior, a buffer in screen coordinate needs to be set so that the feature get selected within a constant distance in screen coordinate to where the user clicked on regardless on the zoom level. This project will show how to accomplish that task regardless of the layer type (polygon, line or point based) and the zoom level of the current extent of the map. This is a Desktop project.

How do I remove a LineShape from a MultiLineShape?

This question has a corresponding sample application(s) associated with it.

Sample:Remove LineShape

MultilineShape is a line based shape type consisting of a collection of LineShapes. In today’s project, we will show some editing on how to remove a LineShape of the MultilineShape. In this process, you have to be aware of various issues such as removing the LineShape using the correct index and recreating a new feature with the edited MultilineShape with the correct ColumnValues if necessary.

How do I register a shape to the ground from a non-geographic coordinate system?

This question has a corresponding sample application(s) associated with it.

Sample:Register Shape

In this sample, we show a geometric function that allows tying to the ground or registering shapes from some non geographic coordinate to the map (in world coordinates). To better understand how useful this can be for your mapping needs, imagine the following scenario: You have some geometric shapes in a CAD for chemical plume. In a CAD or specialized program generating chemical models, you can do all your scientific manipulation, transformation etc. Once you are finished generating the chemical models with your specialized program, you are ready to put it on the map. Using anchor points, one of origin and one of destination, you can tie to the ground the shapes with the help of the Register function. This operation cannot be confused with Projection. Projecting a shape means going from one geographic projection to another one, for example from Geodetic to Spherical Mercator and some deformation of the shape can occur. Registering is simply placing a shape from a non geographic coordinate to a specific location on the map.

How do I identify a feature when clicking anywhere on its icon?

This question has a corresponding sample application(s) associated with it.

Sample:Identify Point with Icon

This project shows what technique to use when identifying at mouse click a feature represented with an icon. From the user’s perspective, the expected behavior when is to get the information of the feature when the user clicks on the icon, any part of the icon. The icon is the feature for him.

Today, we show how to implement that mode of getting info from a feature with icons of any size.

How do I determine if a point is inside an inner ring of a polygon?

This question has a corresponding sample application(s) associated with it.

Sample:Inner Ring Containment

The Contains function of PolygonShape when passing a PointShape is a convenient way to find out if a point is inside a polygon or not. But you have to be aware that the function is going to return false whether the point is completely outside the polygon or is inside one of the inner rings (holes of the polygon). While this is technically accurate, you might be in the position where you need to be able to make the distinction between those different types of containment for a polygon possessing inner rings. In today’s project, we create a function gives you the information whether a point is completely outside or inside one of the inner rings.

How do I split a line based on an intersecting line?

This question has a corresponding sample application(s) associated with it.

Sample:Intersect Line

In today’s project, we show how to split a line based on an intersecting line. To accomplish this task, basically two steps are needed. First, you need to find the crossing point using the GetCrossing function and then you split the line based on the crossing point using the GetLineOnLine function. If you are in the utilities industry working with electric network, gas pipes etc, you will find this project useful.

How do I handle self-intersecting polygons?

This question has a corresponding sample application(s) associated with it.

Sample:Intersecting Multi Polygon

In today’s project, we learn how to handle graciously the case of an invalid MultipolygonShape. Having a MultipolygonShape (The MutiPolygon according to OGC) with intersecting (overlapping) PolygonShapes is not a valid geometric shape. Although it draws (with some quirks) without throwing errors, such a shape cannot be used for doing spatial queries or other geometric functions. There are two options to solve the problem. One is to create a collection of individual PolygonShapes. The other one is to correct the MultipolygonShape by unioning the overlapping parts. In this project, you will see the code for both approaches. Keep in mind that the two different approaches are not just different methods, they also give different resulting shapes. You have to choose what solution fits the best your case.

How do I intersecting two layers?

This question has a corresponding sample application(s) associated with it.

Sample:Intersecting Two Layers

In the project “Clipping”, we saw how to clip a layer with another to have a resulting layer of the desired geographical extent. In the project “Intersecting two layers”, we see the technique of intersecting two layers which goes a few steps further compared to simply clipping a layer.

Let say you have a layer of stratigraphy and a layer of counties and you need to do some analysis based on info from the county layer and info from the stratigraphy layer. You can combine the two layers by intersecting them and get only the common data of the two layers while adding the attributes of both original layers. The resulting layer has geographical extent that is common to both layers (as for clipping) while adding the information from both original layers. As for other geoprocessing techniques, writing the code for Intersecting requires combining layer editing with geometric functions.

How do I merge two line layers?

This question has a corresponding sample application(s) associated with it.

Sample:Merge Line Layers

From the previous project, on the geoprocessing technique of merging point layers, here we show the same technique applied to line layers. Remember that an alternative approach to merging is to use a multi index and treating all the various files as one layer. You can see this Discussion Forum post for more info on that: http://gis.thinkgeo.com/Support/DiscussionForums/tabid/143/aff/21/aft/5921/afv/topic/Default.aspx

How do I merge two point layers?

Sample:Merge Point Layers

This project is similar to a previous project related to geoprocessing for merging polygon layers “Merging Layers”, but applied to point layers.

An alternative approach to merging is to use a multi index and treating all the various files as one layer. You can see this Discussion Forum post for more info on that: http://gis.thinkgeo.com/Support/DiscussionForums/tabid/143/aff/21/aft/5921/afv/topic/Default.aspx Next we will show how to do the same thing for line layers.

How do I treat multiple shape files as one shape file without physically merging them?

This question has a corresponding sample application(s) associated with it.

Sample:Merging Layers

If you have many files of the same type and representing the same type of features, Map Suite offers an API for building a multi index and treating all the various files as one layer. You can see this Discussion Forum post for more info on that: http://gis.thinkgeo.com/Support/DiscussionForums/tabid/143/aff/21/aft/5921/afv/topic/Default.aspx

While this is very convenient, you may still want to combine all your files into one for maintenance purpose. This project shows the geoprocessing technique of accomplishing that task with merging. The logic for writing the merging algorithm is simpler than other geoprocessing tasks since no geometric functions are involved. Keep in mind that this project shows how to merge polygon based shapefiles into one. In the future, we will post a more generic project for layer of various format and type.

How do I move a point parallel to a line segment?

This question has a corresponding sample application(s) associated with it.

Sample:Offset Point at Right Angle

This project shows some geometry for moving a point parallel to a line segment. The GetLineOnLine method allows you to do some dynamic segmentation on a road. After doing that you may need to offset the start and end points at a right angle by a certain distance. This project will show you how to accomplish that.

How do I buffer shapes based on multiple distances?

This question has a corresponding sample application(s) associated with it.

Sample:Multi Ring Buffering

This project shows how to create a multi ring buffer on shapes, in this case MultilineShapes from a line based layer, a road. From buffering the road at various distances, we create concentric rings. Then, we can determine how many features from the point based layer (schools) are in each ring.

In this project, you learn how to handle geometry functions such as Buffer, Union and Difference for the goal of doing some spatial analysis with the resulting rings.

How do I perform a negative buffer?

This question has a corresponding sample application(s) associated with it.

Sample:Negative Buffering

This project is meant for addressing a current limitation of Map Suite API concerning the geometric operation of buffering. Currently, the Buffer function can only be done for buffering to the outside of a shape but not to the inside of the shape. This project shows the different steps to follow using various geometric functions to accomplish the result of negative buffering. In the future public release of Map Suite, negative buffering will be fully supported. This project is still useful in understand how to manipulate various geometric functions to get the desired result.

How to create a MultipolygonShape from various PolygonShapes?

This question has a corresponding sample application(s) associated with it.

Sample:Polygon Shapes To Multipolygon Shapes

In this Wpf project, we show how to create a MultipolygonShape from various PolygonShapes. Since a collection of PolygonShapes cannot be directly cast to a MultipolygonShape, we show the technique to build a MultipolygonShape passing an IEnumerable of PolygonShape. This is a Wpf sample and you will need the references for MapSuiteCore.dll and WpfDesktopEdition.dll.

How to use GetFeaturesWithinDistanceOf/GetFeaturesNearestTo methods when the data is reprojected?

This question has a corresponding sample application(s) associated with it.

Sample:Distance Query on Projected Layers

In this sample, we learned how to use the method GetFeaturesWithDistanceOf when the data is projected. We just input the unit which is projected to, do not need to mind what the real unit is for the internal data before projection. It works fine with Map Suite Assemblies 4.5.54.0 or later.

How to use distance query on wrap dateline mode?

This question has a corresponding sample application(s) associated with it.

Sample:Distance Query on WrapDatelineMode

In this Wpf sample is on the same theme as the previous sample WrapDatelineMode. Here we show how to take advantage of the projection class WrapDatelineProjection for doing spatial query when on a “virtual map”. From this spatial query example, the developer should understand how the same principle using the same projection class can be applied for other operations such as Spatial Queries, Identify etc. In order to run this sample, you will need the latest Dev Daily Build for Wpf with references to MapSuiteCore.dll and WpfDesktopEdition.dll.

How do I clip one line layer based on a polygon?

This question has a corresponding sample application(s) associated with it.

Sample:Clipping On Line Layer

This Wpf project completes the series of projects dedicated to the clipping geoprocessing. We already saw how to perform clipping on a polygon based layer in “Clipping” and on a point layer in “Clipping On Point Layer”. Here we show how to perform the clipping geopressing on a line based layer. As for the same operation on a polygon based layer, the key geometric function is GetIntersection. We will also appreciate the operation of creating a layer from scratch as in addition to the geometric operation itself, geoprocessing also involves creating a result layer from the original layers, the clipping layer and the clipped layer. You will need to get in the Dev Daily Build the latest MapSuiteCore.dll and WpfDesktopEdition.dll as references as the GetIntersection API for line based shapes was added only recentely.

map_suite_wpf_desktop_edition_faq_spatial_functions.txt · Last modified: 2015/09/16 11:14 by admin