TransWikia.com

ArcPy: How best to handle output that could be a shapefile or feature class?

Geographic Information Systems Asked on December 18, 2020

In many Esri examples, including this one, they code in the output ".shp". What is the best way if you want to be able to handle a shapefile OR a feature class output. Let say if a GDB is provided as the workspace, then features class, if a folder directory then .shp. Is there any ArcPy built-in to handing this?

One Answer

As commented, it doesnt matter. Just supply the path and ~filename without the .shp extension and arcpy will know what to do.

For example:

  • With a folder named data r"C:GISdataoutputdataset" a shape named outputdataset.shp (and all other shape extensions) will be created in it
  • If the output is a database, like a file geodatabase arcpy will create a feature class in it, example: r"C:GISdatadatabase.gdboutputdataset"

Correct answer by BERA on December 18, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP