Hot answers tagged vba
11
There are many ways to weight distances for constructing Thiessen polygons. The basic idea in constructing them is based on comparing the distance between an arbitrary point x and two fixed points p and q; you need to decide whether x is "closer" to p than to q or not. To this end--at least conceptually--we consider the distances dp = d(x, p) and dq= d(x, ...
8
the Q was about single use, but I might as well round out things out by providing the answer for concurrent licensing use as well so everything is in one place (I don't think it warrants a separate question).
Prepwork:
Contact your customer support representative, by email, and requestVBA extension authorization (it's free, and no I don't know why you ...
8
If you know row, column, cellsize and extent, X & Y can easily be calculated. Note this assumes a North up raster. If the raster is rotated you'll need to know the other two affine transformation coefficients (or geotransform in GDAL speak). Also note that the column/row coordinates in the below are from (0.0,0.0) at the upper left corner of the upper ...
7
I don't know how to do this with Field Calculator, but I do know a workaround.
Run Summary Statistics in ArcToolbox with COUNT on the [name] field. This will create another table where each unique [name] entry will have next to it the number of times it appears in the original layer. Then Join this table back to your original layer, with the [name] ...
7
What you want is a weighted Voronoi diagram:
http://en.wikipedia.org/wiki/Weighted_Voronoi_diagram
also know as a circular Dirichlet tessellation when done with multiplicative weights in a 2d plane.
Someone seems to have built an arcgis 9 extension to build these:
http://arcscripts.esri.com/details.asp?dbid=15481
With a user guide available here
...
6
You need to concatenate information from two fields using the & operator (see this link for all supported operators) . You can do this from ArcGIS's Field Calculator using [mycol1] =:
[mycol1] & [mycol2]
If you want a space in between the two values:
[mycol1] & " " & [mycol2]
This only works for text type destination fields. If you want ...
5
Try calling Store.
pFeature.value(pFeature.Fields.FindField("Type")) = "update"
pFeature.Store()
Set pFeature = pEnumFeature.Next
Are you in an edit session? Scroll down to best practices:
http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html#/d/00010000010s000000.htm
5
This is one of the most common errors in ArcGIS/VBA environment, and is usually due to missing references.
Go to Tools --> references and check for any MISSING ones. Most likely your missing references to Crystal components.
Tick them on and re-try.
http://resources.arcgis.com/content/kbase?fa=articleShow&d=29069
5
As @ujjwalesri pointed out, you need a reference to the toolbox. Here is an example that works for me:
Dim gp_msg As String = ""
Dim pGp As ESRI.ArcGIS.Geoprocessing.IGeoProcessor
Dim pResult As ESRI.ArcGIS.Geoprocessing.IGeoProcessorResult
Dim pParamArray As ESRI.ArcGIS.esriSystem.IVariantArray
Dim minZ As Double
Dim MaxZ As Double
Dim TinPath As String
...
5
I've never tried this but it seems like this would work:
Create a 3D voronoi diagram of the sphere. This resulting polygons will be roughly centered on the original existing (seed) points.
Loop through each resulting vertex to find the one that is farthest from its closest existing point. This point should be the most remote point on the globe.
5
Kirk Kukendall's recommendation to construct a spherical Voronoi diagram (Thiessen polygons) is a good one, but might have some technical hitches to work out. In the meantime, as an alternative, one can apply the standard raster solution as described on another thread. Use spherical distances instead of Euclidean distances.
Here is an example using five ...
5
There are a few concepts that I see you are missing. I will try to explain them.
1- The first one has to do with spatial filter usage. You should pass a filter when you are using it, otherwise, just pass nothing.
You have this code:
Dim pSpatialFilter As ISpatialFilter
Set pSpatialFilter = New SpatialFilter
Dim pBlockBoundaryCursor As IFeatureCursor
Set ...
5
You could just use the ArcMap Command, Zoom To Selected Features.
Dim pUID As New UID
Dim pCmdItem As ICommandItem
' Use the GUID of the Save command
' Zoom to all selected features
pUID.Value = "{AB073B49-DE5E-11D1-AA80-00C04FA37860}"
' or you can use the ProgID
' pUID.Value = "esriArcMapUI.ZoomToSelectedCommand"
pUID.SubType = 3
Set ...
4
Cast the geometry bag to an IGeometry first, then try setting its SpatialReference property.
The behavior you describe is weird, though, since IGeometryBag descends directly from IGeometry. Are you sure you are trying to set the spatial reference on the correct interface?
4
OK so my co-worker helped me figure this out...
Turns out I hadn't declared an envelope for my featureIndex, which in turn, left my indexQuery empty.
Underneath:
Dim pNhdIndexQuery As IIndexQuery2
I added the following lines of code:
Dim pEnvelope As IEnvelope
Set pEnvelope = New Envelope
pNhdFeatureIndex.Index Nothing, pEnvelope
This ...
4
A while back, I wrote some VB code to persist and de-persist renderers in ArcObjects. It's a slightly different spin on your question but I think what you need is there. The code can be found at: http://arcscripts.esri.com/details.asp?dbid=12474
I hope this helps.
Bill
4
If you want to move the values in the 'acct id' into the 'taxid' Field, it should be as simple as:
[acct_id]
(The field names cannot have a space, so I do not think that 'acct id' is the field name, it should be the field Alias)
If on the other hand, you want to concatinate the strings from both 'acct id' & 'taxid' into a third field, it can be:
...
4
This code will run existing tools or models that your create:
Private Sub opentool_Click()
'Ensure that there are references set to the
'ESRI GeoprocessingUI Object Library and the
'ESRI Geoprocessing Object Library.
'Go to Tools > References to do this
Dim pUID As New UID
pUID = "esriGeoprocessingUI.ArcToolboxExtension"
Dim pATBExt As ...
4
Use a static variable to keep track of the incremental value (assuming you're using ArcGIS) in thei field calculator (toggle on the 'advanced' tab)
Static cnt As Integer
Dim startValue as Integer
Dim result as Integer
startValue = 192
cnt = cnt + 1
result = cnt + startValue
then, whateveryourfieldnameis="Pipe-" & result
I think that should work
4
The double click is unfortunately not tied to a command, but is handled internally by the TOC contents view which displays a dialog with all property pages applicable to the active selected item. The same is done when selecting Properties.. in the context menu. There is no double click event readily available which you could subscribe to and stop its ...
4
It looks like CreateThiessenPoly.dll has a DllRegisterServer hook, so it is a DLL COM file, which means you can directly reference it from VBA. Note: I used Dependency Walker to determine that you may need msvbvm60.dll from vbrun60.cab (the module was programmed/compiled from Visual Basic 6.)
From the VBA development environment (I'm actually using Excel's, ...
4
Personally, I'd go python all the way
cursor = arcpy.searchcursor(your_table)
for row in cursor:
sort = sorte([row.percent_1,row.percent_2,row.percent_3,row.percent_4])
row.Class_t = sort[len(sort)-1]
cursor.updateRow(row)
del row
del cursor
Play about with it in Idle, it's something like this.
4
it is much easier now in 10.
Right click on the length field and select calculate geometry.
you can select the pcs of the data or the document,
then select the units.
4
Yes you can, but you have things out of order and one important step missing
This should be your order:
startediting
starteditoperation
get insert cursor
create rowbuffer
do your edits
insertcursor.insertrow(buffer) <---- missing
stopeditoperation
stopediting(save)
You may want to look at this example
4
ArcMap has a built-in tool for that: Select Layer by Location (Data Management).
Just select all features from the Select Layer, then use Select by Location (Data Management) with the overlap type "Intersect" and the selection type "Remove_From_Selection." This will remove from the selection all those that intersect the other layer, and you'll be left with ...
4
The following should do it (place it in the code block section):
def calc_distance(shape, x0, y0):
point = shape.getPart(0)
X = point.X
Y = point.Y
d = math.sqrt(pow(X-x0,2) + pow(Y-y0,2))
return d
The Expression should be:
calc_distance(!SHAPE!, 10000, 10000)
However, you'll need to pass the second X and Y you're comparing from ...
4
Have you checked the ESRI Technical Certification website? Under each level (e.g. Desktop 10.1) they provide a PDF with a thorough list of resources including training courses, web lessons and books from ESRI Press.
3
Once you have the Polygon, QI to IPointCollection. You can then iterate over all the points in this PointCollection which are the vertices that you need.
Here is some code which shows how to get the selected features & then get the geometry:
I am writing this from memory, so it might not be exactly correct, but should give you an idea
Dim ...
3
Try the install Microsoft Data Access Components (MDAC) 2.8 SP1
http://www.microsoft.com/downloads/en/details.aspx?familyid=78cac895-efc2-4f8e-a9e0-3a1afbd5922e&displaylang=en
Only top voted, non community-wiki answers of a minimum length are eligible

