Python Forum
split a grid into its tiles with tried codes
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
split a grid into its tiles with tried codes
#1
Hello

I have a grid shapefile that contains 10 polygon squares.

I need to select each tile (which is a row in the attribute table) and make a separate shapefile. It means I need to create 10 separate shpefiles from the grid.

How can I make a loop to go through rows and select each row and make a polygon shapefile out of it?

I tried the following codes unsuccessfully.

Thanks for help.


# Import arcpy module
import arcpy

# Local variables: This is the Grid
Mapsheet_grid_50K = "Mapsheet_grid_50K"

# The following loop is supposed to go through rows
rows = arcpy.SearchCursor(Mapsheet_grid_50K)
row = rows.next()
while row:
  Expression = "\"FID\" = row" #This expression is used is the following select method
  arcpy.Select_analysis(Mapsheet_grid_50K, Mapsheet_grid_50K_Select_shp, row)# This select method will select each tiles
  # This is a separated single tile
  Mapsheet_grid_50K_Select_row_shp = "F:\\Canada_DSM_ForTestOnly\\PersonalData&Maps\\map_Tiles\\Mapsheet_grid_50K_Select."+row+".shp"
del row
del rows
Reply
#2
seems to be fairly explained here: https://gis.stackexchange.com/questions/...ing-python
Reply
#3
Thanks, I will try to learn from it
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020