Working with csv files


We recently started to save all GOES-PRWEB hydro-climate variables as comma separated value (csv) files.   This format is useful as it can be read into spreadsheets, GIS programs and computational programs such as Matlab.  To use the hydro-climate variable csv file you will also need the latitude and longitude files.  Although the hydroclimate variable csv files are updated periodically (e.g.,daily, monthly or annually), the latitude (LAT.csv) and longitude (LON.csv) files never change, and therefore you only need to download them once.  These files can be downloaded by clicking on the hyperlinks below:

LAT csv file

LON csv file

If you open up a hydro-climate csv file in Excel, for example soil_moisture20151008.csv, which is the soil moisture file for October 8th 2015, you will see a matrix of values 101 rows by 210 columns.   Each cell has a corresponding latitude and longitude that you can find in the LAT.csv and LON.csv files.   Let’s  continue working with the example.  Suppose we want to know what the soil moisture is at latitude 18.3 degrees north, longitude 66.0 west.  Start by opening the LON.csv file and searching for the row corresponding with 18.3 degrees.  (Note that if you have Excel on your computer it will open in Excel, however, if do not have Excel it will open in a text editor.)  The closest value of latitude is 18.304 in row 57.  Now open the LON.csv file and search for the column with a value of -66.0 (note that the negative value makes it a westerly longitude). The closest value is -66.005 in columns EO. Now if we open the file soil_moisture20151008.csv, row 57, column EO gives a value of the volumetric soil moisture content of 0.25033.

In some cases it is more convenient to have the latitude, longitude and hydro-climate value in three columns (x,y,z format), instead of in large matrices. To covert the data to and x,y,z format you can use a program like Matlab to transform the data. A sample Matlab script is provided below to convert the matrix data from the three files to an x,y,z data set in one csv file.

LON=csvread(‘LONGITUDE.csv’);
LAT=csvread(‘LATITUDE.csv’);
SM=csvread(‘soil_moisture20151008.csv’);
xyz=zeros(101*210,3);
k=0;
for i=1:101
for j=1:210
k=k+1;
xyz(k,1)=LAT(i,j);
xyz(k,2)=LON(i,j);
xyz(k,3)=SM(i,j);
end
end
csvwrite(‘xyz.csv’,xyz);

GOES-PRWEB daily images and csv files (csv files are available starting in Jan 2009)
GOES-PRWEB monthly averages and totals (csv files available starting Jan 2009)
GOES-PRWEB annual averages and totals (csv files available starting in 2009)

DISCLAIMER: The information on this website is provided “as is”, should be considered provisional and is subject to change. The authors and publishers of this information disclaim any loss or liability, either directly or indirectly as a consequence of applying the information provided herein, or in regard to the use and application of said information. No guarantee is given, either expressed or implied, in regard to the accuracy, or acceptability of the information.

Advertisements