2

I have created the following tool to use in version 10.1:

def getParameterInfo(self):
        """Define parameter definitions"""

        param0 = arcpy.Parameter(
        displayName="Input Table",
        name="Input_Toolbox",
        datatype="GPLayer",
        parameterType="Required",
        direction="Input",
     multiValue=False)

        return [param0]

def execute(self, parameters, messages):
        """The source code of the tool."""

     fc = parameters[0].value  
     oidField = arcpy.Describe(fc).oidFieldName

     with arcpy.da.SearchCursor(fc,["SHAPE@","OID@"]) as search:  
             for line in search:  
                  geometry = line[0]  
                  with arcpy.da.UpdateCursor(fc,["SHAPE@","SHAPE@M","OID@"],explode_to_points=True,where_clause = '{0}={1}'.format(arcpy.AddFieldDelimiters(fc,oidField),line[1])) as update:  
                            for point in update:  
                                point[1] = geometry.measureOnLine(point[0])  
                                 update.updateRow(point)  

But everytime I use it, I get this error:

AttributeError: 'Polyline' object has no attribute 'measureOnLine'

Does anyone know what is the problem? fc is a feature class with polylines.

The problem is MeasureOnLine is a 10.2.1 feature and I have to use 10.1.

Does anyone know what to do?

1
  • 1
    Looks like you are setting the measures for each polyline based on the length of the points along the polyline. Why not just use CreateRoutes and specify a route id that is unique on each feature? Commented Oct 4, 2016 at 16:59

1 Answer 1

3

I suspect that you are trying to use the MeasureOnLine function to perform some sort of linear referencing.

Without access to that function due to your version (ArcGIS 10.1) being earlier than its release I think your best option will be to investigate the Linear Referencing functionality of ArcGIS 10.1 for Desktop:

A linear reference system stores data using a relative position along existing line features. That is, location is given in terms of a known linear feature and a position, or measure, along it.

Your Answer

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

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