Tell me more ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

This is a silly question, but I have this code snippet that I can't figure out:

'Define a calculator for NewArea field
    pCalculator = New Calculator
    With pCalculator
        .Cursor = pCursor
        .PreExpression = "Dim dbarea as double" & vbCrLf _
                       & "Dim pArea as IArea" & vbCrLf _
                       & "Set pArea = [Shape]" & vbCrLf _
                       & "dbArea = pArea.area"
        .Expression = "dbArea"
        .Field = "NewArea"
    End With

    'Calculate the field values of NewArea field
    pCalculator.Calculate()

What is pCalculator calculating here? What is [Shape] in this context? I'm migrating this old VBA code to Python, and I'm stuck at this segment. Thanks in advance.

A more general question, what is the significance of the square brackets in the pre-expression? Are they placeholders for the expression?

share|improve this question

1 Answer

up vote 3 down vote accepted

All this is doing is calculating the area of each feature. You can easily do the same thing with the Python version of the parser with !shape.area!. See the documentation.

share|improve this answer
Awesome, thank you. – Kyle M Feb 27 at 3:20

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.