How to create one raster from many polygons of species distribution??

390
8
Jump to solution
02-03-2014 09:09 AM
ThiagoModesto
New Contributor
I have a shapefile with the distribution of many species in polygons. I need to create a raster that shows me the number of species
per cell. How should I do?
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
PaulBeurskens
New Contributor III
Hi

The reason it didn't work was becouse of the multipleoverlapping polygons.
I have tried to solve it using some data I have made myself that simulates your situation.
What is critical is that a species does not have overlapping polygons.
If it does you should first dissolve (http://resources.arcgis.com/en/help/main/10.1/index.html#//00170000005n000000)  your layer on the species so you have one (or more but without overlapping) polygon(s), make shure not to create multiparts.

First you preform a union (http://resources.arcgis.com/en/help/main/10.1/index.html#//00080000000s000000) on your shape (it is allowed to do so on one shapefile), this will make small pieces of overlapping data clipping the data on each other.

Then you need to add three columns to the attribute table of the union shapefile:
-  X  "double"
-  Y "double
-  compare "text" (minimum of 50 characters)
In X you calculate the x coördinate of the polygon using the calculate geomitry function in the attribute table (http://resources.arcgis.com/en/help/main/10.1/index.html#//005s00000027000000)
In Y you calculate the y coördinate in the same way.
In compare you make a combination of the X and Y fields to get the combination of the two, becouse of the overlapping parts the union makes you need tis so you have a unique code for that specific location. All the overlapping parts are identical so the centrers are identical.
You can paste this in your field calculator: &"_"&
(so X and Y are seprarated with an underscore).

With this done you need to first summarize the compare field (http://resources.arcgis.com/en/help/main/10.1/index.html#//005s00000055000000) this creates a table with a count of the values, no need to assess other fields just specify the output location and name and click OK (add it to the map).
Then dissolve (http://resources.arcgis.com/en/help/main/10.1/index.html#//00170000005n000000) the shapefile with the compare field.
This will bring it down to a single feature layer per location.

Where almost there 😉
Join the data from the summarized table to the dissolved shapefile (based on the compare field) and it will add the number of counts to your shapefile from the summarized table.
To permanently fuse the data rightclick your joined shape and click export data (all features) and save it again.

This makes a shape with a count field of the overlapping polygons, you can now run the polygon to raster tool with the value of the count field (http://resources.arcgis.com/en/help/main/10.1/index.html#//001200000030000000).

It looks like a lot but it are just a few steps.
I hope this works for you, it did it for me.

Greets Paul

View solution in original post

0 Kudos
8 Replies
PaulBeurskens
New Contributor III
What does your shapefile look like?
Are ther several different shapefiles?
Or are there multiple features on top of each other?
Or is there a remark in the attribute table you can use to get the count.

If you have a value in a field jou could use polygon to raster (http://resources.arcgis.com/en/help/main/10.1/index.html#//001200000030000000).

But a bit more info is needed to give a good answer.

Greets Paul
0 Kudos
JoshuaChisholm
Regular Contributor
Hello thiago021,

You'll need to do this in two steps.
1) Prepare an attribute you want in raster form. I think you want total number of species. In other words a count of non-zero fields for a specific polygon.
First open the shapefile's attribute table and create a new field (make sure its a number type like ShortInteger). Then right click on that new field and click Field Calculator. Enter in a formula to calculate number of species. I would use something like this (using Python😞
Pre-Logic Script Code: (make sure Show Codeblock is checked)

def getSpeciesCount(speciesFields):
    speciesCount=0
    for speciesField in speciesFields:
        if str(speciesField)!="0": #should handel sting and interger inputs
            speciesCount+=1
    return speciesCount


numSpecies=

getSpeciesCount([!Frogs!, !Goats!, !Deer!])


2) Convert to raster using the Polygon to Raster tool, set the field value to the attribute created above.

Let me know if you get it working. Good luck!
0 Kudos
ThiagoModesto
New Contributor
Have you tried the feature to Raster tool? In ArcToolbox -> Conversion Tools: http://resources.arcgis.com/en/help/main/10.1/index.html#//00120000002v000000 (assuming you are using ArcGIS version 10.1)

To better assist you and general curiosity: What do you intend to use the raster for? Comparison with another raster? Analysis?

http://resources.arcgis.com/en/help/main/10.1/index.html#/Polygon_to_Raster/001200000030000000/


What does your shapefile look like?
Are ther several different shapefiles?
Or are there multiple features on top of each other?
Or is there a remark in the attribute table you can use to get the count.

If you have a value in a field jou could use polygon to raster (http://resources.arcgis.com/en/help/main/10.1/index.html#//001200000030000000).

But a bit more info is needed to give a good answer.

Greets Paul


I have a file with multiple overlapping polygons in one shapefile. Each polygon represents the distribution of a species. In total there are over 150 species. When I create the raster file the result brings no information on the number of overlapping polygons. I need this information to know how many species there are per cell and how the species are distributed in a particular location for use in statistical analyzes of conservation.

I  have tried the Polygon to Raster, but it did not work.

Hello thiago021,

You'll need to do this in two steps.
1) Prepare an attribute you want in raster form. I think you want total number of species. In other words a count of non-zero fields for a specific polygon.
First open the shapefile's attribute table and create a new field (make sure its a number type like ShortInteger). Then right click on that new field and click Field Calculator. Enter in a formula to calculate number of species. I would use something like this (using Python😞
Pre-Logic Script Code: (make sure Show Codeblock is checked)

def getSpeciesCount(speciesFields):
    speciesCount=0
    for speciesField in speciesFields:
        if str(speciesField)!="0": #should handel sting and interger inputs
            speciesCount+=1
    return speciesCount


numSpecies=

getSpeciesCount([!Frogs!, !Goats!, !Deer!])


2) Convert to raster using the Polygon to Raster tool, set the field value to the attribute created above.

Let me know if you get it working. Good luck!


I also tried your suggestion, but it did not work because it created a field with all values "1" and then a raster with all cells values 1. If I can turn each polygon (each species) in a raster where the species were "1" and the remaining "0", I think I could solve, but I do not know how to do this.
0 Kudos
PaulBeurskens
New Contributor III
Hi

The reason it didn't work was becouse of the multipleoverlapping polygons.
I have tried to solve it using some data I have made myself that simulates your situation.
What is critical is that a species does not have overlapping polygons.
If it does you should first dissolve (http://resources.arcgis.com/en/help/main/10.1/index.html#//00170000005n000000)  your layer on the species so you have one (or more but without overlapping) polygon(s), make shure not to create multiparts.

First you preform a union (http://resources.arcgis.com/en/help/main/10.1/index.html#//00080000000s000000) on your shape (it is allowed to do so on one shapefile), this will make small pieces of overlapping data clipping the data on each other.

Then you need to add three columns to the attribute table of the union shapefile:
-  X  "double"
-  Y "double
-  compare "text" (minimum of 50 characters)
In X you calculate the x coördinate of the polygon using the calculate geomitry function in the attribute table (http://resources.arcgis.com/en/help/main/10.1/index.html#//005s00000027000000)
In Y you calculate the y coördinate in the same way.
In compare you make a combination of the X and Y fields to get the combination of the two, becouse of the overlapping parts the union makes you need tis so you have a unique code for that specific location. All the overlapping parts are identical so the centrers are identical.
You can paste this in your field calculator: &"_"&
(so X and Y are seprarated with an underscore).

With this done you need to first summarize the compare field (http://resources.arcgis.com/en/help/main/10.1/index.html#//005s00000055000000) this creates a table with a count of the values, no need to assess other fields just specify the output location and name and click OK (add it to the map).
Then dissolve (http://resources.arcgis.com/en/help/main/10.1/index.html#//00170000005n000000) the shapefile with the compare field.
This will bring it down to a single feature layer per location.

Where almost there 😉
Join the data from the summarized table to the dissolved shapefile (based on the compare field) and it will add the number of counts to your shapefile from the summarized table.
To permanently fuse the data rightclick your joined shape and click export data (all features) and save it again.

This makes a shape with a count field of the overlapping polygons, you can now run the polygon to raster tool with the value of the count field (http://resources.arcgis.com/en/help/main/10.1/index.html#//001200000030000000).

It looks like a lot but it are just a few steps.
I hope this works for you, it did it for me.

Greets Paul

View solution in original post

0 Kudos
PaulBeurskens
New Contributor III
I agree with Sol on working in a file geodatabase.
Your working enviroment will become more stable and you will be able to save the summary there as well.

Greets Paul
0 Kudos
PaulBeurskens
New Contributor III
I see I forgot to mention someting.

When calculating X and Y you need to calculate the Centoid of the polygon.
You will probably do it correctly but this is a critical step.

Please let us know if it worked.
0 Kudos
ThiagoModesto
New Contributor
Hi

The reason it didn't work was becouse of the multipleoverlapping polygons.
I have tried to solve it using some data I have made myself that simulates your situation.
What is critical is that a species does not have overlapping polygons.
If it does you should first dissolve (http://resources.arcgis.com/en/help/main/10.1/index.html#//00170000005n000000)  your layer on the species so you have one (or more but without overlapping) polygon(s), make shure not to create multiparts.

First you preform a union (http://resources.arcgis.com/en/help/main/10.1/index.html#//00080000000s000000) on your shape (it is allowed to do so on one shapefile), this will make small pieces of overlapping data clipping the data on each other.

Then you need to add three columns to the attribute table of the union shapefile:
-  X  "double"
-  Y "double
-  compare "text" (minimum of 50 characters)
In X you calculate the x coördinate of the polygon using the calculate geomitry function in the attribute table (http://resources.arcgis.com/en/help/main/10.1/index.html#//005s00000027000000)
In Y you calculate the y coördinate in the same way.
In compare you make a combination of the X and Y fields to get the combination of the two, becouse of the overlapping parts the union makes you need tis so you have a unique code for that specific location. All the overlapping parts are identical so the centrers are identical.
You can paste this in your field calculator: &"_"&
(so X and Y are seprarated with an underscore).

With this done you need to first summarize the compare field (http://resources.arcgis.com/en/help/main/10.1/index.html#//005s00000055000000) this creates a table with a count of the values, no need to assess other fields just specify the output location and name and click OK (add it to the map).
Then dissolve (http://resources.arcgis.com/en/help/main/10.1/index.html#//00170000005n000000) the shapefile with the compare field.
This will bring it down to a single feature layer per location.

Where almost there 😉
Join the data from the summarized table to the dissolved shapefile (based on the compare field) and it will add the number of counts to your shapefile from the summarized table.
To permanently fuse the data rightclick your joined shape and click export data (all features) and save it again.

This makes a shape with a count field of the overlapping polygons, you can now run the polygon to raster tool with the value of the count field (http://resources.arcgis.com/en/help/main/10.1/index.html#//001200000030000000).

It looks like a lot but it are just a few steps.
I hope this works for you, it did it for me.

Greets Paul



It worked!
Thank you so much!!!

thiago021
0 Kudos
PaulBeurskens
New Contributor III
Great!

These questions are allways interesting and fun if they can be solved.
If you would please check the box that it is the answer and Arrow up on it.

Thanks!!

Greets Paul
0 Kudos