0

Having some issues running the Connect Public Transit Data Model To Streets (Public Transit) tool with arcpy. Getting an error code when completing a script provided by Esri - located here. I modeled my code after the script found in the previous link.

Getting "ERROR 000358: Invalid expression." I have reviewed the inputs, and I do not believe it to be invalid. This seems like a simple fix with the where clause; perhaps I am missing something, but I have written that differently without any luck.

Here is the code:

import arcpy
import os
arcpy.CheckOutExtension("network")
arcpy.env.overwriteOutput = True


fd_path = r"D:\Python\PlanningTools\TransitAccessibility\Tools\GTFStoNetworkAnalysisModel\Inputs\TransitAnalysis\TransitNetwork.gdb\TransitNetwork"
streets = os.path.join(fd_path, "Streets")
where = "RestrictPe = 1"
arcpy.transit.ConnectPublicTransitDataModelToStreets(fd_path, streets, "100 meters", where)

And here is the error:

ERROR 000358: Invalid expression ERROR: Failed to execute (MakeFeatureLayer). Traceback (most recent call last): File "C:\Users\Owner\PycharmProjects\PlanningTools\testing.py", line 11, in arcpy.transit.ConnectPublicTransitDataModelToStreets(fd_path, streets, "100 meters", where) File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\transit.py", line 330, in ConnectPublicTransitDataModelToStreets raise e File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\transit.py", line 327, in ConnectPublicTransitDataModelToStreets retval = convertArcObjectToPythonObject(gp.ConnectPublicTransitDataModelToStreets_transit(*gp_fixargs((target_feature_dataset, in_streets_features, search_distance, expression), True))) File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\geoprocessing_base.py", line 512, in return lambda *args: val(*gp_fixargs(args, True)) arcgisscripting.ExecuteError: ERROR 000358: Invalid expression Failed to execute (MakeFeatureLayer). Failed to execute (ConnectPublicTransitDataModelToStreets).

New contributor
MattMDL is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
2
  • 1
    It appears that internally, the tool is attempting to run Make Feature Layer and has failed. Since turning a feature dataset into a layer doesn't make sense, I'd guess it's failing on your streets featureclass. Perhaps, as a test, within your script run Make Feature Layer on your streets, and use the result of that into the tool.
    – KHibma
    Sep 23 at 16:33
  • 1
    OR - its failing to apply your where = "RestrictPe = 1" with Make Feature Layer. A good test here would be to go into Pro, and using the GP Tools, run Make Feature Layer and build the expression to match what you want. Run it to be sure it works. If it does, get the Python code and see if it's different than your script
    – KHibma
    Sep 23 at 16:36

0

Your Answer

MattMDL is a new contributor. Be nice, and check out our Code of Conduct.

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.