Polygon to Raster - can I base it on 2 fields

683
4
Jump to solution
08-13-2013 12:34 PM
MaritzaMallek
New Contributor II
I am doing a lot of geoprocessing for a project where all my input layers need to be perfectly overlapping rasters. Some of my input data starts out as polygons, and I have been converting them to rasters. One of my "base" polygons has 2 fields I need, so I have been running the conversion twice, once on each field. I have been using maximum combined area but just discovered that this creates errors in the output. What I noticed was that, for example, I have field a and field b, and both contain value x. If a row in field a has value x, then the same row in field b also has value x. But when I run the conversion this is not true a very small percentage of the time. I realize that this is probably cause by doing the maximum combined area. But what would really be nice is if I could just convert the raster using both fields? Is there a way to do this if I went into python? Or is my only option to create a new attribute field that combines the previous 2, and convert based on that?
Thanks!
Maritza
0 Kudos
1 Solution

Accepted Solutions
MaritzaMallek
New Contributor II
I am doing a lot of geoprocessing for a project where all my input layers need to be perfectly overlapping rasters. Some of my input data starts out as polygons, and I have been converting them to rasters. One of my "base" polygons has 2 fields I need, so I have been running the conversion twice, once on each field. I have been using maximum combined area but just discovered that this creates errors in the output. What I noticed was that, for example, I have field a and field b, and both contain value x. If a row in field a has value x, then the same row in field b also has value x. But when I run the conversion this is not true a very small percentage of the time. I realize that this is probably cause by doing the maximum combined area. But what would really be nice is if I could just convert the raster using both fields? Is there a way to do this if I went into python? Or is my only option to create a new attribute field that combines the previous 2, and convert based on that?
Thanks!
Maritza


So I guess the answer is no, but there are workarounds (which I knew already). Oh well. I'll leave this up in case anyone in the future has the same question.

View solution in original post

0 Kudos
4 Replies
SteveLynch
Esri Regular Contributor
Max combined area will give different output because the values may be different. See How Polygon To Raster works in the help.


Why don't you use the CELL_CENTER method and use the polygon FC's object-id field and then join the polygon's attribute table to the rasters table and persist it to a new raster.
0 Kudos
MaritzaMallek
New Contributor II
Max combined area will give different output because the values may be different. See How Polygon To Raster works in the help.

Yes, I understand that. I use this tool all the time. Sorry if that wasn't clear.

Why don't you use the CELL_CENTER method

Well, CELL_CENTER has it's own flaws. In this particular dataset it is very common for polygon boundaries to pass through a pixel. So yes, I could use CELL_CENTER. But this is a somewhat arbitrary setting; why not go for the max area setting, which at least (to me) reflects the overall character of an individual cell. That is sort of what I was going for with using max combined, although I am now thinking perhaps it wasn't doing quite what I had hoped.

and use the polygon FC's object-id field and then join the polygon's attribute table to the rasters table and persist it to a new raster.

I'm not sure exactly what you are suggesting here. Are you suggesting doing the rasterization based on the object ID field rather than on the attribute field of interest?


Regardless, my question is whether there is a way to base the polygon to raster conversion on more than one field. If I did it in Python instead of with the tool, would I be able to, or is the tool to much of a black box to modify in that way?
0 Kudos
SteveLynch
Esri Regular Contributor
I'm not sure exactly what you are suggesting here. Are you suggesting doing the rasterization based on the object ID field rather than on the attribute field of interest?



Yes, then join the featureclass table to the raster attribute table and persist the raster. Your raster will then have all the info from the featureclass.

Another option would be to manipulate your two fields into one and then convert to raster.

Steve
0 Kudos
MaritzaMallek
New Contributor II
I am doing a lot of geoprocessing for a project where all my input layers need to be perfectly overlapping rasters. Some of my input data starts out as polygons, and I have been converting them to rasters. One of my "base" polygons has 2 fields I need, so I have been running the conversion twice, once on each field. I have been using maximum combined area but just discovered that this creates errors in the output. What I noticed was that, for example, I have field a and field b, and both contain value x. If a row in field a has value x, then the same row in field b also has value x. But when I run the conversion this is not true a very small percentage of the time. I realize that this is probably cause by doing the maximum combined area. But what would really be nice is if I could just convert the raster using both fields? Is there a way to do this if I went into python? Or is my only option to create a new attribute field that combines the previous 2, and convert based on that?
Thanks!
Maritza


So I guess the answer is no, but there are workarounds (which I knew already). Oh well. I'll leave this up in case anyone in the future has the same question.
0 Kudos