# Convert lat/long four corners data to raster

I have a data set in the following format.each row represents the coordinates of the four corners of a cell and the last column is the value associated to the cell.

``````lon1 lat1 lon2 lat2 lon3 lat3 lon4 lat4 TotHg
========================================================
-44.48, 49.88,  -44.69, 50.51,  -43.71, 50.64,  -43.5,  50.02, 8.50

-42.53  50.14   -42.71  50.77   -41.71  50.88   -41.54  50.25   9.02

-40.56  50.35   -40.71  50.98   -39.7   51.08   -39.56  50.44   9.21

-38.56  50.52   -38.68  51.16   -37.66  51.23   -37.56  50.59   8.75

-36.55  50.64   -36.64  51.28   -35.61  51.33   -35.54  50.69   8.53
``````

I would like to convert it to a raster to be used in GIS. At the moment I do not know the coordinate system but I am investigating. All I know is that the resolution is supposed to be 2.5°. How can this be done in either R or in ArcMap? I have read a similar thread but I am not sure if it is the same situation since I have the coordinates for the four corners of each cell.this is the other question: How can I convert data in the form of lat, lon, value into a raster file using R?

I have to resuscitate this question because I have received some information about projection. I am not sure if this will change the answer or help in any way. I am still quite confused at the moment. Here is the information I have received:

My model is define on a 2-d plane by using a polarstereographic projection with a griddistance of 150 km at 60N. The projection is define by:

X_in_grid_units=x_coordinate_of_northpole+6370km/150km*(1+sin(60N))*tan(45-latitude/2)sin(longitude-(-32)) y_in_grid_units=y_coordinate_of_northpole-6370km/150km(1+sin(60N))*tan(45-latitude/2)*cos(longitude-(-32))

where 6370km is the used diameter for the projection, 150km as told before is the griddistance at 60N, -32=32W is central longitude for the projection, eg. the longitude parallel with y-axis. The griddistance as a function of latitude is defined as d=150km*(1+sin(latitude)/(1+sin(60N)), eg. 160.77km at northpole, and 80.38km at equator.

• These data obviously are not for a grid with a 2.5 degree resolution. We might think of them as `TotHg` values associated with various (four-cornered) polygons. But how, exactly, should such data be converted to raster? Do you want to create a raster representation that will have a similar appearance to this vector layer of a collection of polygons-with-attributes? Or perhaps you need to interpolate the values? Or compute a kernel density? More information is needed to make this an answerable question: please edit it. – whuber Jun 24 '13 at 19:19
• @whuber I will try to gather more information and add it to the question. Are you saying that one row doesn't correspond to a square? I need to create a raster where each cell has one tothg value. – Herman Toothrot Jun 24 '13 at 19:53
• Look at the positions of the four points in each of your rows: they neither describe squares 2.5 degrees on a side, nor do the differ by whole multiples of 2.5 degrees. If you try to represent these with a 2.5 degree grid, something has to give. – whuber Jun 24 '13 at 20:25

Your sample data, when drawn as quadrangles and labeled with the `totHg` values, look like this: (It is simple to create a GIS polygon layer from these data, as I did in order to make this illustration, but would likely require a little programming in Python or `R` due to the idiosyncratic nature of this data format.)

These might have been collected on a regular grid in some other coordinate system, but (if they are currently in lon-lat as stipulated) they clearly are not on a 2.5 degree grid.

Presumably the data records not shown would fill in this row and describe adjacent rows of data, too. But maybe not--maybe many of the apparent cells are missing.

There are three general approaches to creating raster representations of such data:

1. Assume the values represent measurements of some hypothetical underlying "surface" of such measurements. These could be mercury concentrations in air at a particular time, for instance: the concentrations at unsampled locations at that time will exist but are unknown and should be predicted from the measurements. This calls for spatial prediction ("interpolation"). For this purpose the measurements might be assumed to take place at the center of each polygon.

A variant of this supposes these are average concentrations within the extents of each polygon, not just at single points. About the only way to interpolate such data is by applying "change of support" formulas to Kriging in a method called "area-to-point Kriging".

2. The values are what they are: attributes of polygonal regions on the earth's surface. Just divide the map up into a regular array of rows and columns and transfer this picture onto that array. That means most of the cells in the array will have missing values; all those whose centers are located within the "8.5" polygon will get the value 8.5; all those whose centers are located within the "9.02" polygon will get the value 9.02; and so on.

3. Assume the values shown represent some aggregate amounts of something that you would like--for cartographic or analytic purposes--to spread within surrounding areas without "losing" any of the total. This is done with a kernel density calculation.

An "area-to-point" version of the kernel density can be obtained via convolution, using a Fast Fourier Transform. Many applications don't worry about this and just assume the data values are located at the centers of their polygons, then spread the values from their centers.

To reduce the loss of information when discretizing these data into a raster, it is a good idea to use a small resolution. In the figure, the spacing between adjacent cells looks like it's about 0.5 degree. Consider using something around 0.1 degree or less. That is practicable, because the entire world can be covered by an 1800 by 3600 grid, which today is considered only small or medium in size and can be post-processed fairly quickly.

Another possibility is to find out precisely what coordinate system was used for the original grid and reproject these data into that coordinate system, where (presumably) they will already lie on a regular square array. If you do not know the coordinate system already, that is often a difficult process.

• thank you for your answer, I am trying to contact the person who provided the data and will get back to this question to close it properly. – Herman Toothrot Jun 28 '13 at 8:49