I have two raster file, i want to perform Scatter plot of those raster . I found one code that is written by Dan Patterson
from matplotlib import pyplot as plt
xs = [1,3,2,5,6,4] # Which fomart of data i have to give here?
ys = [3,2,1,5,3,2]
main_title ="My first graph"
plt.title(main_title, loc='center') #loc is either left, right or center
plt.tick_params(which='major', direction='in', length=6, width=2)
plt.tick_params(which='minor', direction='in', length=4, width=2)
Earlier Dan suggest to someone convert those raster to arrays. I followed the same but could not solve it. How to process tiff to array.
how do i execute two raster in X and Y axis. I have tiff images.
Solved! Go to Solution.
Follow Neil's and Xander's advice. A plot like that is going to show nothing more than a scaled down version. Calculate the statistical parameters of both variables and summarize in tabular form. This is a classic example of a graph adding nothing to the analysis or presentation. In fact, the association between the variables is better shown in mapped form since the spatial dimension is explicit.
Is this a requirement for some project? If so, gently suggest to the proponent that better means of examining the relationship are available.
you have to plot them separately as rasters not as a scatter plot, you can convert a raster to rows and columns and plot those as a scatterplot, so I am not sure what you want to do specifically. What does your data look like now?
I would normally not do this on the entire raster or rasters but create a random subset of them using Create Random points and then use Sample.
Then just use the graphing tools inside ArcMap.
I think the suggestion by Neil Ayres is an option you should look at. Use Create Random Points—Help | ArcGIS for Desktop , followed by Extract Multi Values to Points—Help | ArcGIS for Desktop to graph the two variables (rasters) together in a scatter plot.
The alternative is using numpy to access the pixel values and create a resulting table with the combination of the values for each cell. In your case that would be over 5.5 M records, which might yield errors.