Select to view content in your preferred language

ArcGIS Pro Model Builder help with creating points

149
9
Friday
KevinColtart
Emerging Contributor

I am trying to build a model in ArcGIS Pro Model Builder that uses user-entered longitude and latitude values to create Start and End point features, validate that both points fall within another polygon feature already in the project, create a new selection of the polygons that those points sit within, expand that selection to connect the two points (the polygon is a linear feature made up of sections) and then generate a new record using the selected geometry in another feature.

 

I am completely new to Model Builder but see that creating a custom tool could help me and my department save a lot of time.

 

Starting from the beginning and the variable that I need to start with. From research online, I began with variable parameters set to double format. But everything I try to do to create points from them is not working. Could somebody help me please.

0 Kudos
9 Replies
BobBooth1
Esri Regular Contributor

You could create a table with StartLat, StartLon, EndLat,EndLon fields but no records in it. Then make variables that are doubles, and set them as parameters of the tool. Use the Calculate Fields tool to calculate the variables into the fields (you need to wrap the variable name in %, so they'll look like:

%StartLat%

variables_as_parameters.png

Calculate_field_to_variable_value.png

When you run the tools, the variables input on the tool GUI should get calculated into the table.

values_in_table.png

Once values are in table you can use the XY Table to Point tool to make points and use those for further processing.

 

BobBooth1
Esri Regular Contributor

If you want to let them add points by clicking on the map, look at using a Feature Set as an input.

https://doc.esri.com/en/arcgis-pro/latest/help/analysis/geoprocessing/basics/interactive-feature-inp...

0 Kudos
KevinColtart
Emerging Contributor

Good morning,

 

Back at it again this week trying to get this working.

 

I added the elements you suggested. I made a template standalone table on my project with two rows, one for start and one for end. Then made two double (numeric) fields that can contain my Lat and Long.

I have the flow set up as below;

KevinColtart_0-1785918769931.png

The calculate field didn't run when I contained the variable parameter in '%'. I was getting the following error;

File "<string>", line 1 %Start_Latitude% ^ SyntaxError: invalid syntax

When you connect the variable parameter to the calculate field it has the options expression or precondition. Should I connect it like that?

0 Kudos
BobBooth1
Esri Regular Contributor

Is your variable name Start Latitude or Start_Latitude? The spelling in the calculate expression must match the variable name. 

What is the data type of the variable? The syntax %Start_Latitude% syntax should be correct.

https://doc.esri.com/en/arcgis-pro/latest/help/analysis/geoprocessing/modelbuilder/inline-variable-s...

You don't need to connect the variables to the Calculate Field tool, just use the exact name, wrapped in % in the expression box.

You could set it as a precondition, I suppose. Preconditions are a way of ensuring that a given part of a model has run before another part runs.

https://doc.esri.com/en/arcgis-pro/latest/help/analysis/geoprocessing/modelbuilder/using-preconditio...

0 Kudos
KevinColtart
Emerging Contributor

Thanks so much for your replies, this has been giving me a real headache.

 

The label for the variable is 'Start Latitude' but the name is 'Start_Latitude', which is the one I used.

When I try to reference with the % I get the below syntax error.

KevinColtart_0-1785943012459.png

I suspect that it is related to the formatting of the variable and input. Both my variable and my template table fields I am trying to update are set to double.

 

I see the point about preconditions. These won't be needed in this model as it will only start once the variable are input into the tool by the user.

0 Kudos
BobBooth1
Esri Regular Contributor

Try %Start Latitude% - that's what your image of the model shows.

0 Kudos
KevinColtart
Emerging Contributor

I have tried a bunch of variations with no luck. Here are the properties;

KevinColtart_0-1785944588513.png

 

I changed the variables to String and they works but only the first field and only once..

The whole model looks like this now. The fields within my template table are <Null>, could it be that blocking the update?

KevinColtart_1-1785944678371.png

 

0 Kudos
BobBooth1
Esri Regular Contributor

If the values in your calculation are supposed to be coordinates, as Doubles, I'd suggest making the parameters Double too.

Here is my version, for your inspection.

0 Kudos
KevinColtart
Emerging Contributor

Fixing the format has made it work! Not sure what I corrected on the Field calculation tool to make it work. I think learning that you don't need to connect the field parameters to the tools was the curve ball I needed to learn. Being able to reference the variable parameters with the %, despite the validity checker within the field calculation tool saying there is an error. The string error was still there despite it working now.


Thanks very much for the help on this. Your example definitely helped.

Now to build the rest of the tool!

0 Kudos