Select to view content in your preferred language

arcpy.ExtractData_production does not work in Python GUI?

4773
11
03-26-2014 07:05 AM
ThomasColson
MVP Alum
>>> arcpy.ExtractData_production("'C:\\Temp\\Python\\GRSM_20140326075058.gdb\\Boundaries_And_AOIs\\grsm_bndry_polygon'","C:\\Temp\\Python\\GRSM_20140326075333.gdb","DO_NOT_REUSE","NO_FILTER_BY_GEOMETRY","INTERSECTS","")

 
<Result 'C:\\Temp\\Python\\GRSM_20140326075333.gdb'>



Works fine in the Arc Map Python window.

Per the ESRI help for Extract Data (Production Mapping) one could conclude that

>>> import arcpy
>>> arcpy.CheckOutExtension("Foundation")
u'CheckedOut'
>>> arcpy.ExtractData_production("C:/Temp/Python/GRSM_20140326075058.gdb/Boundaries_And_AOIs/grsm_bndry_polygon","C:/Temp/Python/GRSM_20140326075333.gdb","DO_NOT_REUSE","NO_FILTER_BY_GEOMETRY","INTERSECTS","")


Would work as well in Python Shell.

Nope.

Traceback (most recent call last):
  File "<pyshell#26>", line 1, in <module>
    arcpy.ExtractData_production("C:/Temp/Python/GRSM_20140326075058.gdb/Boundaries_And_AOIs/grsm_bndry_polygon","C:/Temp/Python/GRSM_20140326075333.gdb","DO_NOT_REUSE","NO_FILTER_BY_GEOMETRY","INTERSECTS","")
AttributeError: 'module' object has no attribute 'ExtractData_production'


Tried numerous variations of back, forward, double-slash as per http://resources.arcgis.com/en/help/main/10.1/index.html#//002z0000000r000000

None worked.

So what special trick is required to get arcpy.ExtractData_production to work in Python Shell?
Tags (2)
0 Kudos
11 Replies
ThomasColson
MVP Alum

I'm able to verify the path is valid in the following (sorry for the formatting Geonet toolbars don't work in IE):

import arcpy, sys, traceback
from arcpy import env
import time, os
from subprocess import call
arcpy.CheckOutExtension("Foundation")
arcpy.CheckOutExtension("Spatial")
arcpy.CheckOutExtension("Network")

OutFolder = "C:\\GDB\\OUTPUT\\"
OutName = "TEST_"+time.strftime("%Y%m%d%H%M%S")+".gdb"
GDB = OutFolder+"\\"+OutName

if os.path.exists("C:\\GDB\\TEST.gdb"):
    arcpy.Delete_management("C:\\GDB\\TEST.gdb")
else:
    print ("Nothing to Delete")
   
arcpy.env.configKeyword = "DEFAULTS"
arcpy.CreateFileGDB_management(OutFolder, OutName)

arcpy.env.workspace = "C:\\GDB\\RESTON DB.sde"

arcpy.ExtractData_production("TEST.DBO.Boundaries_And_AOIs",GDB,"DO_NOT_REUSE","","","")
arcpy.ExtractData_production("TEST.DBO.Air_Photo_Footprints",GDB,"DO_NOT_REUSE","","","")
arcpy.ExtractData_production("TEST.DBO.Elevation",GDB,"DO_NOT_REUSE","","","")
arcpy.ExtractData_production("TEST.DBO.GridsAndGrats",GDB,"DO_NOT_REUSE","","","")

arcpy.Compact_management(GDB)

if os.path.exists("C:\\GDB\\TEST.gdb"):
    arcpy.Delete_management("C:\\GDB\\TEST.gdb")
else:
    print ("Nothing to Delete")


arcpy.Copy_management(GDB, "C:\\GDB\\TEST.gdb", "")  

0 Kudos
JamesCrandall
MVP Alum

The example at http://desktop.arcgis.com/en/arcmap/10.3/tools/production-mapping-toolbox/extract-data.htm shows a selection being applied to the input feature layer as well as a test to make sure there is only 1 feature selected before creating the value table of input datasets.  I'm simply not familiar with this tool and what it is supposed to accomplish but it looks like you are attempting to initiate the tool over and over on the unique data within the gdb rather than generating a value table of input datasets and executing the tool once with this parameter.

Instead of executing on each input dataset,

arcpy.ExtractData_production("TEST.DBO.Boundaries_And_AOIs",GDB,"DO_NOT_REUSE","","","")
arcpy.ExtractData_production("TEST.DBO.Air_Photo_Footprints",GDB,"DO_NOT_REUSE","","","")
arcpy.ExtractData_production("TEST.DBO.Elevation",GDB,"DO_NOT_REUSE","","","")
arcpy.ExtractData_production("TEST.DBO.GridsAndGrats",GDB,"DO_NOT_REUSE","","","")‍‍‍‍

The example shows that each of these need to be as a single input parameter,

#change your workspace to the folder rather than the sde connection file
arcpy.env.workspace = "C:/GDB/"

# create a value table of input datasets and filter options
inDatasets="RESTON DB.sde/TEST.DBO.Boundaries_And_AOIs;RESTON DB.sde/TEST.DBO.Air_Photo_Footprints;RESTON DB.sde/TEST.DBO.Elevation;RESTON DB.sde/TEST.DBO.GridsAndGrats ALL_ROWS"

# extract data
reuseSchema="DO_NOT_REUSE"
useFilter="FILTER_BY_GEOMETRY"
filterType="CONTAINS"

arcpy.ExtractData_production(inDatasets,extractGdb,reuseSchema,useFilter,filterType,inFeaturesLyr)‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
0 Kudos