|
POST
|
It looks like you switched to VB Code on the line that reads: IFeatureSelection featureSelection = featureLayer as IFeatureSelection; I believe it should be: IFeatureSelection featureSelection = (IFeatureSelection)featureLayer; public void StartButton_Click(object sender, EventArgs e)
{
IApplication app = (IApplication)this.Hook;
IMxDocument mapDoc = (IMxDocument)app.Document;
IFeatureLayer featureLayer = (IFeatureLayer)mapDoc.SelectedLayer;
GetSelectedValues(featureLayer);
}
private void GetSelectedValues(IFeatureLayer featureLayer)
{
IFeatureSelection featureSelection = featureLayer as IFeatureSelection;
ISelectionSet selectionSet = featureSelection.SelectionSet;
ICursor cursor;
selectionSet.Search(null, false, out cursor);
IRow row = cursor.NextRow();
textBox2.Text = row.OID.ToString();
while (cursor != null)
{
System.Diagnostics.Debug.WriteLine(row.OID.ToString());
row = cursor.NextRow();
}
}
... View more
02-04-2013
02:45 PM
|
0
|
0
|
1981
|
|
POST
|
Since this is in VBA, will this script even work in 10.1? I got it to loop for a few minutes, and the I got an error: Runtime Error "91": Oject Variable or With Block Variabel Not Set When I go to debug it, it takes me to line: Set TheCurve = FeatureB.Shape Anyone out there that can help with this? You should not be able to author this in 10.1 as far as I know, since VBA authoring should not be allowed. So how are you creating and running this? In any case, are you sure that your Line ID values are never Null in the points and that every point has a Line ID value that matches an actual line? If either of these conditions are not met the cursor will set FeatureB to Nothing and the line you mentioned will fail. Here is your main loop with a test for the assignment of FeatureB and a MsgBox to help you figure out why the queryfilter gets no hit if FeatureB is Nothing. 'Loop through all records in point layer
Do Until FeatureA Is Nothing
Set ThePoint = FeatureA.Shape
'Set up the filter for the line cursor
K = FeatureA.Value(Y) 'Find the line id in the point layer
strQuery = "NOMBRE = '" & K & "'"
Set pfilter = New QueryFilter
pfilter.WhereClause = strQuery
'Open line cursor as select the line based of pfilter value
Set FCursorB = pfClassB.Search(pfilter, False)
Set FeatureB = FCursorB.NextFeature
'Verify that a feature was found
If Not FeatureB Is Nothing Then
Set TheCurve = FeatureB.Shape
Set pNearPoint = New Point
'Find nearest point on the line to the point
TheCurve.QueryPointAndDistance esriNoExtension, ThePoint, False, _
pNearPoint, DistOnCurve, NearDist, bRight
'Update the old point to the new point
Set FeatureA.Shape = pNearPoint
FCursorA.UpdateFeature FeatureA
Else
MsgBox("No Line Feature Found. Where Clause was: " & strQuery
End If
'Move to the next record in the point feature
Set FeatureA = FCursorA.NextFeature
Loop
... View more
02-04-2013
02:34 PM
|
0
|
0
|
1652
|
|
POST
|
Dear all, a few weeks ago I updated from ArcGIS 10.0 to 10.1. Now recently I noticed a phenomenon several times: When running processes take very long time or even don't work out at all I try to clear the .mxd file from no more required layers. Quite surprised I found out that the file size - instead of decreasing - was even enlarged. What reason might there be for that? Maybe it doesn't have to do with version 10.1 but I just didn't observe it before. Thanks in advance and kind regards, Matthias mxd files save a history of actions like the addition and removal of layers. You just have not observed it before. The only way I know of to clear the history is to save the file under a new name.
... View more
02-02-2013
05:29 AM
|
0
|
0
|
966
|
|
POST
|
Thanks a lot, that was exactly what I meant !! Just one more question: How can I delete from the final shapefile the duplicate lines (those connecting the same polygons) ? The line connecting polygon A to polygon B is exactly the same as that connecting polygon B to polygon A. I need to delete duplicate lines. I would really appreciate your help ! Had I known this was what you wanted here is how the instructions would have gone. Use Spatial Join of the layer with a copy of itself using a very, very small overlapping tolerance. Use the One to Many option. This will cause each polygon to duplicate to cover as many neighbors as it has (plus itself). Filter out the cases where the ObjectIDs of the two layers are the same. Add a text field called APN_PAIR and select all cases where the first parcel is less than (<) the second parcel. Create a concatentation of the two parcel numbers with a space separator with first parcel first and second parcel second (the concatenation will be in sorted pair order). Create a Long Integer Field and name it LINE_ORDER and calculate a 1 in it. Select all cases where the first parcel is greater than (>) the second parcel. Create a concatentation of the two parcel numbers with a space separator with the second parcel first and first parcel second (i.e, the concatenation keeps the pair in sorted order). Calculate a 2 in the LINE_ORDER field. Use the Feature to Point tool on the data. Check the keep inside option. Use the Point to Line tool using the concatenated APN_PAIR field as the Line Field and the LINE_ORDER field as the Sort field. You should now have just one line for each parcel pair with your lines always originating from the parcel with the lower parcel number and ending in the parcel with the higher parcel number. To create and polulate separate fields for the original Parcel numbers in the final connector lines, create two Parcel fields that are identical in type and configuration to your original Parcel field, and name them with names that relate to the Parcel field name, such as PARCEL1 and PARCEL2. For PARCEL1 use the Field Calculator. With the parser set as VB Script use this formula: Split(APN_PAIR)(0) For PARCEL2 use the Field Calculator. With the parser set as VB Script use this formula: Split(APN_PAIR)(1) These two fields should now join/relate with your original Parcels.
... View more
02-01-2013
04:09 PM
|
0
|
0
|
2440
|
|
POST
|
Hi everyone, I am looking for a tool that allows me to create a shapefile with lines connecting adjacent polygons. For example: if polygon A has 2 adjacent polygons (B and C), I need to create a shapefile with a line that connects centroid of polygon A with centroid of polygon B and another line that connects centroid of polygon A with centroid of polygon C. The total number of polygons from which I have to do this is 300. I have been able to do it for 1 polygon but it takes me 6 steps and the creation of multiples shapefiles and tables in the process. It's not a choice when trying to repeat the process for the 300 polygons of the shapefile. I need an easier way to do it ! Any help would be muuuuuch appreciated ! Thank you. Use Spatial Join of the layer with a copy of itseld using a very, very small overlapping tolerance. Use the One to Many option. This will cause each polygon to duplicate to cover as many neighbors as it has (plus itself). Filter out the cases where the ObjectIDs of the two layers are the same. Add a text field called APN_PAIR and create a concatentation of the two parcel numbers with a space separator. Create a Long Integer Field and name it LINE_ORDER and calculate a 1 in it. Start an edit session. Select all of the parcels in the layer and copy them to itself. While the copied set is still selected calculate the LINE_ORDER field as 2 and calculate the APN_PAIR as the reversed concatenation of the APN values. Save your edits and stop editing. Use the Feature to Point tool on the data. Check the keep inside option. Use the Point to Line tool using the concatenated APN_PAIR field as the Line Field and the LINE_ORDER field as the Sort field. You should now have your lines with the first point in the center of the first APN in the concatenated APN_PAIR field and the last point in the second APN of the APN_PAIR field. Now create two APN fields and calculate the original separate APNs into them. If you filtered a particular APN and use arrowheads they will point out from the parcel. The screen shot shows the result for 1379 parcels.
... View more
01-31-2013
03:13 PM
|
0
|
0
|
2440
|
|
POST
|
Hi Richard, This is what I got after creating polygon (see attached). Not sure how to filtered to show road interiors. I am fairly new in ArcGIS, Thanks for your help. You have to classify the polygons manually. You will need to add an attribute field (either text or number) called something line POLY_TYPE and select the first road polygon you see. Give it a value that will mean it is a road. If you use a number create a coded value domain to give a meaningful name to the value. If it text, be consistent in the spelling of the Road and Non-Road values. One way to attribute the roads is to do the following. There should be far fewer road polygons than non-road polygons, so start with the Roads. Select the first road polygon you see and attribute it as a Road. With this road selected, do a Select by Location using the layer to select against itself. The default Select by Location options should be fine. If the result of that selection operation was that every other polygon got selected then that polygon should be your only road polygon. If some polygons did not get selected, reverse the selection and look at what was not touched by your road polygon(s). Find the obvious road polygon in the reversed selection and attribute it as a Road. Select all road polygons in the Attribute table (sort on that field after each edit using a Descending sort and select the all of the Road attributed group in the table). Repeat the Select by Location, reverse selection and attributing process until you have attributed all of the road polygons and every polygon is selected by the processes. When you finish attributing the roads, select the Null polygons remain. These polygons should be your non-road polygons. Attribute them as non-roads. You can now filter to show just the Road Polygons using a Definition Query where the field you added equals the value that means it is a road.
... View more
01-31-2013
01:18 PM
|
0
|
0
|
11884
|
|
POST
|
A few other notes on the output. There will always be two lines at each intersection, with the Road Names in sorted and reverse sorted orders. If only two road names meet at an intersection and you only want one line, you could select based on the sort order and either delete what you don't want or export what you do want. (I would export and leave the result unedited to be able to go back to it as a reference during clean-up). At intersections with 3 or more names there will be more lines. Also the names that are opposite each other across an intersection with more than 2 names will place the crosswalk line in the opposing named road's location. So some process to identify these intersections and switch the attributes would be needed. Also, at 4 way named intersections you would need to deal with revising the field structure to handle more than 2 names if you want a single line at each of its Crosswalks, since at least 3 names would associate with each crosswalk. So there will probably still be about 10 to 20 percent of the segments that need manual clean-up. I find that is typical for virtually every first-pass, broad scoped geoprocessing operation.
... View more
01-31-2013
12:58 PM
|
0
|
0
|
11884
|
|
POST
|
Thanks Richard, Yes I do have Road centre lines. Waiting for remaining attachments and procedures. Some of the road sections are missing sidewalk centre lines. I am not sure whether this would be an issue to create polygon. I used a parcel layer to do the example. If the parcels excluded roads you could create a polygon that bounds the parcels using the Minimum Bounding Feature tool and then Erasing the Parcels from that Output to get a Road Casing polygon. My parcels had the road interiors, but divided at book boundaries, so I first dissolved the Road Parcels into a single parcel to get my road casing. The parcel Casing could be an outer most boundary. You might have to mix it with your sidewalks to close all of your lines to form the road Casing polygon. Experiment to see if that is really needed. I hope this helps.
... View more
01-31-2013
11:59 AM
|
0
|
0
|
11884
|
|
POST
|
Continued from previous post. 5. Feature to Line tool. Screen Shot 6 shows the result of using the Feature To Line tool on your intersection polygons (the red ones shown in step 4). 6. Preview appearance with Original line set of outlines of Roads. Screen Shot 7 shows dark green lines for your original road outlines overlaying the intersection lines exported from Step 5. The purple shows the portions of the intersections that are not overlapped. 7. Erase Tool. Use the Intersection line set from step 5 and the primary input and your original lines as the features to erase. Screen Shot 8 shows the result of the erasure. 8. The final output shown with the cased Road polygons, the original Centerlines and the purple Crosswalks. Because I kept the road names in the Intersect tool step the Crosswalks already have road names assigned that I can use to select the crosswalks. You may have to use the Explode Multi-part feature tool on the result. And to straighten curved Crosswalks (created from the curved end caps) you could extract the two end points using the Features to Points tool with the Both Ends Option. Then use the Points to Lines tool to recreate the straight lines between the point pairs from the ID field preserved by the Features to Points tool. I hope this helps.
... View more
01-31-2013
11:56 AM
|
0
|
0
|
11884
|
|
POST
|
I have sidewalks centre line for a City. That is, two lines that creates the shape of a roadway. I want to create line (to represent cross-walks) in every intersections. For example, in the attachment, I have the black lines (shapefile), and I want to create the red lines in every intersections. Is there any way I can do that automatically or efficiently. Manually creating would take hours and hours as I have hundreds of intersections. Thanks. Shafayat Question. Do you have the actual Centerlines for the roads that include Road Names of the streets? If so, I have done a process as follows: 1. Features to Polygon tool. Screen Shot 1 shows the lines converted to polygons (Features to Polygons tool) and attributed and filtered to show just road interiors. Singe Centerlines within the road polygons are also shown. 2. Buffer tool. Screen Shot 2 shows the Centerlines buffered by 75 feet. Use Road Name as the Dissolve value. Use Rounded End caps. You may have to test different buffer widths and if you have road classifications you might be able to quickly assign varying widths depending on the Road class to a field and use that for the buffer width value for better results. 3. Intersect tool. Screen Shot 3 shows the result of using the Intersect tool with the Centerline buffer output form step 2 used as an input twice and the Road casing polygon from step 1 used as an input once. 4. Definition Query. Screen shot 4 shows the definition query that will filter out just intersections from the result of Step 3. Screen shot 5 shows the resulting intersection polygons in Red overlaying the Road polygon shown in green. See next message for further steps, since I could only upload 5 screen shots.
... View more
01-31-2013
11:41 AM
|
0
|
0
|
11885
|
|
POST
|
I forgot to mention that you probably would need to use the Explode Mulit-Part Feature tool that you can access from the Advanced Editor toolbar or as a Geoprocessing tool. That is because the Union tool keeps all parts of an original feature together that it can by default. If there is an option on the Union tool to not create a multi-part feature, use that option.
... View more
01-31-2013
05:26 AM
|
0
|
0
|
2141
|
|
POST
|
Thanks for the suggestion, but I'm working with an area with many many islands as well, I was really hoping there was just a tool that could just invert the polygon. I tried using the Erase tool, but the area has too many line segments to process. Create a separate shape feature class. In it create a single polygon that covers all of the holes in your water layer. The shape can be a square. If you overbound the water do it by a fair amount so it will be easy to tell it falls outside of the water area. Use the Union tool to merge and intersect the water shape(s) and the overlapping new shape. Every output shape in the Union result that has -1 as the water FID is either an island or a shape that fell outside the external boundary of your water shape(s). Select everything where the water FID >= 0 and delete them. Or else do the opposite selection (Water FID = -1) and export them. Clean up any land shapes that overbounded the water body that you do not want. You should have your islands.
... View more
01-30-2013
02:35 PM
|
0
|
0
|
2141
|
|
POST
|
Hello, I have a big problem...I have merged polygons, many of them. This was mistake in my work, so I want to know is there any possibility to unmerge it? To return my old polygons that have disapired...Is there any hope for it?:( Thank you a lot. I assume you have saved the edits already, since you could use undo if you were still in the edit session where you did the merge. If you were using SDE and had not committed the child version you were editing you could salvage the original data it it was posted in the unmerged state to a parent version. If it is a shapefile, personal geodatabase or file geodatabase, you could only salvage your work if you had some sort of back up created by your IT department, which should be occurring if you keep your data on a network drive. I hope that helps.
... View more
01-30-2013
02:24 PM
|
0
|
0
|
10108
|
|
POST
|
In Arcmap you can only have one tool active at a time, which is reflected in the ArcMap.Application.CurrentTool property. Buttons that look depressed are simply commands that have their checked property set to true. Example of these include the editor shape constructors, the editor command on the standard toolbar and the snapping types on the snapping toolbar etc. If you set the currenttool property to null or nothing in your add-in, like Ken does in his example, the current tool is deactivated. The arcmap cursor changes to a default which just happens to be the one used by the select elements tool, hence the confusion. The add-in wizard template code includes this in the on-click events for buttons so in your case your button is probably deactivating the current tool before showing the modal dialog. Simply remove or comment out this line. The customize dialog also clears the selected tool and has done so since arcgis 8. Got it. I had not really paid attention to or thought through what the default code for the onClick button was actually doing, since I just assumed it was was there by default to only deselect the button that I was creating rather than every button in ArcMap. For my buttons I will comment out the line that reads: My.ArcMap.Application.CurrentTool = Nothing It would be nice if the default code above had a comment explaining what it does, such as: ' Unselect all buttons and tools on all toolbars.
... View more
01-30-2013
12:02 PM
|
0
|
0
|
1236
|
|
POST
|
I found out that this behavior is by design from ESRI and an �??enhancement�?� change at 10.0 from the behavior of 9.3. At 9.3 pressing a normal button would not deselect the Select Element button on the toolbar (the standard selection tool that is active by default when ArcGIS opens). At 10.0+ pressing any button does deselect the Select Elements button. Why? I don�??t know. In versions previous to ArcGIS 10.0 the Select Element button has only been unselected by tools that stay depressed on the toolbar and that changed the cursor shape (both visual cues that the Select Elements button was no longer selected). However, before 10.0 it did not do this for regular buttons where the new button does not stay depressed and the cursor does not change (giving no visual cues to the user that they did anything to affect the Select Elements button). I have told ESRI that I think this is a dumb enhancement and that it just adds a pointless extra mouse click and confusion to users that have no reason to look over and notice the subtle behavior of the Select Element button becoming unselected when they press a button that may be located nowhere near the Select Elements button. Because the Select Elements button has always been and continues to be a default option at start-up, almost none of my basic viewer users have ever actually clicked this button before or were even really aware of its existence. So the workaround is to press the Select Elements Button after running any tool or button on the toolbar. The same applies to opening the Customize Mode dialog and probably many other menu items. Now that I know what behavior ESRI changed with their "enhancement" I can write code to undo their change when my buttons finish, since I have no reason to want the Select Elements button to not work.
... View more
01-30-2013
09:46 AM
|
0
|
0
|
1236
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 03-24-2026 11:37 PM | |
| 1 | 03-24-2026 08:01 PM | |
| 7 | 02-23-2026 08:34 AM | |
| 1 | 03-31-2025 03:25 PM | |
| 1 | 03-28-2025 06:54 PM |
| Online Status |
Offline
|
| Date Last Visited |
a week ago
|