+ Reply to Thread
Results 1 to 21 of 21

Thread: Merge Raster data (table) with shapefile of counties

  1. #1
    Robert Ford
    Join Date
    Feb 2013
    Posts
    26
    Points
    0
    Answers Provided
    1


    0

    Question Merge Raster data (table) with shapefile of counties

    Hi all. Thanks for any response in advance.

    My question is this: I have a raster image that details land use data for a state (Ohio). I also have a shapefile of all Ohio counties. I want to be able to export a table that has the raster values for each county listed. Basically, I need to query every county in the state. I've attached a ZIP file with 2 pictures and a layer file that contains the raster data and shapefile I am working with.

    I would consider myself an advanced-beginner with ArcGIS, so forgive any naivety on my part.

    Thanks for any and all help!
    Attached Files

  2. #2
    Robert Ford
    Join Date
    Feb 2013
    Posts
    26
    Points
    0
    Answers Provided
    1


    0

    Default Re: Merge Raster data (table) with shapefile of counties

    Basically, as an example, I want to know how much land is covered by forest, corn, and soybeans in every County, Ohio based on the raster image. Thanks again for anyone who bothers to respond!

  3. #3
    Eric Rice

    Join Date
    Oct 2009
    Posts
    954
    Points
    474
    Answers Provided
    76


    0

    Default Re: Merge Raster data (table) with shapefile of counties

    Hi Robert,

    You should check out the Zonal Histogram tool. Your zones are the counties and the value raster would be your landuse raster. This tool will give you the breakdown of each landuse within each zone.

    Best,
    Eric
    Eric Rice
    Product Engineer
    Esri Software Products

  4. #4
    Robert Ford
    Join Date
    Feb 2013
    Posts
    26
    Points
    0
    Answers Provided
    1


    0

    Default Re: Merge Raster data (table) with shapefile of counties

    Thanks, but I have tried this method and it does not produce what I need. The resulting table does not tell me what the resulting values even stand for. I have attached what the outcome of this method is.

    However, the table does have the format that I need. (IE values for every county in the state)

    Thanks for the reply!
    Attached Files

  5. #5
    Eric Rice

    Join Date
    Oct 2009
    Posts
    954
    Points
    474
    Answers Provided
    76


    0

    Default Re: Merge Raster data (table) with shapefile of counties

    Hi Robert,

    I personally dislike the formatting of the output table, but it's not hard to get the landuse descriptions back. All you would have to do is join the output table back to the raster attribute table. The output table has a field called LABEL which you can use to join back to the VALUE field in the raster. Once this join is in place you'll have landuse descriptions back. Since each zone becomes a field, you can't really expect to join this back to the original polygon zones.

    I have an alternative workflow where you convert the landuse raster to polygons and run the Tabulate Intersection tool (new at 10.1) then I usually follow that up with the Pivot Table tool before joining the table back to my polygons.

    Best,
    Eric
    Eric Rice
    Product Engineer
    Esri Software Products

  6. #6
    Robert Ford
    Join Date
    Feb 2013
    Posts
    26
    Points
    0
    Answers Provided
    1


    0

    Default Re: Merge Raster data (table) with shapefile of counties

    Hi Eric,

    Thanks for the reply again. I currently only have access to ArcGIS 10 not 10.1.

    I tried the join and got the resulting table attached. Also, there is no "LABEL" field in any of the tables I am working with so I'm not sure what you mean here. The table that was created is not correct as it shows cotton grown in the county, which cotton is not grown anywhere in Ohio.

    I appreciate the help!

    Best,
    Rob
    Attached Files

  7. #7
    Eric Rice

    Join Date
    Oct 2009
    Posts
    954
    Points
    474
    Answers Provided
    76


    0

    Default Re: Merge Raster data (table) with shapefile of counties

    Robert,

    We will get this sorted out together...

    Originally, I assumed you were symbolizing the landuse raster using Unique Value rendering and thus the zonal histogram table's label field would have the unique values for the raster in that column and require joining the zonal output table back to the input value raster table where Label = Value to establish/retain the landuse descriptions. I found that if you symbolize by Unique Values, but use the description field for the value field (on symbology tab) rather than the Value field, when you run Zonal Histogram the label field will automatically contain the descriptions your looking for so no further join is required. Please see screenshot-1 of result I obtained with this method.

    Based on the table you sent and lack of label field, I do not believe you are using the Unique Value renderer. My example case is simple with only 7 landuse categories so ArcMap automatically uses Unique Value, but if your data has more than 26 unique values (and it does) then ArcMap will display it with a stretched renderer. If you leave it as stretched, AND your inputting a raster layer (rather than a raster dataset) then the layer's symbology defines the number of classes. When it's stretched you get 256 classes so most of your landuse will be zero's for each county. Hopefully this second screenshot helps clarify what is happening. The table on the left is Zonal Histogram with the Unique Value renderer and the table on the right is with Stretched. What you see is that the value 7 was stretched to 256 - county 1 still has 447 pixels of wetlands and county 2 has zero, but clearly using stretched is not the way to run this tool since the values for each landuse are stretched to the full 8 bit range and aren't really meaningful in terms of properly being able to join it back to get descriptions. This is how you got cotton growing in Ohio! The stretched value was joined, not the real value.

    To summarize:
    1. Use the Unique Value renderer on the landuse raster.
    2. On the symbology tab, set the value field to the landuse description field like in screenshot-3. My description field just happens to be called Landuse.
    3. Run Zonal Histogram.

    This should produce what you're looking for without further joins.

    Best,
    Eric
    Attached Thumbnails Attached Thumbnails Click image for larger version

Name:	example_output_ZHtool.jpg‎
Views:	60
Size:	195.8 KB
ID:	22056   Click image for larger version

Name:	table_compare_UV_to_Stretch.jpg‎
Views:	46
Size:	97.0 KB
ID:	22057   Click image for larger version

Name:	symbology_setup.jpg‎
Views:	50
Size:	97.8 KB
ID:	22058  
    Last edited by erictrice; 02-21-2013 at 01:26 PM.
    Eric Rice
    Product Engineer
    Esri Software Products

  8. #8
    Robert Ford
    Join Date
    Feb 2013
    Posts
    26
    Points
    0
    Answers Provided
    1


    0

    Default Re: Merge Raster data (table) with shapefile of counties

    Eric,

    From your images, I see that my original data that I provided was not accessible. If you private message me your email, I can share a layer package with you via Google Drive (it's too large to upload here 15 MB +).

    Also, my data is already displayed the way you say and show, but I still cannot figure out how to get the landuse descriptions back. I still just get the table like before.

    Thanks again!

  9. #9
    Robert Ford
    Join Date
    Feb 2013
    Posts
    26
    Points
    0
    Answers Provided
    1


    0

    Default Re: Merge Raster data (table) with shapefile of counties

    Also, attached is a screen capture of what I am doing with the Zonal Histogram tool, the raster table and symbology, and the resulting table again.
    Attached Files

  10. #10
    Robert Ford
    Join Date
    Feb 2013
    Posts
    26
    Points
    0
    Answers Provided
    1


    0

    Default Re: Merge Raster data (table) with shapefile of counties

    Eric,

    So after playing around, I noticed if I change the symbology value field from "Class_Name" to "Value", Zonal histogram will output the labels column into the table (attached), but they still do not mean anything. If I try it with the "Class_Name" instead, I get the following message:

    "Background processing has encountered a serious error and is unable to continue."

    Thanks again for all of your help and patience!
    Attached Files

  11. #11
    Robert Ford
    Join Date
    Feb 2013
    Posts
    26
    Points
    0
    Answers Provided
    1


    0

    Post Re: Merge Raster data (table) with shapefile of counties

    Okay so here is a link to the layer package with my data. Hopefully this works for anyone that downloads it!

    If it doesn't, it would be great to know so I can figure out how to make it!

    https://docs.google.com/file/d/0B_RL...it?usp=sharing

  12. #12
    Eric Rice

    Join Date
    Oct 2009
    Posts
    954
    Points
    474
    Answers Provided
    76


    0

    Default Re: Merge Raster data (table) with shapefile of counties

    Hi Rob,

    Thanks for the data. I did a quick test using the workflow I described earlier and got exactly what I said we'd get. What sp are you using with v10.0? I am using 10.1 sp1 (the latest release).

    -Eric
    Attached Thumbnails Attached Thumbnails Click image for larger version

Name:	myoutput.jpg‎
Views:	24
Size:	343.7 KB
ID:	22238  
    Eric Rice
    Product Engineer
    Esri Software Products

  13. #13
    Eric Rice

    Join Date
    Oct 2009
    Posts
    954
    Points
    474
    Answers Provided
    76


    0

    Default Re: Merge Raster data (table) with shapefile of counties

    One more thing since you're on an old release. The name of your raster indicates it was the result of a clip operation. I believe in your version, the table is not automatically updated and even records that were clipped off are still in your table with counts set to 0. For example, in the data you sent, the raster has Barley with a significant number of pixels in the count column, but when I do zonal on it I get 0 for every county. You should probably run the Build Raster Attribute Table tool to get an up to date raster attribute table before running Zonal Histogram. It will make your output table look cleaner and won't be filled with 0's like in my last screenshot. Back up/ copy your raster before rebuilding the table.

    Best,
    Eric
    Eric Rice
    Product Engineer
    Esri Software Products

  14. #14
    Robert Ford
    Join Date
    Feb 2013
    Posts
    26
    Points
    0
    Answers Provided
    1


    0

    Default Re: Merge Raster data (table) with shapefile of counties

    Eric,

    Thanks again. I am using sp5 (the latest from what I can tell). I will try it out again later this afternoon and get back to you. Also, I am assuming the numbers in the table represent pixels correct?

    I am comparing this acreage with another websites (http://nassgeodata.gmu.edu/CropScape/) that also lists pixel counts per county (screen shot of Lucas County, Ohio attached). The tables don't seem to match up if it is pixel counts.

    Again I will mess with it some more this afternoon and get back to you.

    Sorry I keep complicating the issue!

    I can't thank you enough!
    Attached Thumbnails Attached Thumbnails Click image for larger version

Name:	cropscape pic.jpg‎
Views:	18
Size:	247.9 KB
ID:	22254  

  15. #15
    Robert Ford
    Join Date
    Feb 2013
    Posts
    26
    Points
    0
    Answers Provided
    1


    0
    This post is marked as the answer

    Smile Re: Merge Raster data (table) with shapefile of counties

    eric,

    Tried your workflow again but this time I added the Raster file to a personal geodatabase and did the Build Raster Attribute Table tool.

    Worked like a charm now. Not sure why it didn't like not being in a geodatabase.

    Finally got a table with a label column! But the values do no match the ones in your screenshot for some reason. Table is attached.

    Again, do these numbers represent pixels, acreage, or some other attribute?

    At least I finally figured out the original problem so thanks again!
    Attached Files

  16. #16
    Eric Rice

    Join Date
    Oct 2009
    Posts
    954
    Points
    474
    Answers Provided
    76


    0

    Default Re: Merge Raster data (table) with shapefile of counties

    I hadn't rebuilt the table before running zonal for that screenshot. The numbers are definitely counts, not acreage or some other unit.

    Eric
    Eric Rice
    Product Engineer
    Esri Software Products

  17. #17
    Robert Ford
    Join Date
    Feb 2013
    Posts
    26
    Points
    0
    Answers Provided
    1


    0

    Cool Re: Merge Raster data (table) with shapefile of counties

    So I made a step by step guide for this problem. It is attached here. Hope it helps other people trying to figure this out!

  18. #18
    Erik Olson
    Join Date
    May 2010
    Posts
    3
    Points
    0
    Answers Provided
    0


    0

    Default Re: Merge Raster data (table) with shapefile of counties

    Rob or Eric,

    I'm wondering why Tabulate Area wouldn't have worked for what you were trying to do. Wouldn't it produce the same table?

  19. #19
    Robert Ford
    Join Date
    Feb 2013
    Posts
    26
    Points
    0
    Answers Provided
    1


    0

    Angry Re: Merge Raster data (table) with shapefile of counties

    Tabulate area does not produce the table format I want.

    Now I have another issue. Zonal Histogram seems to ONLY work for certain files. I am attempting to do this for a few states and only certain states are working.

    Let me note that all of the states are in a geodatabase with the same formatting. All of the rasters are in a separate geodatabase with the same formatting.

    My question is why on Earth will Zonal Histogram only work for certain states (polygons)? Formats are the same. File Locations are the same.

    What is wrong with this program?

  20. #20
    Jeff Swain

    Join Date
    Nov 2009
    Posts
    749
    Points
    184
    Answers Provided
    21


    0

    Default Re: Merge Raster data (table) with shapefile of counties

    The morphology of the counties is probably causing the issue. Depending on your data, that is what I would look into. Also per the help documentation,

    If the zone input is a feature dataset, a vector-to-raster conversion will be internally applied to it. To ensure that the results of the conversion will align properly with the value raster, it is recommended that you check that the extent and snap raster are set appropriately in the environment settings and the raster settings.

    Since the internal raster must have an attribute table, an error will occur if one was not created in the conversion. If this happens, convert your feature dataset directly with Feature To Raster, Polygon To Raster, Point To Raster, or Polyline To Raster. Generate an attribute table for it as described in the previous tip and use the resulting raster as your Zone input.
    Also depends on how much NoData is covered by your zones.
    Last edited by jbswain; 03-29-2013 at 08:10 AM.
    Esri Education Specialist
    Esri Certified ArcGIS Desktop Professional
    Training Services
    Esri Training | ArcGIS Ideas

  21. #21
    Eric Rice

    Join Date
    Oct 2009
    Posts
    954
    Points
    474
    Answers Provided
    76


    0

    Default Re: Merge Raster data (table) with shapefile of counties

    The zones are counties Jeff, and there isn't a state in the union with more counties than the maximum unique values to render so it should be building a table during the conversion. At this point, I would suggest Rob contact Esri Support and have an analyst go through it with him. Rob posted this same question to the GP forum but included more details in that thread, specifically about the background gp process failing with error messages. The first test is obviously running it in the foreground to narrow the issue down. After that, I would do what you suggested and convert the zones into raster datasets and run it again, to narrow down the issue some more. Support will know what to do in terms of other troubleshooting.

    Best,
    Eric
    Last edited by erictrice; 03-29-2013 at 07:53 AM.
    Eric Rice
    Product Engineer
    Esri Software Products

+ Reply to Thread

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts