arcpy.env.workspace cannot be defined

852
1
09-08-2020 01:31 AM
DrigoHoreis
New Contributor

Hi all,

I have to create a simple python script that would be used as a tool with the functionality of receiving 1 input of a switch number (working on an electric grid system) and the tool would provide as an output the station/substation adjacent to the switch, at first I thought something like SelectByLocation Radius or SpatialJoin would suffice but there is a third variable that needs to be taken into account, both the switches and the stations/substation are located within a building polygon, so I would need to confirm that the feature class line (switch) and the feature class point (station/substation) are within the same polygon.

Now I have a rough idea of making this work by using a dictionary and SelecbyAttribute/Location tools but the main problem is that the data set I'm working on is hosted on my companies local server, i.e when I created my version of the main webmap we were working on, the gdb is located online and not on a local file in my computer, the problem I'm having is that almost all of the online tutorials and learning materials assume that you write a python script starting off with

arcpy.env.workspace = r"C:\Yourfile\YourGDB.gdb"

The problem I'm having is that the only local gdb file i have on my computer is empty, which is the one which is auto created everytime you make a project and I've been unable so far to set any scripts to work with the data from the map I'm working on.

Any help is Appreciated

Cheers

0 Kudos
1 Reply
DanPatterson
MVP Esteemed Contributor

You don't have to specify a workspace.  It is useful to specify if your read and write locations are going to be the same. 

The alternative is to specify paths to the data, even if you have to temporarily make copies to in_memory or 'memory' or to use temporary workspaces using

EnvManager—ArcGIS Pro | Documentation 

If you remove the idea of setting a workspace as your first line... what does your problem boil down to?


... sort of retired...