Hello everyone,
I have a table and a shapefile containing lining up points
The Shapefile contains all points in order from 1 to x without any additional metadata kinda like this
iD | Shape |
1 | Point |
2 | Point |
... | ... |
X | Point |
The other table contains infos about the Naming of Profiles which are made up of those points something like this:
Name | iD from | iD to |
Profile 1 | 1 | 50 |
Profile 2 | 51 | 90 |
... | ... | ... |
Profile Y | 23455 | 23501 |
I am trying to join those features in a way that I add a column to my shapefile containing the info about the Profile names like so:
iD | Shape | Profile Name |
1 | Point | Profile 1 |
2 | Point | Profile 1 |
... | ... | ... |
50 | Point | Profile 1 |
51 | Point | Profile 2 |
... | ... | ... |
90 | Point | Profile 2 |
... | ... | ... |
I reckon there must be some way to join tables, but having to columns with start and end ID's is throwing me off. Does anyone have an idea?
Thank you
I managed to do this in excel via some exporting and vlookup but if there is any build-in functionality, I would be thankful to know 😉
Hi
1) Use the attached python scripts to create a python toolbox:
2) You must add the Feature Class (point) and the Table to the content of ArcGIS Pro
3) Select the features to update
4) Run the python toolbox
Filegeodatabase annex, image of my desktop and python scripts
# -*- coding: utf-8 -*-
import arcpy
import arcgis
class Toolbox(object):
def __init__(self):
"""Define the toolbox (the name of the toolbox is the name of the
.pyt file)."""
self.label = "ProfileName"
self.alias = "Profile name"
# List of tool classes associated with this toolbox
self.tools = [UpdateProfile]
class UpdateProfile(object):
def __init__(self):
"""Define the tool (tool name is the name of the class)."""
self.label = "UpdateProfile"
self.description = "Update profile name"
self.canRunInBackground = False
def getParameterInfo(self):
"""Define parameter definitions"""
# Input parameter: feature class
param0 = arcpy.Parameter(
displayName="Feature class: Lining up points ",
name="in_features",
datatype="GPFeatureLayer",
parameterType="Required",
direction="Input")
# Input parameter: Table
param1 = arcpy.Parameter(
displayName="Table: Naming of Profiles ",
name="in_records",
datatype="GPTableView",
parameterType="Required",
direction="Input")
parameters = [param0, param1]
return parameters
def isLicensed(self):
"""Set whether tool is licensed to execute."""
return True
def updateParameters(self, parameters):
"""Modify the values and properties of parameters before internal
validation is performed. This method is called whenever a parameter
has been changed."""
return
def updateMessages(self, parameters):
"""Modify the messages created by internal validation for each tool
parameter. This method is called after internal validation."""
return
def execute(self, parameters, messages):
"""The source code of the tool."""
arcpy.AddMessage("Running task with following parameters")
arcpy.AddMessage("1. Create the update cursor: Featue Class(Lining up points)")
update_cursor = arcpy.UpdateCursor(parameters[0].valueAsText)
arcpy.AddMessage("2. Create the search cursor: Table(Naming of Profiles")
# Update the Point(profileName) based on Naming of Profiles
for row in update_cursor:
# search the Naming of Profiles
for row_pf in arcpy.SearchCursor(parameters[1].valueAsText):
if row.Id >= row_pf.IdFrom and row.Id <= row_pf.IdTo:
row.setValue("ProfileName", row_pf.Name)
update_cursor.updateRow(row)
arcpy.AddMessage("Id: "+str(row.Id)+" Profile: "+str(row.ProfileName))
# Delete cursor and row objects
del row, row_pf
return
Reinaldo.
Hey thanks, I will try this out on the next dataset