Select to view content in your preferred language

How to clip map sheets to a Map Gird

2270
11
02-03-2017 11:17 AM
JosephPlessis
Emerging Contributor

I have multiple geo referenced scanned maps from the 1950's, Like 60 of them.

I need to clip some white space off the edges so I can apply a fishnet.

So the main question is I have a 50k nts grid where the maps sit perfectly within each grid tile, When i try to clip the map to the grid it does nothing because it is reading the outside border of the nts grid. how would i get the clip to read each individual grid tile for a clip?

thanks

0 Kudos
11 Replies
NeilAyres
MVP Alum

Joe,

can you try and format your code to make it readable...

script-formatting

The point about making a mosaic is that you don't have to do all this clipping.

No extra time and no extra disk space.

JosephPlessis
Emerging Contributor

THIS WORKS!

import arcpy
from arcpy import env
from arcpy.sa import *
arcpy.CheckOutExtension("3D")
arcpy.env.overwriteOutput = True

# Set the current workspace
arcpy.env.workspace = "Q:\\josephplessis\\GIS 307 Resource Managment\\Project\\Mapsheets\\soil"
Dir = "Q:\\josephplessis\\GIS 307 Resource Managment\\Project\\Mapsheets\\ClippedMaps"


GRID="Q:\\josephplessis\\GIS 307 Resource Managment\\Project\\Geodatabases\\Grid_points.gdb\\GRID"

GRIDlyr=arcpy.MakeFeatureLayer_management(GRID, "GRIDlyr")


# Get and print a list of TIFs from the workspace

rasters = arcpy.ListRasters("*")
for raster in rasters:
    print raster
    name = Dir + "\\" +"clp_"+ str(raster)
    print name
    arcpy.RasterDomain_3d(raster, "in_memory/temp", "POLYGON")

    # Process: Central Feature
    arcpy.MeanCenter_stats("in_memory/temp", "in_memory/temp1")

    # Process: Select Layer By Location
    arcpy.SelectLayerByLocation_management(GRIDlyr, "intersect", "in_memory/temp1", "", "NEW_SELECTION")

    # Clip Raster
    arcpy.Clip_management(raster,"#", name,GRIDlyr, "#", "ClippingGeometry")

    # Delete in_memory
    arcpy.Delete_management("in_memory")

    print "processing " + raster + " complete..."


    print "All processing is now finished"