38

I have a rectangular raster image in ArcMap.

How can I produce a polygon which is just the extent of the raster image?

That is, I want to have a polygon layer with a single quadrilateral which is the edge of the image.

I've tried simply doing a Raster->Polygon conversion, but this tries to use the data in the image to generate the outline - all I want is the outline of the edge of the image.

I'm using ArcGIS Desktop 10.

PolyGeo
  • 65,136
  • 29
  • 109
  • 338
robintw
  • 4,006
  • 11
  • 40
  • 60

14 Answers14

44

If you have the "Spatial Analyst" then you can:

  1. Multiply the raster by 0 to create a constant value raster using Raster Calculator. (be sure to convert it to integer type or step 2 will not work)
  2. Convert the result of step 1 to polygon using the Raster to Polygon tool.

Another solution:

If your have 3D Analyst license then you can use the Raster Domain tool under 3D Analyst>Conversion>from raster (however it does not have the smooth function)

Taras
  • 32,823
  • 4
  • 66
  • 137
Alex Markov
  • 4,017
  • 22
  • 34
17

You can use the Raster Domain tool from 3D Analyst to create a polygon with the same extent as your raster data

Andreas
  • 171
  • 1
  • 2
  • Welcome to GIS SE! Could you please add references to your answer? That way it would be more solid. – R.K. Nov 22 '12 at 14:22
  • Raster Domain tool did the job, perfectly! Creates an outline or boundary of the raster data. –  Mar 10 '14 at 17:28
  • 3
    A word of warning about this tool - the bounding polygon that's created is the extent of your raster data starting & ending at the pixel CENTER, not the outside edge of the pixels. I just tried it and thought it returned the outside bounding box of the raster, but when you zoom in you'll see that the bounding box starts at the pixel center. – fbiles Aug 04 '16 at 03:29
  • There is actually a parameter for the IRasterDomainExtractor.ExtractDomain method that controls whether it uses the center or the outer edge of the pixels/cells. – Preston May 19 '17 at 22:36
  • This is perfect! One tool and I have a polygon outline of my raster. Thanks! – MyNameisTK Aug 03 '17 at 20:10
12

I use this simple python script, it create a polygon featureclass with the extent of all the raster present in a folder. To use it, you can create a tool in ArcToolbox or you simply change the InFolder and Dest (Destination) variables.

import arcpy,os

InFolder = arcpy.GetParameterAsText(0)
Dest=arcpy.GetParameterAsText(1)

arcpy.env.workspace=InFolder
#The raster datasets in the input workspace
in_raster_datasets = arcpy.ListRasters()

arcpy.CreateFeatureclass_management(os.path.dirname(Dest),
                                   os.path.basename(Dest),
                                   "POLYGON")
arcpy.AddField_management(Dest,"RasterName", "String","","",250)
arcpy.AddField_management(Dest,"RasterPath", "String","","",250)

cursor = arcpy.InsertCursor(Dest)
point = arcpy.Point()
array = arcpy.Array()
corners = ["lowerLeft", "lowerRight", "upperRight", "upperLeft"]
for Ras in in_raster_datasets:
    feat = cursor.newRow()  
    r = arcpy.Raster(Ras)
    for corner in corners:    
        point.X = getattr(r.extent, "%s" % corner).X
        point.Y = getattr(r.extent, "%s" % corner).Y
        array.add(point)
    array.add(array.getObject(0))
    polygon = arcpy.Polygon(array)
    feat.shape = polygon
    feat.setValue("RasterName", Ras)
    feat.setValue("RasterPath", InFolder + "\\" + Ras)
    cursor.insertRow(feat)
    array.removeAll()
del feat
del cursor  
jeb
  • 1,668
  • 1
  • 14
  • 18
  • can tell us in details how to use this code. I wanna use it on .asc raster file. My images are different different sub folder.? – GIS Data Butcher Mar 23 '15 at 12:14
  • 1
    Answer from jeb has worked for me, don't have sufficient rep to up vote him. @GIS Data Butcher Save the complete source into a script.py file and execute it from Python Window within ArcMap. You can use following command on Python Window to execute script from file.

    execfile(r'd:\temp\script.py')

    – Asad Mar 13 '16 at 10:13
  • perfect!! i wonder, is there a way to the tool read subfolders as well? – raphael Feb 18 '19 at 18:14
  • @raphael, for sure, you just have to implement the standard python os.listdir or os.walk in script. – jeb Feb 27 '19 at 15:08
  • @jeb yes, i get the concept... bot i'm very new at this, and could not make it work... can you give some help? – raphael Feb 27 '19 at 19:05
  • Thanks.. much better strategy for a large folder of tiles than reclass>convert to polygon.. that would be a bit over the top. – Mike Apr 05 '22 at 21:04
  • While running this code in ArcMap Python Window, giving error. See below

    Runtime error Traceback (most recent call last): File "", line 12, in File "c:\program files (x86)\arcgis\desktop10.8\arcpy\arcpy\management.py", line 2025, in CreateFeatureclass raise e ExecuteError: ERROR 000735: Feature Class Location: Value is required ERROR 000735: Feature Class Name: Value is required

    Could you pls suggest so that this can resolve

    – Kaichand03 Jul 21 '22 at 10:57
  • @Kaichand03, you would have to give more details, but I can guess... if run in Python window, this line "Dest=arcpy.GetParameterAsText(1)" should be replaced by something like: Dest='c:/temp/my_raster_index.shp. Same will go for "InFolder = arcpy.GetParameterAsText(0)". Those are parameters if run in a script, if run in python window, has to be set. – jeb Jul 22 '22 at 03:12
  • Thx Mate, Raster extent boundary is now creating well but this script created Raster extent in Rectangle, I need exact/Actual Raster boundary, that should include No data area. Is there any suggestion on this? – Kaichand03 Jul 22 '22 at 03:55
  • @Kaichand03, the option that I know in ArcGIS (easier to do in python rasterio) is to use the "con" tool to get a raster with only 2 value (data, no data), them "raster to polygon" tool. – jeb Jul 23 '22 at 02:40
11

You can use the Build Footprint tool in the Data management Toolbox. You have to create a Mosaic Dataset out of your raster.

Create a new Mosaic in a File Geodatabase , add your raster.

Open your Mosaic in ArcMap and Extract the Footprint.

That's what I would do.

Dom
  • 894
  • 1
  • 10
  • 24
11

What about simply digitizing it? Click-click-click-click done.

Matt
  • 899
  • 4
  • 11
  • 19
  • 8
    Not really sure why this option has been down voted. You can find the coordinates of the extent corners and create vertices at those coordinates. It can even be used for analysis. If it's only for display, click-click-click-click works great. – Baltok Mar 20 '12 at 19:26
  • 6
    I'd say because the raster could be an irregular shape and, depending on the complexity, could result in a pretty tiresome digitising job – Phil Henley Mar 20 '12 at 21:57
  • 4
    But the OP said it was rectangular. Seems like a pretty simple job to me. By zooming in and being accurate, the difference between the actual raster outline and the digitized outline would be negligible for any real world application. – Matt Mar 21 '12 at 13:09
6

Also, an easy way is to use Reclassify tool where you should click the button Classify and change the number of classes to 1. Click Ok. Now, the output raster can be easily converted using Raster to Polygon conversion Tool. ;)

4

I think that reclassifying and converting the raster to polygon can be way too time consuming. In my opinion, the easiest way to do it is:

  • Get maxX, maxY, minX, minY (this can be done in Python with the describe command)
  • Run Create Fishnet with the extent as above and number of rows/columns as 1

If you have lots of rasters, this should be done in Python and can create hundreds of footprints in a matter of seconds.

PolyGeo
  • 65,136
  • 29
  • 109
  • 338
0

If you are trying to get the outline of a DEM raster then you will need to do the following

If you have Spatial Analyst and 3d Analyst then you can:

  1. multiply the raster by 0 to create a constant value raster using Raster Calculator.
  2. Convert results of step 1 to a raster integer by using the "INT (Tool)". This is necessary for the next step.
  3. convert result of step 2 to polygon using the Raster to Polygon tool (only works with raster integers).
PolyGeo
  • 65,136
  • 29
  • 109
  • 338
seamster02
  • 21
  • 1
  • Hi Seamster02, welcome to GIS Stack Exchange :) As written this is not appreciably different from the accepted answer, http://gis.stackexchange.com/a/22016/108. – matt wilkie Jun 12 '15 at 16:04
0

In ArcCatalog you can create a raster catalog in a .gdb (Data Management Tools->Raster). Unmanaged is fine. Then right click and load (if the rasters are just sitting in a folder then "load from workspace". If you load the raster catalog into ArcMap you can right click-> data-> export footprint, as a shape file or feature class. The shape file will have a 'name' field populated with the name of the raster.

The Raster Catalog will automatically display the extents but I needed to send the extents to someone who wasn't using ArcGIS.

0

Use the "Raster to Polygon" tool in the conversion tools toolbox. Make sure to uncheck the simplify polygons box. This will create exactly what you want.

PolyGeo
  • 65,136
  • 29
  • 109
  • 338
Boyle300
  • 264
  • 2
  • 6
  • 8
    Are you sure this doesn't just create a huge mess of polygons, one for each contiguous set of equal-value pixels in the original image? – whuber Mar 21 '12 at 16:33
  • You could always add a dissolve after this to get the extent poly. However, I bet the python solution listed by @jeb is faster. – GeoJohn Jun 04 '15 at 15:45
0

"Raster Domain" tool will create a polygon around an irregularly shaped raster. I believe it requires a license for the 3d analyst extension.

RWRogers
  • 11
  • 1
0

Using ArcCatalog is the best option. Create a Mosaic Dataset from available rasters. Define "NO VALUE" in the mosaic to avoid the background of raster from being included in the polygon. Build footprints using Radiometric method. Open the Mosaic dataset in ArcGIS and export Footprints to shp file. Great way to get the mosaic boundaries...

0

I read this post for advice on a similar need. I wanted to outline a raster that is very irregularly shaped, with a stair-step pattern around all the curves, which would have taken hours to digitize. All the other recommendations, mosaic, reclassify, raster calculator, raster domain, etc., all require higher level licenses that I don't have. I solved this problem by using the free program QGIS for parts of it. I loaded my raster into Q. I ran it through the tool Raster>Conversion>polygonize, which converted it into a polygon layer with many thousands of tiny polygons. I exported that layer as an ESRI shapefile, and brought that into Arcmap. Once in arcmap, I began an editing session, opened the attribute table, and selected all of the many thousands of polygons. The selection could have been more easily accomplished with the selector tool, but either way... From the Editor toolbar's main dropdown menu, I selected Union (different from the Union tool from the toolbox). It created the outline I wanted, already highlighted. From the attribute table, I clicked on switch selection, and then right clicked the selected polygons and deleted the selection, so all I had left in the layer was the outline. Then saved edits and stopped editing.

0

You can do it easily with "arcpy" module in Python: The important thing is that you have to read the spatial georeference system of the input raster, and create a polygon feature with the same spatial georeference system. You read the corners of the raster and add points to a polygon shape. Then you add the shape to your feature class. This is the code for doing it.

import arcpy
import sys
import os

fp_inp = "C:\raster\raster.tif" fp_out_dir, fp_out_name = "C:\raster", "polygon.shp" fp_out = os.path.join(fp_out_dir, fp_out_name) if arcpy.Exists(fp_inp): desc = arcpy.Describe(fp_inp) spatialName, spatRef = "Unkown", None if hasattr(desc, 'spatialReference'): spatRef = desc.spatialReference spatialName = desc.spatialReference.name if spatialName != "" and spatialName != "Unkown": arcpy.env.workspace = fp_out_dir try: arcpy.CreateFeatureclass_management(fp_out_dir, fp_out_name, 'POLYGON', spatial_reference=spatRef) polygonSuc = True except: print("ERROR (126401236004)") print(arcpy.GetMessages()) fieldsOk = False if polygonSuc: try: arcpy.AddField_management(fp_out, "src", "TEXT", "", "", 254, "src", "NULLABLE") fieldsOk = True except: msg01 = "\n" + arcpy.GetMessages() print(msg01) corners = ["lowerLeft", "lowerRight", "upperRight", "upperLeft"] ras = arcpy.Raster(fp_inp) points_array = arcpy.Array() for corner in corners: pt = arcpy.Point(getattr(ras.extent, "%s" % corner).X, getattr(ras.extent, "%s" % corner).Y) points_array.add(pt) polygon_shape = arcpy.Polygon(points_array) if fieldsOk: with arcpy.da.InsertCursor(fp_out, ["SHAPE@", "src"]) as cursor: cursor.insertRow([polygon_shape, "your raster name goes here"]) print("Inserted polygon into shapefile: " + fp_out) points_array.removeAll() array = None else: print("Input raster does not exist.")