I have a few shapefiles in one folder with different coordinate systems but would like to use one of them as a template dataset. Is there a way to use python to filter out the shapefiles already in the required projection in the same folder?
I have been looking at the ListFeatureClasses and somehow using a wildcard, but not sure if that's the right way to go.
-
This is a near duplicate of gis.stackexchange.com/questions/141351/… - the only difference seems to be the use of a file geodatabase instead of a folder of shapefiles.PolyGeo– PolyGeo ♦2015年04月07日 10:18:22 +00:00Commented Apr 7, 2015 at 10:18
-
Oh sorry, thanks for pointing out PolyGeo, I will try.John H– John H2015年04月07日 10:26:55 +00:00Commented Apr 7, 2015 at 10:26
-
Is there a way to filter out the shapefiles already in the required projection in the same folder?John H– John H2015年04月07日 10:48:42 +00:00Commented Apr 7, 2015 at 10:48
-
You should probably research/ask that as a new question but the way I would try is to use arcpy.Describe().PolyGeo– PolyGeo ♦2015年04月07日 10:58:44 +00:00Commented Apr 7, 2015 at 10:58
1 Answer 1
You can use the Describe function to get information about your spatial references. Then simply use logic to screen out the spatial reference you do not want.
import arcpy
arcpy.env.workspace = r'C:\path\to\your\fgdb.gdb'
fcs = arcpy.ListFeatureClasses()
for fc in fcs:
sr = arcpy.Describe(fc).spatialReference.name
# Note that you can add multiple spatial references in a list ["sr1", "sr2"...]
if sr not in ["NAD_1983_UTM_Zone_15N"]:
# Do something
print sr