My goal is to print names of feature classes and corresponding minimum latitude of centroids of geometry for all shapefiles in a folder. In total I have 5 shapefiles and I'm trying to loop through them.

import arcpy
arcpy.env.overwriteOutput = True

arcpy.env.workspace = r"C:\Users\username\dataset_folder"

for z in arcpy.ListFeatureClasses():

I am able to print the names of these shapefiles but don't know how to get minimum latitude of centroids of geometry.

What ArcPy tool should I use to get these minimum latitude of centroids of geometries?

  • 1
    Or just SHAPE@Y to make it simpler (a double, instead of a tuple). Nov 3, 2021 at 3:15

1 Answer 1


This might work (untested):

arcpy.env.workspace = r"C:\Users\username\dataset_folder"

for fc in arcpy.ListFeatureClasses():
    minLatitude = min(arcpy.da.SearchCursor(fc, "SHAPE@Y"))
    print("{}: {}".format(fc, minLatitude))

(Updated to include PaulH's suggested modification/simplification.)

  • That worked! I was trying to wrap my for loop under SearchCursor instead of the other way around! Thanks a lot for your time!
    – puredata
    Nov 3, 2021 at 3:23
  • 3
    would min(arcpy.da.SearchCursor(fc, "SHAPE@Y")) work? (I don't have access to arcpy at the moment?
    – Paul H
    Nov 3, 2021 at 3:37
  • min(arcpy.da.SearchCursor(fc, "SHAPE@Y")) worked too! A follow up question, I keep seeing similar syntax to "y for y in" what would be a good search term to understand this kind of for loops? I haven't really encountered them before until a week ago.
    – puredata
    Nov 3, 2021 at 4:28
  • 1
    It's Python's "list comprehension" syntax. See: w3schools.com/python/python_lists_comprehension.asp . It's a great shorthand for some for loops, and optionally for loops with if conditions and other variations. Nov 3, 2021 at 4:30
  • @PaulH - thanks... I've updated the answer to use your suggested improvement. Makes sense! Nov 3, 2021 at 4:33

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.