Quantcast
Channel: Forums - Python
Viewing all articles
Browse latest Browse all 2485

Problem writing to file geodatabase other than default.gdb

$
0
0
I have a script that selects parcels within a boundary and then runs a dissolve on those parcels. I have a file geodatabase that I want to use for the output. If I have my workspace set to my default.gdb, everything works great. When I change my workspace to a different file geodatabase, I get "ExecuteError: ERROR 000210: Cannot create output" and the dissolve fails to execute. When I look into the file geodatabase, the new feature class is created but it is empty.

Are there permissions or environment variables that need to be set so that I can write to a different FGDB?

what am I doing wrong?

Thanks,
Janice.

Code:

import sys, os
import arcpy
from arcpy import env

env.overwriteOutput = True

### Set the workspace ---
env.workspace = r"C:\Users\janiceb\Documents\ArcGIS\Default.gdb"
##env.workspace = r"\\skagit\dept\gis\janiceb\Projects\Health\June_2014\Septic.gdb"

print env.workspace

## Parcel Layer
prodParcelPolys = r"Database Connections\SQLVM3_scgis.sde\Scgis.SDEADM.Parcel_Polys"
tempParcels = "Temp_Copy_of_Parcels"
tempDOHParcels = "Temp_Copy_of_DOH_Parcels"
## MRA Layer
prodMRAPolys = r"Database Connections\SQLVM9_Health.sde\Health.SDEADM.MarineRecoveryAreas"
tempMRAs = "Temp_Copy_of_MRAs"
## Final Data to be written to file geodatabase for sharing with DOH
finalDOHParcels = "ParcelsInMRA"

# Make a temporary layer from the parcel feature class
print("  -> Making temporary copy of the Parcel layer...")
arcpy.MakeFeatureLayer_management(prodParcelPolys, tempParcels)

# Make a temporary layer from the MRA feature class
print("  -> Making temporary copy of the MRA layer...")
arcpy.MakeFeatureLayer_management(prodMRAPolys, tempMRAs)

# Select those parcels with centroid in MRA Polygons
arcpy.SelectLayerByLocation_management(tempParcels, "HAVE_THEIR_CENTER_IN", tempMRAs, 5, "NEW_SELECTION")
print("FYI :: Number of parcels with centroid in MRA Polygons: {0}".format(str(arcpy.GetCount_management(tempParcels).getOutput(0))))

# Dissolve the parcels in the MRA by PARCELID
# This will combine parcels with duplicate parcelid values (ex: parcels divided by a road or river.)
# This will give us a feature class of parcels which are located in the MRA
print("  -> Dissolving by parcel id...")
dissolveFields = ["PARCELID"]
arcpy.Dissolve_management(tempParcels, finalDOHParcels, dissolveFields, "", "MULTI_PART", "")
Total_Parcels_In_MRA = int(arcpy.GetCount_management(finalDOHParcels).getOutput(0))
print("FYI :: Number of parcels in MRA after Dissolve: {0}".format(str(Total_Parcels_In_MRA)))

Attached Thumbnails
Click image for larger version

Name:	error000210.png‎
Views:	N/A
Size:	12.5 KB
ID:	34544  

Viewing all articles
Browse latest Browse all 2485

Trending Articles