Hey everyone!
First off, thank you for all help, I really appreciate everyone who takes time off their own work to help others. My problem is the following:
I am currently trying to create a series of maps for a presentation and have run into a series of issues in getting them to look the way I want.
My dataset consists of >19k rows, with a latitude value, longitude value, and then some variables of interest that I want to graph/map. For the purpose of this example, let’s just assume that the dataset only has three columns: latitude, longitude, and pre-industrial temperature.
The two main issues I have are as follows:
I run the following code to create a map
preindT_grd = xyz2grd(preindT_df, region=(-180, 180, -60, 83), spacing=(1.0, 1.0))
C = grd2cpt(preindT_grd, cmap=:polar);
grdimage(preindT_grd, proj=:Miller, cmap=C, title = "Pre-Industrial Temperature Distribution", xaxis=(annot=60, ticks=60), yaxis=(annot=20, ticks=20))
colorbar!(C=C,frame=(annot=:5));
coast!(region=(-180, 180, -60, 83), water="lightblue", proj=:Miller, savefig ="preindustrial_temperature.jpg")
which looks as follows:
My data only covers areas with economic activity, so the NaN values (white squares) in the center of Greenland are expected. However, there are a number of regions (such as Brittany in Western France) where I definitely have data. I think this has to do with how I have defined the grid when I created my dataset.
In my dataset, every row represents a 1° x 1° area. The latitude/longitude data I have tells me the coordinates of the lower left-hand corner of that area. So, the row with latitude/longitude values 48/2 gives data for the region between 48 and 49° latitude and 2 to 3° longitude. I am guessing that this is not the input that xyz2grid expects to create a grid. How can I either transform my data set to match the way that xyz2grid defines longitude and latitude or change the function call? And would this eliminate the “wrong” whitespaces I have on the map, especially around some of the coastal regions.
The second thing I would like to do is increase the number of bins that grd2cpt creates. When I change my code to:
C = grd2cpt(preindT_grd, cmap=:polar, nlevels = 128);
This changes the number of bins, but they are now equidistant, not binned so that every bin has the same number of values. For temperature, this is fine but some of my other variables have a significantly more uneven range. How would I tell grd2cpt to use more bins while still making them equally sized?
Thank you again for your help and I apologize if any of this is trivial.
Best,
Henri