Using GPInMemoryWorkspace Data

2419
3
10-21-2015 06:03 AM
TerryGustafson
Occasional Contributor II

Good Morning,

I'm hoping someone has run into something similar.  I have looked for a solution with no luck.  I have a GP service that generates a point table through a process.  I want to add the "Make Route Event Layer" to the GP service and use this point table to generate a segment.  When I do this it returns an error that it can't open the in_table.  This in_table is in the GPInMemoryWorkspace.  Is there a way to get to this in memory data so I can generate the segment or is there another way to get it?  TIA.

Terry

Tags (1)
0 Kudos
3 Replies
MichaelKozub
New Contributor II

Can you post some code of how you're creating the in_table? Are you doing something with "in_memory"?

0 Kudos
TerryGustafson
Occasional Contributor II

I have created a model that has a couple input parameters and the in_table is an output parameter. I put the model in a toolbox... I then run the tool and share it as a GP service. Then when I run the GP service it asks for the inputs which would be like begin C000001E and a reference marker i.e. 22 Here is a snap shot of the model and the GP service. Here is a link to the GP service that is created. You should be able to add this to ARCMAP and run it, add the following parameters first point Corridor = C000001E. RM = 22 end point Corridor = C000001E RM 23. You can leave the offsets at zero. It should return a table in the results tab.

https://app.mdt.mt.gov/arcgis/rest/services/Testing/rs/GPServer

not sure if any of this makes sense..

0 Kudos
TerryGustafson
Occasional Contributor II

I exported the model to python and this is the code.  I would have thought there would be a local variable for the points_Events

# -*- coding: utf-8 -*-
# ---------------------------------------------------------------------------
# seg.py
# Created on: 2015-10-22 10:41:12.00000
#   (generated by ArcGIS/ModelBuilder)
# Usage: seg <first_point> <end_point> <merge__3_> <points> <points_Events> 
# Description: 
# ---------------------------------------------------------------------------
# Import arcpy module
import arcpy
# Load required toolboxes
arcpy.ImportToolbox("E:/MDTAPPS/terry/ref segment.tbx")
# Script arguments
first_point = arcpy.GetParameterAsText(0)
if first_point == '#' or not first_point:
    first_point = "E:\\MDTAPPS\\terry\\Default.gdb\\first_point" # provide a default value if unspecified
end_point = arcpy.GetParameterAsText(1)
if end_point == '#' or not end_point:
    end_point = "E:\\MDTAPPS\\terry\\Default.gdb\\end_point" # provide a default value if unspecified
merge__3_ = arcpy.GetParameterAsText(2)
if merge__3_ == '#' or not merge__3_:
    merge__3_ = "E:\\MDTAPPS\\terry\\Default.gdb\\merge" # provide a default value if unspecified
points = arcpy.GetParameterAsText(3)
if points == '#' or not points:
    points = "E:\\MDTAPPS\\terry\\Default.gdb\\points" # provide a default value if unspecified
points_Events = arcpy.GetParameterAsText(4)
if points_Events == '#' or not points_Events:
    points_Events = "points Events3" # provide a default value if unspecified
# Local variables:
first_point__2_ = first_point
first_point_Event = first_point__2_
first_point_ev = first_point_Event
Output_Event_Table_Properties = first_point_Event
end_point__2_ = end_point
end_point_Event = end_point__2_
end_point_ev = end_point_Event
end_point_ev_View = end_point_ev
Output_Event_Table_Properties__2_ = end_point_Event
MDTGIS_ROUTES_LRM_RM = "MDTGIS.ROUTES_LRM_RM"
MDTGIS_ROUTES_LRM_DC_MI = "MDTGIS.ROUTES_LRM_DC_MI"
MDTGIS_ROUTES_LRM_DC_MI__2_ = "MDTGIS.ROUTES_LRM_DC_MI"
Default_gdb = "E:\\MDTAPPS\\terry\\Default.gdb"
MDTGIS_ROUTES_LRM_DC_MI__3_ = "MDTGIS.ROUTES_LRM_DC_MI"
# Process: Calculate Field
arcpy.CalculateField_management(first_point, "Corridor", "str(!Corridor!) + \"_\" + str(!RM!)", "PYTHON_9.3", "")
# Process: Make Route Event Layer
arcpy.MakeRouteEventLayer_lr(MDTGIS_ROUTES_LRM_RM, "ROUTE_ID", first_point__2_, "Corridor POINT beg_offset", first_point_Event, "", "ERROR_FIELD", "NO_ANGLE_FIELD", "NORMAL", "ANGLE", "LEFT", "POINT")
# Process: Locate Features Along Routes
arcpy.LocateFeaturesAlongRoutes_lr(first_point_Event, MDTGIS_ROUTES_LRM_DC_MI, "CORRIDOR", "0 Meters", first_point_ev, Output_Event_Table_Properties, "FIRST", "DISTANCE", "ZERO", "FIELDS", "M_DIRECTON")
# Process: Calculate Field (2)
arcpy.CalculateField_management(end_point, "Corridor", "str(!Corridor!) + \"_\" + str(!RM!)", "PYTHON_9.3", "")
# Process: Make Route Event Layer (2)
arcpy.MakeRouteEventLayer_lr(MDTGIS_ROUTES_LRM_RM, "ROUTE_ID", end_point__2_, "Corridor POINT end_offset", end_point_Event, "", "ERROR_FIELD", "NO_ANGLE_FIELD", "NORMAL", "ANGLE", "LEFT", "POINT")
# Process: Locate Features Along Routes (2)
arcpy.LocateFeaturesAlongRoutes_lr(end_point_Event, MDTGIS_ROUTES_LRM_DC_MI__2_, "CORRIDOR", "0 Meters", end_point_ev, Output_Event_Table_Properties__2_, "FIRST", "DISTANCE", "ZERO", "FIELDS", "M_DIRECTON")
# Process: Make Table View
arcpy.MakeTableView_management(end_point_ev, end_point_ev_View, "", "", "OBJECTID OBJECTID VISIBLE NONE;RID RID VISIBLE NONE;to_MEAS to_MEAS VISIBLE NONE;Distance Distance VISIBLE NONE;RM RM VISIBLE NONE")
# Process: Merge
arcpy.Merge_management("E:\\MDTAPPS\\terry\\Default.gdb\\first_point_ev;end_point_ev_View", merge__3_, "RID \"CORRIDOR\" true true false 10 Text 0 0 ,First,#,E:\\MDTAPPS\\terry\\Default.gdb\\first_point_ev,RID,-1,-1,end_point_ev_View,RID,-1,-1;from_MEAS \"from_MEAS\" true true false 0 Double 0 0 ,First,#,E:\\MDTAPPS\\terry\\Default.gdb\\first_point_ev,from_MEAS,-1,-1;to_MEAS \"to_MEAS\" true true false 0 Double 0 0 ,First,#,end_point_ev_View,to_MEAS,-1,-1")
# Process: Table to Table
arcpy.TableToTable_conversion(merge__3_, Default_gdb, "points", "", "RID \"CORRIDOR\" true true false 10 Text 0 0 ,First,#,E:\\MDTAPPS\\terry\\Default.gdb\\merge,RID,-1,-1;from_MEAS \"from_MEAS\" true true false 0 Double 0 0 ,First,#,E:\\MDTAPPS\\terry\\Default.gdb\\merge,from_MEAS,-1,-1;to_MEAS \"to_MEAS\" true true false 0 Double 0 0 ,First,#,E:\\MDTAPPS\\terry\\Default.gdb\\merge,to_MEAS,-1,-1", "")
# Process: Make Route Event Layer (3)
arcpy.MakeRouteEventLayer_lr(MDTGIS_ROUTES_LRM_DC_MI__3_, "CORRIDOR", points, "rid LINE from_MEAS to_MEAS", points_Events, "", "ERROR_FIELD", "NO_ANGLE_FIELD", "NORMAL", "ANGLE", "LEFT", "POINT")
# Process: Script1
arcpy.gp.toolbox = "E:/MDTAPPS/terry/ref segment.tbx";
# Warning: the toolbox E:/MDTAPPS/terry/ref segment.tbx DOES NOT have an alias. 
# Please assign this toolbox an alias to avoid tool name collisions
# And replace arcpy.gp.Script1(...) with arcpy.Script1_ALIAS(...)
arcpy.gp.Script1()
0 Kudos