|
POST
|
Thanks for the link. I think I have identified the problem. I used type = "Polygon" on arcpy.da.Walk, which should have worked fine, however, one of the polygons in my list had a shapeType of "Null" when I used arcpy.describe. Apparently I should have put another check on the shapeType other than the one on Walk. Wonder why it didn't pick it up though. I will check in once I have re-run the script, thanks for being a sounding board and giving ideas. Edit: Yep that was the issue, I batched it into groups of 256(I thought it might be a limit issue), first two batchs ran, third time gave me a parameter error again, but this time I got an additional error code ExecuteError: Failed to execute. Parameters are not valid. ERROR 000468: Input shape types are not equal Failed to execute (Merge). The earlier part of the post explains. Anyway, 1 hour later 1700+ shapefiles merged! Still curious why the filter on Walk didn't catch it but the describe.shapeType did, I wonder how they function differently? Final code in case anyone is curious.
import arcpy
import os
workspace = r"workspacepath"
feature_classes = []
for dirpath, dirnames, filenames in arcpy.da.Walk(workspace,datatype="FeatureClass", type="Polygon"):
for filename in filenames:
desc = arcpy.Describe(dirpath + "/" + filename)
if desc.shapeType == "Polygon":
feature_classes.append(os.path.join(dirpath, filename))
arcpy.Merge_management(feature_classes, "outputlocationandfile)
... View more
09-04-2014
12:17 PM
|
0
|
2
|
2610
|
|
POST
|
There shouldn't be that many unique fields, and also featureclass to Geodatabase doesn't use any field mapping, since you are just pretty much batch converting the shapefiles into gdb feature classes. I'm wondering if the tools have a limit on how many shapefiles you can use for an input at once.
... View more
09-04-2014
11:10 AM
|
0
|
5
|
2610
|
|
POST
|
I really just need the geometry of each represented, the attribute data that they contain is not important. The script filters to only polygons, so its not an issue of mixed geometry types. I thought it might be the field mapping, so I tried the same thing with FeatureClassToGeodatabase, but I get the same error of parameters not being valid.
... View more
09-04-2014
10:51 AM
|
0
|
7
|
2610
|
|
POST
|
They are in about 700 or so subdirectories that have shapefiles in the workspace directory, so yes very necessary. Sorry should have mentioned that.
... View more
09-04-2014
10:06 AM
|
0
|
9
|
2610
|
|
POST
|
Hey all, I had a goal of making a single shapefile from all the shapefiles I had in a directory, (I have 800 or so), since its hard to share all 800 with someone at once. I wrote up the following script that I hoped would take care of it using the Merge Tool.
import arcpy
import os
workspace = r"myworkspace"
feature_classes = []
for dirpath, dirnames, filenames in arcpy.da.Walk(workspace,datatype="FeatureClass", type="Polygon"):
for filename in filenames:
if filename.endswith(".shp"):
feature_classes.append(os.path.join(dirpath, filename))
print filename
print feature_classes
arcpy.Merge_management(feature_classes, r"C:/Data/test.shp")
However, I keep getting the following error. ExecuteError: Failed to execute. Parameters are not valid. Merge only takes 3 parameters, so I am failing to see the issue.
... View more
09-04-2014
09:33 AM
|
0
|
12
|
7376
|
|
POST
|
If you need to change the projection of a shapefile, you need to use the Project tool(this will make a new shapefile). If you simply assign it a new coordinate system in properties, you are telling the program this is the projection this data is in(which its not), not projecting it from one coordinate system and datum to another, hence why it ends up in the middle of the ocean.
... View more
09-03-2014
08:13 AM
|
0
|
0
|
3732
|
|
POST
|
It notes in the help file that nearest neighbor resampling is used as well.
... View more
09-02-2014
02:01 PM
|
1
|
1
|
1268
|
|
POST
|
Default is to use the largest cell size of all the input datasets, this can be changed in the environmental settings of the tool. ArcGIS Help 10.1
... View more
09-02-2014
01:26 PM
|
0
|
4
|
1268
|
|
POST
|
Replace Workspaces replaces the entire string path and type, findandReplaceWorkspacepath, finds the first string parameter in your workspace path , and replaces it with the second string, you aren't taking an entire path and replacing it with a new one. All you are trying to do is replace your lettered drive "W:" or whatever with a network path r"\\gisserver2" or whatever.
... View more
08-28-2014
02:21 PM
|
0
|
1
|
1725
|
|
POST
|
Ah okay I got it now, since you are replacing only a partial path, you only need to change the part of the path that needs changing, not the whole path. Example:
import arcpy
mxd = arcpy.mapping.MapDocument(r"C:\Project\Project.mxd")
for lyr in arcpy.mapping.ListLayers(mxd):
if lyr.supports("DATASOURCE"):
if lyr.dataSource == r"C:\Project\Data\Parcels.gdb\MapIndex":
lyr.findAndReplaceWorkspacePath(r"Data", r"Data2")
mxd.saveACopy(r"C:\Project\Project2.mxd")
del mxd
In the example, it finds "Data" and replaces with "Data2", not giving a whole new path. So you are having it find the part of the path string that needs changing, in your case, from W:\ to \\gisserver2 Try this out
if 'W:' in wp:
wp = "W:"
nwp = r"\\\gisserver2"
lyr.findAndReplaceWorkspacePath(wp,nwp)
... View more
08-28-2014
02:08 PM
|
0
|
0
|
1725
|
|
POST
|
Sorry I copy pasted from your post, but for a layer its lyr.findAndReplaceWorkspacePath, not Paths like in the mxd version. Did you change that as well?
... View more
08-28-2014
01:44 PM
|
0
|
5
|
1725
|
|
POST
|
try lyr.findAndReplaceWorkspacePath(wp,nwp) instead of mxd, you are changing mxd workspace path, not the layer. Edit: had Paths, not Path
... View more
08-28-2014
01:11 PM
|
0
|
7
|
1725
|
|
POST
|
Note the parameter order changes slightly between da Cursors and standard Cursors
... View more
08-28-2014
12:46 PM
|
0
|
1
|
1220
|
|
POST
|
If you write a script that adds both fc to a map document, you can use the arcpy.mapping module, you can return an layers extent with the layer.getExtent method. You might have to get a bit creative to determine a method for determining if one contains the other, but it should be possible.
... View more
08-28-2014
06:25 AM
|
1
|
0
|
1651
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 02-22-2017 08:58 AM | |
| 1 | 10-05-2015 05:43 AM | |
| 1 | 05-08-2015 07:03 AM | |
| 1 | 10-20-2015 02:20 PM | |
| 1 | 10-05-2015 05:46 AM |
| Online Status |
Offline
|
| Date Last Visited |
11-11-2020
02:23 AM
|