Hello,
The last line of my script produces an error in my script when a network filesystem is provided for "ow_space," but the script works fine when a local filesystem is provided instead. Note that "ow_space" retrieves parameter 0, which is set to "workspace" and not "folder" since I want this parameter to also accept a file geodatabase (which is working in the script). The error message is nonspecific and unhelpful. How can I get arcpy.CreateFeatureclass_management to work regardless of whether ow_space is a network location or a local directory? e.g. \\JLLORENS\Share\GIS
Below is the code in question:
import arcpy
from arcpy import env
from arcpy.sa import *
import os
ow_space = arcpy.GetParameterAsText(0)
in_WSheds = arcpy.GetParameterAsText(1)
file_name = arcpy.GetParameterAsText(2)
vector_extension_output = '.shp'
arcpy.CreateFeatureclass_management(ow_space, ('%s_Longest_Flowpaths_Vector%s' % (file_name, vector_extension_output)), 'POLYLINE', spatial_reference = (arcpy.Describe(in_WSheds).spatialReference))
Solved! Go to Solution.
No, I have full write access.
I found that using the following fixed my issue. I cannot figure out why, since I would expect GetParameterAsText() to return a string anyways, but apparently using str() fixes the issue.
Replacing:
ow_space = arcpy.GetParameterAsText(0)
with:
ow_space = str(arcpy.GetParameterAsText(0))
was the fix. If anyone can elaborate why this works, that would be awesome.
Hi @jllorens,
I agree with @Anonymous User, that is a very likely cause.
You may want to try converting it to "real Path" as well.
arcpy.CreateFeatureclass_management(r'{}'.format(ow_space), ('%s_Long......
That may help since "GetParameterAsText" tends to be very literal, which would mean that the network path would not be complete as far as Python is concerned. \ is an "Escape" character, so to do the start of a network path, usually "\\" you actually need to do "\\\\".
Hope this helps,
Michael
Is there a group policy governing/ access restrictions on your network that may be causing an issue?
No, I have full write access.
I found that using the following fixed my issue. I cannot figure out why, since I would expect GetParameterAsText() to return a string anyways, but apparently using str() fixes the issue.
Replacing:
ow_space = arcpy.GetParameterAsText(0)
with:
ow_space = str(arcpy.GetParameterAsText(0))
was the fix. If anyone can elaborate why this works, that would be awesome.
Hi @jllorens,
I agree with @Anonymous User, that is a very likely cause.
You may want to try converting it to "real Path" as well.
arcpy.CreateFeatureclass_management(r'{}'.format(ow_space), ('%s_Long......
That may help since "GetParameterAsText" tends to be very literal, which would mean that the network path would not be complete as far as Python is concerned. \ is an "Escape" character, so to do the start of a network path, usually "\\" you actually need to do "\\\\".
Hope this helps,
Michael