# a quick look at a (pseudo) random section of this data
chla_mean[35:37, 245:247]
## [,1] [,2] [,3]
## [1,] 0.1415056 0.1358830 0.1303250
## [2,] 0.1339336 0.1328560 0.1255906
## [3,] 0.1358152 0.1276533 0.1243571
# Change the dimension names of our matrix to "lon" and "lat",
# and the row and column names to the latitude and longitude values.
dimnames(chla_mean) <- list(lon=nc_lon, lat=nc_lat)
chla_mean[35:37, 245:247]
## lat
## lon -36.4791717529297 -36.5208358764648 -36.5625038146973
## 16.6458396911621 0.1415056 0.1358830 0.1303250
## 16.6875057220459 0.1339336 0.1328560 0.1255906
## 16.7291717529297 0.1358152 0.1276533 0.1243571
# lastly, you may want to transpose this matrix.
chla_mean <- t(chla_mean)
chla_mean[245:247, 35:37]
## lon
## lat 16.6458396911621 16.6875057220459 16.7291717529297
## -36.4791717529297 0.1415056 0.1339336 0.1358152
## -36.5208358764648 0.1358830 0.1328560 0.1276533
## -36.5625038146973 0.1303250 0.1255906 0.1243571