Hot answers tagged

12 votes
Accepted

Extracting all points within a certain distance and height difference from a Raster

A perhaps-too-simple approach would be to use Focal Statistics. Define the neighborhood of interest as an annulus, with inner radius just under 720m and outer radius just over 720m. (This depends ...
user avatar
  • 8,926
6 votes

Opening QGIS using VBA and executing Python script?

QGIS can take a --code that you can pass a Python file to in order to run. qgis --code my myfile.py Run this command from the VBA shell command.
user avatar
  • 34k
5 votes
Accepted

Calculating Sinuosity Using ArcGIS Field Calculator

If done in Python: Expression parameter: getSinuosity(!shape!) Codeblock parameter: import math def getSinuosity(shape): length = shape.length d = math.sqrt((shape.firstPoint.X - shape....
user avatar
  • 2,364
4 votes
Accepted

Route hatch labeling as stations (0+00) with vba

You missed an underscore in the esri__measure variable in your first 2 if clauses, so they always tested as equal to 0 and fullfilled the condition of the first clause (an uninitialized variable ...
user avatar
4 votes
Accepted

Cannot convert dms to dd in Excel 2007 using VBA code

Are the longitude and latitude values in separate fields? Because the Convert_Decimal function requires a single value. After trying this myself, I think you were trying to convert the DMS values to ...
user avatar
  • 18.3k
4 votes
Accepted

Can't fill the attribute table programmatically

I believe the code you have: Set pFeature.Value(3) = 2 needs to be pFeature.Value(3) = 2 The reason is that the value it is storing is a number and not an object. If you are planning to run this ...
user avatar
  • 39.7k
4 votes
Accepted

"CountIf" or alternative function in ArcMap field calculator?

This is generally not something that should be done using the Field Calculator (although by using a cursor you can do it, it is better to create a standalone Python script). The easiest approach is ...
user avatar
4 votes
Accepted

Creating custom forms in ArcMap

VBA is still available in 10.x, but must be installed separately. Prior to 10.x, it was included with installation files. Now, however, you must install separately and receive a license for the VBA ...
user avatar
  • 5,727
3 votes
Accepted

Matching OBJECTID with value using VBA in ArcMap?

Your code won't work. You loop the cursor until it finishes. At that point pFeature is Nothing. After that you try to access the OID value of pFeature, which is Nothing. If you only select a ...
user avatar
3 votes
Accepted

Tutorial on creating python toolboxes?

As long as a tool is simple input-output python-toolboxes are great, but creating your own gui elements is not supported, drawing line is kinda possible using featureSet, but not in a user friendly ...
user avatar
  • 3,463
3 votes

Collapsing layers in ArcMap Table of Contents using ArcObjects?

Extending on Chad's answer, following does the trick for feature layer with multiple legend groups for (int k = 0; k <= (featureLayer as ILegendInfo).LegendGroupCount - 1; k++) { (featureLayer ...
user avatar
  • 86
3 votes

How to make a Python script that does a task in QGIS?

You will want to run this as a standalone application. The reference for this can be found in the appropritate pyqgis cookbook section. You need to run setup code at the beginning and cleanup code at ...
user avatar
3 votes

"Error in Parcel Selection" in SaeX in ArcGIS 9.3

Installing arcgis did not install visual basic properly. Manually installing VBA solved the problem.
user avatar
  • 8,134
3 votes
Accepted

VBA Labeling works on some symbol classes but not other

If there are any instances of special characters (& and <) in [LOCA_ID], the formatting will fail. You have to replace them dynamically with code like this: Function FindLabel ([LABELFIELD]) ...
user avatar
  • 5,288
2 votes
Accepted

How to get a Layer as ILayer (ArcObjects)

You need to access the active document in order to get access to layers. Create a reference to the document using your IMxApplication object (pMxApp): Dim pMxDoc as IMxDocument = pMxApp.Document ...
user avatar
  • 1,178
2 votes

Route hatch labeling as stations (0+00) with vba

Actually, since you know all your measures always end in +00, because that applies to all intervals of 500, you can simplify the expression to: esri__measure / 100 & "+00" You only need the more ...
user avatar
2 votes
Accepted

Referencing a method from a different class within an Else statement and using 2 variables with the method

Thanks to Daniel from geonet, the problem has been solved. As far as referencing ValidFacet is concerned, the app needed to be changed from 'void' to 'bool'. Daniel also corrected various problems ...
user avatar
  • 309
2 votes
Accepted

Adding VBA code to ArcMap

I was able to find the same answer that @mkennedy wrote as a comment by using Google to search on "arcgis 10.2 vba". The first result was a page entitled Installing ArcGIS for Desktop VBA ...
user avatar
  • 63.9k
2 votes

Any extention Open File Dialog

This is substantially the work of Radar in an answer to a similar question, using the same ArcObjects as Hornbydd does. I have modified Radar's function for my clients to select a delimited text file ...
user avatar
2 votes
Accepted

"Error in Parcel Selection" in SaeX in ArcGIS 9.3

Installation of VBA manually will solve the problem. The VBA can be manually installed from the Installed Directory which Usually is C Drive > Program Files (for 32 bit windows) and Program Files (X86)...
user avatar
  • 741
2 votes

ArcPy/Python method to ascertain VBA requirements in mxd

I don't believe arcpy exposes such properties. You need to be able to drill down into the VBProject and then VBComponents to check if a code module exists. It's been many years since I have mooched ...
user avatar
  • 39.7k
2 votes

VBA/Python If/then statements in Field Calculator for one column based on another not working

It is how you are dealing with Null values. You are treating Null as a string when it is NOTHING! How can nothing be something? But now think about what you are asking, in your case if colour is not ...
user avatar
  • 39.7k
2 votes
Accepted

Ordnance Survey coordinates mismatch when converting from Lat/Lon

It looks like the Excel sheet expects input lat/lon to be in OSGB36, while you are feeding it WGS84. (I just tested the numbers using pyproj, and got the same results as you). I strongly recommend ...
user avatar
1 vote

Matching OBJECTID with value using VBA in ArcMap?

I think SDE_OBJECT_ID might be data type LONG. Have you tried pFeature.OID.ToString(), or whatever the conversion method in VBA is? Not sure if it might fix the issue. Just an idea.
user avatar
  • 1,178
1 vote
Accepted

Any extention Open File Dialog

You can call directly COM object dll Private Declare Function GetOpenFileName Lib "comdlg32.dll" Alias "GetOpenFileNameA" (pOpenfilename As OPENFILENAME) As Long Private Type OPENFILENAME ...
user avatar
1 vote

Any extention Open File Dialog

Below is the code you require: Public Sub OpenDataset() ' Open a dialog for user to select FeatureClasses Dim pEnumGXObject As IEnumGxObject Set pEnumGXObject = Nothing Dim pGxDialog ...
user avatar
  • 39.7k
1 vote
Accepted

How to get the Features of FeatureCursor?

The naming convention you have used is not good, you declare pFeatureLayer, which to everyone on the planet should be an IFeatureLayer object, but you have declared it as an IFeatureSelection. ...
user avatar
  • 39.7k
1 vote

How to get the geometry type FIELD value of attribute table?

@PolyGeo Thanks a lot!! In other words, every time I assigning cell's value to string variable - I have to check if the Field is the Geometry Field, correct? If the field type is Geometry then I ...
user avatar
  • 169
1 vote
Accepted

How to get the geometry type FIELD value of attribute table?

If I have understood you correctly you want to store the text "Polygon" in your array? Shape is the Geometry field so the mismatch error is to be expected, you are trying to store a polygon geometry ...
user avatar
  • 39.7k
1 vote

Merging features into single programmatically

You can use the ITopologicalOperator's Union method to programmatically merge two polygons together. This example (written in VB.NET) shows how that's done. Dim pFirstGeometry As IGeometry = CType(...
user avatar
  • 5,288

Only top scored, non community-wiki answers of a minimum length are eligible