<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: ERROR 000354 when calling Connect Public Transit Data Model To Streets in python script in Public Transit Questions</title>
    <link>https://community.esri.com/t5/public-transit-questions/error-000354-when-calling-connect-public-transit/m-p/1383627#M620</link>
    <description>&lt;P&gt;Okay.&amp;nbsp; Well I don't see anything obvious from just looking at the script, unfortunately.&amp;nbsp; You may need to call Esri Support so they can dig into your data and script in detail and figure out what's happening.&lt;/P&gt;</description>
    <pubDate>Fri, 16 Feb 2024 21:00:43 GMT</pubDate>
    <dc:creator>MelindaMorang</dc:creator>
    <dc:date>2024-02-16T21:00:43Z</dc:date>
    <item>
      <title>ERROR 000354 when calling Connect Public Transit Data Model To Streets in python script</title>
      <link>https://community.esri.com/t5/public-transit-questions/error-000354-when-calling-connect-public-transit/m-p/1382604#M615</link>
      <description>&lt;P&gt;Hello, I'm getting "&lt;SPAN&gt;ERROR 000354: The name contains invalid characters" at line 59 of the attached python script, at the ConnectPublicTransitDataModelToStreets call:&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# Imports
import arcpy
import os
import pandas as pd
from arcgis.features import GeoAccessor, GeoSeriesAccessor

# Paths
proj_dir = r"C:\Users\josephda\GitHub\osm"
streets_dir = proj_dir + r'\data\raw\Street_Centerlines\Street_Centerlines.shp'
gtfs_dir = proj_dir + r'\data\raw\gtfs'
aprx_dir = proj_dir + r'\arcgis\arcgis.aprx'
gdb_dir = proj_dir + r'\arcgis\arcgis.gdb'
nw_dir = proj_dir + r'\arcgis\arcgis.gdb\TransitNetwork'
aprx_dir = proj_dir + r'\arcgis\arcgis.aprx'

# Environment settings
arcpy.env.workspace = gdb_dir

# Set output coordinate system to NAD83 CA Albers
arcpy.env.outputCoordinateSystem = arcpy.SpatialReference(3310)

# Declare the project file
aprx = arcpy.mp.ArcGISProject(aprx_dir)

# List maps in the project
for m in aprx.listMaps():
    print(m.name)
    # List layers in the map
    for lyr in m.listLayers():
        print(lyr.name)
        # Remove any existing layers except the basemap
        if lyr.isBasemapLayer == False:
            m.removeLayer(lyr)
    aprx.save() 


# Load the streets shapefile as a spatially enabled dataframe
streets_sed = pd.DataFrame.spatial.from_featureclass(streets_dir)
streets_fc = streets_sed.spatial.to_featureclass(location=gdb_dir + r'\streets_fc')

# Add restrict pedestrian field
arcpy.AddField_management("streets_fc", "RestrictPedestrians", "TEXT")
arcpy.CalculateField_management("streets_fc", "RestrictPedestrians", "'Y' if !circulatio! == 'Freeway' or !circulatio! == 'State Route' or !road_type! == 'Railway' else 'N'", "PYTHON")
arcpy.AddField_management("streets_fc", "ROAD_CLASS", "SHORT")

# Create the feature dataset
arcpy.CreateFeatureDataset_management(gdb_dir, "TransitNetwork", arcpy.SpatialReference(3310))

# Covert GTFS to transit data model
arcpy.transit.GTFSToPublicTransitDataModel(gtfs_dir, nw_dir, "NO_INTERPOLATE", "NO_APPEND")

# Copy streets to TransitNetwork feature dataset as "Streets"
arcpy.CopyFeatures_management("streets_fc", nw_dir + r'\Streets')

# Delete initial copy of streets
arcpy.Delete_management("streets_fc")

# Connect the transit data model to streets
arcpy.transit.ConnectPublicTransitDataModelToStreets(nw_dir, "Streets", "100 Meters", "RestrictPedestrians &amp;lt;&amp;gt; 'N'")&lt;/LI-CODE&gt;&lt;P&gt;Here's an image of the error:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JosephAhrenholtz1_0-1707946101823.png" style="width: 783px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/94812i2F0571141E6E8F16/image-dimensions/783x233?v=v2" width="783" height="233" role="button" title="JosephAhrenholtz1_0-1707946101823.png" alt="JosephAhrenholtz1_0-1707946101823.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I can't figure out what exactly is causing the error.&amp;nbsp; I don't see any issues with the filename "Streets" and the path to the network dataset it resides in works in subsequent lines.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can run the&amp;nbsp;ConnectPublicTransitDataModelToStreets tool in the ArcGIS Pro GUI and it runs fine.&amp;nbsp; However if I copy the python command as is directly into my script and run it, it fails with the same error message.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any suggestions for how address this would be appreciated.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Feb 2024 23:27:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/public-transit-questions/error-000354-when-calling-connect-public-transit/m-p/1382604#M615</guid>
      <dc:creator>JosephAhrenholtz1</dc:creator>
      <dc:date>2024-02-14T23:27:30Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR 000354 when calling Connect Public Transit Data Model To Streets in python script</title>
      <link>https://community.esri.com/t5/public-transit-questions/error-000354-when-calling-connect-public-transit/m-p/1383035#M616</link>
      <description>&lt;P&gt;Hmm, I'm not sure why you're getting that error based on what I see in the code.&amp;nbsp; However, the one thing that jumps out at me is the way you're constructing filepaths in the Python script.&amp;nbsp; It's safer to use os.path.join() to construct paths from multiple components rather than the + operator.&amp;nbsp; It doesn't&amp;nbsp;&lt;EM&gt;seem&lt;/EM&gt; like the way you have them should cause an error, but it's not really the best coding practice.&lt;/P&gt;&lt;P&gt;Try updating like this, and see if that fixes it:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;streets_dir = os.path.join(proj_dir, '\data\raw\Street_Centerlines\Street_Centerlines.shp')&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Feb 2024 19:27:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/public-transit-questions/error-000354-when-calling-connect-public-transit/m-p/1383035#M616</guid>
      <dc:creator>MelindaMorang</dc:creator>
      <dc:date>2024-02-15T19:27:37Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR 000354 when calling Connect Public Transit Data Model To Streets in python script</title>
      <link>https://community.esri.com/t5/public-transit-questions/error-000354-when-calling-connect-public-transit/m-p/1383181#M617</link>
      <description>&lt;P&gt;Got it, appreciate the suggestion.&amp;nbsp; I'm shifting from primarily using R so am still familiarizing myself with best practices in Python.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've updated the code using the os.path.join() method, which required me to concatenate each level to build the full path.&amp;nbsp; See in the code below:&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# Imports
import arcpy
import os
import pandas as pd
from arcgis.features import GeoAccessor, GeoSeriesAccessor

# Paths
proj_dir = r"C:\Users\josephda\GitHub\osm"
streets_dir = os.path.join(proj_dir, "data", "raw", "Street_Centerlines", "Street_Centerlines.shp")
gtfs_dir = os.path.join(proj_dir, "data", "raw", "gtfs")
aprx_dir = os.path.join(proj_dir, "arcgis", "arcgis.aprx")
gdb_dir = os.path.join(proj_dir, "arcgis", "arcgis.gdb")
nw_dir = os.path.join(proj_dir, "arcgis", "arcgis.gdb", "TransitNetwork")

# Environment settings
arcpy.env.workspace = gdb_dir

# Set output coordinate system to NAD83 CA Albers
arcpy.env.outputCoordinateSystem = arcpy.SpatialReference(3310)

# Declare the project file
aprx = arcpy.mp.ArcGISProject(aprx_dir)

# List maps in the project
for m in aprx.listMaps():
    print(m.name)
    # List layers in the map
    for lyr in m.listLayers():
        print(lyr.name)
        # Remove any existing layers except the basemap
        if lyr.isBasemapLayer == False:
            m.removeLayer(lyr)
    aprx.save() 


# Load the streets shapefile as a spatially enabled dataframe
streets_sed = pd.DataFrame.spatial.from_featureclass(streets_dir)

# Create fc from streets sed
streets_fc_dir = os.path.join(gdb_dir, "streets_fc")
streets_fc = streets_sed.spatial.to_featureclass(streets_fc_dir)

# Add restrict pedestrian field
arcpy.AddField_management("streets_fc", "RestrictPedestrians", "TEXT")
arcpy.CalculateField_management("streets_fc", "RestrictPedestrians", "'Y' if !circulatio! == 'Freeway' or !circulatio! == 'State Route' or !road_type! == 'Railway' else 'N'", "PYTHON")
arcpy.AddField_management("streets_fc", "ROAD_CLASS", "SHORT")

# Create the feature dataset
arcpy.CreateFeatureDataset_management(gdb_dir, "TransitNetwork", arcpy.SpatialReference(3310))

# Covert GTFS to transit data model
arcpy.transit.GTFSToPublicTransitDataModel(gtfs_dir, nw_dir, "NO_INTERPOLATE", "NO_APPEND")

# Copy streets to TransitNetwork feature dataset as "Streets"
nw_streets_dir = os.path.join(nw_dir, "Streets")
arcpy.CopyFeatures_management("streets_fc", nw_streets_dir)

# Delete the other copy of streets
arcpy.Delete_management("streets_fc")

# Connect the transit data model to streets
arcpy.transit.ConnectPublicTransitDataModelToStreets(nw_dir, "Streets", "100 Meters", "RestrictPedestrians &amp;lt;&amp;gt; 'N'")&lt;/LI-CODE&gt;&lt;P&gt;It throws the same error&lt;/P&gt;&lt;P&gt;&amp;nbsp;Unfortunately, this update still throws the same 000354 error when connecting the transit model to streets (at line 62).&amp;nbsp; If I replace line 62 with the following:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;arcpy.transit.ConnectPublicTransitDataModelToStreets(r"C:\Users\josephda\GitHub\osm\arcgis\arcgis.gdb\TransitNetwork", "Streets", "100 Meters", "RestrictPedestrians &amp;lt;&amp;gt; 'N'")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;It throws the same error.&amp;nbsp; This makes me think the issue isn't rooted in the path construction, but I could be wrong.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Feb 2024 00:07:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/public-transit-questions/error-000354-when-calling-connect-public-transit/m-p/1383181#M617</guid>
      <dc:creator>JosephAhrenholtz1</dc:creator>
      <dc:date>2024-02-16T00:07:16Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR 000354 when calling Connect Public Transit Data Model To Streets in python script</title>
      <link>https://community.esri.com/t5/public-transit-questions/error-000354-when-calling-connect-public-transit/m-p/1383395#M618</link>
      <description>&lt;P&gt;Does the tool still error if you replace "Streets" with the full path to the streets feature class?&amp;nbsp; Maybe the tool isn't correctly paying attention to the workspace environment set in the script.&lt;/P&gt;</description>
      <pubDate>Fri, 16 Feb 2024 15:17:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/public-transit-questions/error-000354-when-calling-connect-public-transit/m-p/1383395#M618</guid>
      <dc:creator>MelindaMorang</dc:creator>
      <dc:date>2024-02-16T15:17:55Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR 000354 when calling Connect Public Transit Data Model To Streets in python script</title>
      <link>https://community.esri.com/t5/public-transit-questions/error-000354-when-calling-connect-public-transit/m-p/1383622#M619</link>
      <description>&lt;P&gt;Yeah, still the same error when replacing "Streets" with the full path to the fc.&lt;/P&gt;</description>
      <pubDate>Fri, 16 Feb 2024 20:48:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/public-transit-questions/error-000354-when-calling-connect-public-transit/m-p/1383622#M619</guid>
      <dc:creator>JosephAhrenholtz1</dc:creator>
      <dc:date>2024-02-16T20:48:02Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR 000354 when calling Connect Public Transit Data Model To Streets in python script</title>
      <link>https://community.esri.com/t5/public-transit-questions/error-000354-when-calling-connect-public-transit/m-p/1383627#M620</link>
      <description>&lt;P&gt;Okay.&amp;nbsp; Well I don't see anything obvious from just looking at the script, unfortunately.&amp;nbsp; You may need to call Esri Support so they can dig into your data and script in detail and figure out what's happening.&lt;/P&gt;</description>
      <pubDate>Fri, 16 Feb 2024 21:00:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/public-transit-questions/error-000354-when-calling-connect-public-transit/m-p/1383627#M620</guid>
      <dc:creator>MelindaMorang</dc:creator>
      <dc:date>2024-02-16T21:00:43Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR 000354 when calling Connect Public Transit Data Model To Streets in python script</title>
      <link>https://community.esri.com/t5/public-transit-questions/error-000354-when-calling-connect-public-transit/m-p/1383689#M621</link>
      <description>&lt;P&gt;Ok yeah I'll keep troubleshooting and call support if needed.&amp;nbsp; Thanks for taking a look.&lt;/P&gt;</description>
      <pubDate>Fri, 16 Feb 2024 23:14:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/public-transit-questions/error-000354-when-calling-connect-public-transit/m-p/1383689#M621</guid>
      <dc:creator>JosephAhrenholtz1</dc:creator>
      <dc:date>2024-02-16T23:14:13Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR 000354 when calling Connect Public Transit Data Model To Streets in python script</title>
      <link>https://community.esri.com/t5/public-transit-questions/error-000354-when-calling-connect-public-transit/m-p/1383693#M622</link>
      <description>&lt;P&gt;One further thought (after looking at the tool code): Try printing the value of&amp;nbsp;&lt;SPAN&gt;arcpy&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;env&lt;/SPAN&gt;&lt;SPAN&gt;.scratchGDB in your code and see what it points to.&amp;nbsp; Delete it, and try running the script again.&amp;nbsp; I've seen cases where the scratch gdb gets corrupted, and then weird things happen.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Possibly it works when you run the tool in the Pro UI because it's pointing to a different scratch gdb.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Feb 2024 23:41:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/public-transit-questions/error-000354-when-calling-connect-public-transit/m-p/1383693#M622</guid>
      <dc:creator>MelindaMorang</dc:creator>
      <dc:date>2024-02-16T23:41:17Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR 000354 when calling Connect Public Transit Data Model To Streets in python script</title>
      <link>https://community.esri.com/t5/public-transit-questions/error-000354-when-calling-connect-public-transit/m-p/1383704#M623</link>
      <description>&lt;P&gt;That was it!&amp;nbsp; After deleting scratch gdb the script ran successfully.&amp;nbsp; I wish I knew how exactly the scratch gdb was possibly corrupted to avoid or help trouble shoot future issues.&amp;nbsp; But in any case it worked.&amp;nbsp; Thanks very much!&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 17 Feb 2024 01:18:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/public-transit-questions/error-000354-when-calling-connect-public-transit/m-p/1383704#M623</guid>
      <dc:creator>JosephAhrenholtz1</dc:creator>
      <dc:date>2024-02-17T01:18:10Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR 000354 when calling Connect Public Transit Data Model To Streets in python script</title>
      <link>https://community.esri.com/t5/public-transit-questions/error-000354-when-calling-connect-public-transit/m-p/1384357#M624</link>
      <description>&lt;P&gt;&lt;SPAN&gt;"I wish I knew how exactly the scratch gdb was possibly corrupted"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Me too!&amp;nbsp; I'd love to get that fixed on our end.&lt;/P&gt;&lt;P&gt;Glad that worked!!&lt;/P&gt;</description>
      <pubDate>Tue, 20 Feb 2024 14:54:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/public-transit-questions/error-000354-when-calling-connect-public-transit/m-p/1384357#M624</guid>
      <dc:creator>MelindaMorang</dc:creator>
      <dc:date>2024-02-20T14:54:12Z</dc:date>
    </item>
  </channel>
</rss>

