3

As part of a larger, more complex model, I need to generate random points over an input feature class where the ModelBuilder calculates the minimum allowed distance on the fly. This is my minimum working example:

Example model

In this model, my number is a user-defined integer. In this case 50. This number is modified by the Calculate Value Tool (equation: 2* my number + 30, output type: Long) to create the number dist.

The Constraint Polygons is just an ordinary multi-polygon feature class. workspace is the output workspace for the random points.

The value dist is connected as "Minimum Allowed Distance [value or field]", and was calculated as a Long-type by the Calculate Value Tool.

Connection between dist and Generate Random Points

When I run the model, I get the error 'Error 000176: Field must be numeric'. Error when running the model

I tried to turn the value dist into a Double-type, but that didn't help. I also tried adding dist as a precondition to Create Random Points, but that didn't help either. I also tried inserting %dist% in Minimum Allowed Distance, but that only resulted in the tool using 0m distance.

How can I generate a set of points using a pre-calculated distance?

Alternative I tried

PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked Sep 2, 2024 at 11:09

2 Answers 2

2

If you review the help file for Create Random Points and look at the parameter section, what is the Data Type for the parameter Minimum Allowed Distance? You have fed in a number long or double but the data type is Linear Units. This is the problem.

The output of your calculate value tool needs to be a Linear Units object not a number as you have provided.

So how do you build one? Run the create random points tool on some test data, then from history panel copy to script and you will see the structure of it and this is what your Calculate Value tool needs to build. Something like "100 Meters".

answered Sep 2, 2024 at 11:46
1
  • 1
    Thanks I thought I was going mad. I used str(num) + " Meters" in the code block to convert the number to a linear unit. When the data type of the Calculate Value Tool is also set to Linear Units, it works. Commented Sep 2, 2024 at 12:40
0

The error message could point to a possible solution: Check the "Data type" at the bottom of the Dialog of Calculate Value. This should be Double for Decimal Numbers or Long for Integers. At the Moment it is probably set to Variant.

answered Sep 2, 2024 at 11:46
1
  • 1
    Good point, but this was already mentioned in the question and it did not solve my issue. Commented Sep 2, 2024 at 12:17

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.