I have been asked to create a custom script to reproject shapefiles (different projections) from a folder, but can't contain values such as filenames and path names to access them.

I have started with Batch Project script and tried to set the input parameter as 'folder' but get the error 000840: The value is not a dataset, because the input values needs to be feature class or dataset.

I have also searched the forum and found:

How do I use python to batch process the reprojection of a group of shapefiles?

But obviously this answer contains values. I have also tried setting;

Set workspace environment;

arcpy.env.workspace = arcpy.GetParameterAsText(0)

Doesn't appear to work.

It is now working after I changed my code from:

arcpy.env.workspace = arcpy.GetParameterAsText(0)


arcpy.env.workspace = arcpy.ListFeatureClasses()

There's one important modification you would need to make to the script that is in the link you posted. In that code there is the variable input_features which is a list of feature classes that exist within the geodatabase that has been set as the workspace. You are on the right track by using arcpy.env.workspace = arcpy.GetParameterAsText(0) to feed the folder path to the script, but you need to change the input_features variable.


input_features = arcpy.ListFeatureClasses()

now the input_features variable is a list of all the feature classes (shapefiles, in this case) that are in the workspace. Here's a little more about arcpy.ListFeatureClasses().


The arcpy functions, classes, etc., are designed to be used. Once you set the workspace, you can use any arcpy functions your license level allows on any appropriate shapefiles, tables, feature classes, coverages, etc. in that workspace.

Sometimes you can just give the full path to the feature on disk, but often you have to use a layer file. This depends on the specific function. In python, you often have to create a layer file from the data on disk before working with it.

When you add a shapefile or feature class to ArcMap, it's actually a layer file as far as ArcMap is concerned. So you don't need to specifically create it.

Essentially, in many/most (?) cases, you're working with a copy of the data which is then written back to the primary data.

  • @PolyGeo, not sure why the edit. It was a reference to the OP's post, giving encouragement. Apologize if this isn't the place to bring this up, clicking your name just brought up your profile. – recurvata Apr 4 '15 at 17:29
  • I always try to upvote words of encouragement when made as comments but, as per the Tour, for Qs&As no chit-chat applies. The desirability of that has been most eloquently put in a Meta SE paragraph headed You gotta get this to get us. Also, the term the asker and then you used is one that I would always edit out or re-word. It is a relatively minor issue. – PolyGeo Apr 4 '15 at 22:48

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.