How to Extract Value from Raster into Polygon?

9872
14
11-03-2016 02:09 PM
GwanSeonKim
New Contributor II

Hi, GIS users.

I am struggling with extracting value from raster into each polygon.

I have two layers, which are major crop raster and field boundary shapefile.

I attached a picture to explain what I want to do in detail.

Black line shows single polygon for each field boundaries, and yellow and red colors represent corn and soybeans respectively.

Each color includes single pixels (30 by 30 meters).  

I want to know how many pixels are located in each field.

I may need to clean (delete) some pixels in raster file since there are many single pixels located in field boundary. 

However, I really want to know how may pixels are combined in each field boundary. 

Please help me what tools should I used to do that. 

Thank you.

0 Kudos
14 Replies
MaribethPrice
Occasional Contributor

You might also try the Zonal Statistics as Table tool, with your polygons as the zone data set and the crop raster as the values data set.  It will provide a table with a Count field for all the pixels in each polygon.

You would need to reclasify (Reclassify tool)  the raster so that you would have only corn or only soybeans in each raster. Give each a value of 1 and a nodata everywhere else.

The output is a table that you would join back to the polygons.  You will need a unique identifer for each field; the ObjectID should work if you don't have anything else.

You will need a Spatial Analyst extension license to run these tools.

Maribeth

0 Kudos
GwanSeonKim
New Contributor II

Thank you for your response.

I have one more question to you.

I have a raster file, which is soil map.

In the raster, there are so many columns, but I just want to use one column named "slope" and use zonal statistics tool.

However, I do not know how to select only one column in the raster.

I tried to run the zonal statistics, but I could not figure out what those values are.

Please let me know if you have any ideas,

Sun

0 Kudos
MaribethPrice
Occasional Contributor

Sun,

Rasters only store ONE field attribute directly and it is contained in the “Value” field. Any other fields may have been added by users or copied during a polygon-to-raster conversion process. Most raster tools use the Value field by default, and not many of them allow you to select an alternate.

If you have a soil raster, then I surmise that the Value field contains a unique number code for each soil unit, and the slope field you indicate was merely copied from a polygon soils data set when it was converted to the raster. Presumably this field already contains the average slope of the field, so if you trust this value, then you don’t need to run zonal stats at all.

To use zonal stats, you need a slope raster containing slope values in the Value field (not a soils raster containing a soil code). If you have a digital elevation model already, you can calculate slope from the DEM quite easily with the Slope tool and use that in zonal stats.

You might want to review the Help files on how rasters are stored and analyzed; it sounds like you have might some misunderstandings about how they function.

Maribeth

0 Kudos
GwanSeonKim
New Contributor II

Maribeth, 

I guess I did not have enough knowledge about the raster.

Now I understand what is your point, and I figured it out.

The value in raster is uniquely assigned to each observation. 

Once I use zonal statistical tool, then I can join with other fields based on the value.

Thank you so much. 

0 Kudos
GwanSeonKim
New Contributor II

Maribeth,

This is Sun again.

I am sorry to ask you many questions.

Today, I tried to run zonal statistics as table tool again, but the tool does not work.

I did exactly same steps with same files, but I could not get the output.

For example, it took 10 mins to get output yesterday, but the tool is running more than an hour without output.

Do you have any ideas why I have this issue?

Thank you.

Sun

0 Kudos