I have been tasked with creating a model on ArcGIS Pro that allows you to create a point feature and input XY coordinates (British National Grid) from ModelBuilder.
Please note I don't want to use a .csv file or an external table, but just type in the coordinates in the tool.
What I have done on ModelBuilder:
- Copy features (from a template point feature in projected BNG and geographic OSGB 1936). I am using a template with a single row of data.
- Add fields (Northing and Easting, file type: double)
- Calculate fields (here I add the coordinates for Northing and Easting, for example for Easting: 300000, and for Northing: 600000)
- Add XY coordinates
- Calculate fields (I add the value in Easting to Point X and Northing to Point Y).
The model completes the task "succesfully" but unfortunately the final output is not what it should be.
The attribute table of the output shows the fields exactly as I intended them to be (northing, easting, point_x, point_y) as well with the values I inputted, but the feature cannot be located (zoom to layer results in zooming out at very small scale and no point is visible).
If I try to add a new field and calculate point x (from the attribute table) I get - "skipping feature 0 because of NULL or EMPTY geometry".
The output is in the correct spatial reference as are the other working layers and the current map (projected BNG and geographic OSGB 1936).
I don't want to extract the coordinates from an existing table or add the xy coordinates from the attribute table, or create the point with coordinates from the tab "Edit" - I would like to do this in a ModelBuilder tool.
Following advice from stackexchange users I have added the tool "Calculate Value" to the model to update the point geometry, the code is as below:
Expression: getValue(site_location)
Code block:
import arcpy
input = "site_location"
fields = ["Easting", "Northing", "SHAPE@X", "SHAPE@Y"]
cursor=arcpy.UpdateCursor(input, fields)
for row in cursor:
row.setValue(SHAPE@X, row.getValue(Easting))
row.setValue(SHAPE@Y, row.getValue(Northing))
cursor.updateRow(row)
Data type: XY Domain
Unfortunately this doesn't seem to work, resulting in an error: “NameError: name 'getValue' is not defined”