1

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.

asked Apr 7, 2015 at 10:13
4
  • 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. Commented Apr 7, 2015 at 10:18
  • Oh sorry, thanks for pointing out PolyGeo, I will try. Commented Apr 7, 2015 at 10:26
  • Is there a way to filter out the shapefiles already in the required projection in the same folder? Commented 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(). Commented Apr 7, 2015 at 10:58

1 Answer 1

3

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
answered Apr 7, 2015 at 11:45

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.