1

I have high res raster data covering 2million km sq, with a field where each cell has a value from 0 to 100. I need to create a "mask" using the cells with a value over 12 in that field. I then need to clip vector data to that mask.
I was wondering if there is a good method for selecting cells from rasters and using that selection (with reduced noise and smoothed edges) to clip vector data? I don't have spatial analyst extension. I am using ArcGIS for Desktop 10.1.

    -
1
  • I've assumed that you are using ArcGIS for Desktop based on your "I don't have spatial analyst extension" and tagged it as such. I think it is helpful on all ArcGIS platform questions to mention the ArcGIS product (and often the version) that you are using.
    – PolyGeo
    Commented Nov 25, 2014 at 7:46

2 Answers 2

5

You cannot clip a vector file with a raster file. So you need to convert your raster to polygon first. In ArcGIS, you can use "raster to polygon" from the Conversion toolbox (no need for an extension). The problem is that you first need to create the mask, and there is no built in tool in ArcGIS without spatial analyst. So this step has to be done in another software. It is a basic operation, so that you have the choice (GRASS -> r.reclass , gdal_calc -exp A>12, OTB with BandMath application, etc...). If you really want to do it within ArcGIS, you can use arcpy and "RasterToNumPyArray" (also needs numpy), reclass with numpy and go back to raster with "NumPyArrayToRaster".

3

If you do have ArcGIS and no SA: you might consider converting to points, deleting the values below 12, making the rest of the values a single integer, convert to raster, and then converting to polygon.That polygon would be used in the clips and advanced drawing layer masks, I tested this on an SRTM, and it worked well:

import arcpy
from arcpy import env

Folder = "C:\\Data\\Temp\\STACK"
GDB = "C:\\Data\\Temp\\STACK\\TempGDB.gdb"
env.workspace = GDB
TempP = GDB+"\\TempP"
Poly = GDB+"\\Poly"
InRaster = "C:\\Data\\Temp\\STACK\\Raster"
OutRaster = Folder+"\\OutRaster"
TempPLayer = "TempPLayer"

elevMinResult = arcpy.GetRasterProperties_management(InRaster, "MINIMUM")
elevMaxResult = arcpy.GetRasterProperties_management(InRaster, "MAXIMUM")
CELLSIZEX = arcpy.GetRasterProperties_management(InRaster,"CELLSIZEX")

print "Min: " +str(elevMinResult) +" Max: " + str(elevMaxResult)
print "Cell Size: "+ str(CELLSIZEX)

if arcpy.Exists(TempP):
    arcpy.Delete_management(TempP)
if arcpy.Exists(OutRaster):
    arcpy.Delete_management(OutRaster)
if arcpy.Exists(Poly):
    arcpy.Delete_management(Poly)  

arcpy.RasterToPoint_conversion(InRaster, TempP, "Value")
arcpy.MakeFeatureLayer_management(TempP,TempPLayer) 
arcpy.SelectLayerByAttribute_management(TempPLayer, "NEW_SELECTION", " \"grid_code\" < 12 ")
arcpy.DeleteFeatures_management(TempPLayer)
del TempPLayer

arcpy.AddField_management (TempP, "IntValue", "LONG", "", "", "", "IntValue", "NULLABLE")
arcpy.CalculateField_management(TempP, "IntValue","1", "PYTHON")
arcpy.PointToRaster_conversion(TempP, "IntValue", OutRaster, "MAXIMUM", "", CELLSIZEX)
arcpy.RasterToPolygon_conversion(OutRaster, Poly, "NO_SIMPLIFY", "VALUE")

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.