Converting Data Types
There are library's available for R to work with raster and polygon data. However, most of the statistic functions we are exploring and will use in the future require point data, typically in the form of a CSV. Also, certain modeling methods we'll be exploring require data to have a specific type of value. Typically, we'll use the modeling method that is intended for our type of data but at times we may need to convert our data to use the desired modeling method. The steps below will show you how to convert just about any type of data commonly used in GIS to the other types supported by various modeling methods.
The figure above shows how to move data between the different types. There are details below
Converting The Measurement Type
Occurrence Points to:
- Points with Binary values:
- Create a count data set as below
- ArcMap: Use the field calculator to convert values >0 to 1
- BlueSpray: Use Excel to convert the values >0 to 1
- Right click on the attribute and selected "Calculate..." to convert values >0 to 1
- Points with Counts:
- BlueSpray:
- Select the "To Raster..."
- Set the bounds and "Pixel Reference Width..." to match the desired grid (or raster)
- Set the "Pixel Source" to "Count"
- Setup the output and click "OK"
- Convert the resulting raster back to points.
- ArcMap (not recommended for large data sets):
- Take one of your predictor variable rasters and convert it to a polygon mesh
- Use a join to connect the points to the polygons
- Add an attribute that counts the number of occurrences in each polygon
- Points with Continuous values: Convert your point data set to a density raster, then convert the raster to points
- ArcMap:
- Use a density function to do the conversion
Points with Binary Values to:
- Occurrence Points:
- Remove values that are zero (absences)
- Points with Count values:
- Remove values that are zero (absences)
- Convert to "Count" as in "Occurrences to" above
- Points with Continuous values:
- To create a density of presences:
- Remove values that are zero (absences)
- Use a density function to do the conversion (ArcMap only)
- To create a mean value:
- BlueSpray:
- Remove the values that are zero
- Create a count raster as above in "Occurrences to"
- From the original data set, remove the values that are one
- Create a count raster as above in "Occurrences to"
- You now have two rasters, one for the number of zeros and one for the number of ones in each pixel. You can use a raster calculator (BlueSpray or ArcMap) to compute the mean number or another measure.
Point Counts to:
- Occurrence Points:
- Remove any values with count of 0
- Points with Binary values:
- Add an attribute column and set it to 0 where the count is 0 and 1 where the count is greater than 0
- Points with Continuous values:
- Convert the points to a raster using the count as the new pixel value
- This could then be divided by the pixel size to obtain a density if desired.
Points with Continuous values to:
- Occurrence Points:
- Remove any values that are zero (or below some threshold) and ignore the values
- Points with Binary values:
- Create a new attribute and set it to 0
- Set the values to 1 where the value > 0
- Points with Count values:
- This only makes sense if the continuous value can be equated to some type of count.
Rasters to Point Layers:
- Convert the raster to points. The center of each pixels will be a new point location and the pixel value will become the attribute value. Then, you can use the methods above to convert to the desired point type.
Polygons to Point Layers:
- Convert the polygons to a raster using the desired attribute value as the value for the pixels. Then, use the convert the raster to points as above.
Polylines to Point Layers:
- First, add the desired number of points along the polyline using "densify" in ArcGIS and then convert "feature verticies to points".