1

I have a big spatial dataset file that I need to import to the QGIS to get the temperature data from each grid. However, the dataset file is in the format of having longitude as first row, latitude as first column. And the temperature data is in the format of a 2D matrix.

Is there a way to read the file to the QGIS? Or is there an easier way to convert the file to QGIS-readable format? enter image description here

1

To import this into QGIS as a point shapefile, you need each unique point to be its own row in the spreadsheet.

So you should convert this:

enter image description here

To this:

enter image description here

With n different latitudes and longitudes, your end result has n-squared lines. (In my example, n=5 so there are 25 lines in the second sheet.) Then you import the new spreadsheet and each line of the new spreadsheet becomes a point in QGIS. In my example, the original 2-D table is Sheet1 and the 1-D table is Sheet2 in the same Excel workbook. In the next image, I've removed the equals sign from each cell formula so you can see the formulas I used.

enter image description here

EDIT: It probably makes more sense to display this information in raster format. Use the rasterize tool to convert from a vector to a raster.

enter image description here

  • 2
    If you convert your data into XYZ, you can use ASCII GRIDDED XYZ raster format to read points into a grid in one step inQGIS (be carefull the order of points, increasing Y order) – Zoltan Oct 12 '16 at 5:54
  • I used R to convert the data into XYZ, now it works! Thanks @Zoltan and csk – wwwwwwww Oct 12 '16 at 21:51
2

If this single file have to be converted to QGIS, change it manually into an ESRI ASCII GRID. Remove the first row and the first column in libre/open office calc, save as data into a csv file. The separator should be space in the grid file (extension .grd). Add manually the header information to the file:

ncols 180
nrows 90
xllcorner -179 
yllcorner -89
cellsize 2
nodata_value -9999
0.20 0.20 0.20 ....
...

I hope I guess the number of columns and rows well. Open this file as a raster (Arc/info ASCII GRID) in QGIS.

  • Zoltan, many thanks. Would you mind teaching me how to manually add the header information to the file? – wwwwwwww Oct 11 '16 at 17:20
  • 1
    I have created a raster like this – wwwwwwww Oct 11 '16 at 17:38
  • This is a raster that I made: flic.kr/p/MYKdB2 – wwwwwwww Oct 11 '16 at 17:39
  • I used your suggested method. but the raster is repeating itself in QGIS – wwwwwwww Oct 11 '16 at 17:40
  • You need a simple text editor to add header. Please let me see your spreadsheet and grid files, without that I can't help. – Zoltan Oct 12 '16 at 5:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.