Skip to main content
added 51 characters in body
Source Link
Dave X
  • 1.7k
  • 13
  • 26

If your data is on a regular grid, (even with holes/missing data), sorted by y and x (y primary), as from the python code below, then the data can be imported directly as a raster.

# Make a random CSV xyz file compatible with GDAL
import numpy as np
 
x = np.array([(y, x, 1.0) for x in range(5328530,5328560,10) for y in range(4390000,4390100,10)])
x[:,2] = np.random.normal(size=x.shape[0])
np.savetxt("/Users/drf/data/foo"foo.csv",fmt="%8.1f %8.1f %8.5f",x,
           header="x y z",comments='')


x y z
4390000.0 5328530.0   1.69132
4390010.0 5328530.0  -0.96375
4390020.0 5328530.0  -0.96426
4390030.0 5328530.0   1.90196
4390040.0 5328530.0  -0.43301
4390050.0 5328530.0  -0.47332
4390060.0 5328530.0   0.44058
4390070.0 5328530.0   1.24625
4390080.0 5328530.0   0.01709
4390090.0 5328530.0   1.81022
4390000.0 5328540.0   1.48794
4390010.0 5328540.0   1.20569
4390020.0 5328540.0   0.08455
4390030.0 5328540.0  -1.33575
4390040.0 5328540.0   2.41027
4390050.0 5328540.0  -1.15869
4390060.0 5328540.0   0.41672
4390070.0 5328540.0   1.10926
4390080.0 5328540.0   0.22557
4390090.0 5328540.0  -0.65360
4390000.0 5328550.0  -0.49709
4390010.0 5328550.0   0.53986
4390020.0 5328550.0  -0.90243
4390030.0 5328550.0   0.09379
4390040.0 5328550.0   0.16449
4390050.0 5328550.0   0.55429
4390060.0 5328550.0  -0.55609
4390070.0 5328550.0  -0.78839
4390080.0 5328550.0  -1.76425
4390090.0 5328550.0  -1.31797

This data can be read directly from Layer/Add Layer/Add Raster Layer/ Dataset tool.

If your data isn't a regular grid, and you already have the points imported as a layer, with the accurate fields, then the problem might not be with your data import, its with transforming the point data into a raster, as in Interpolation on set of points in QGIS or this QGIS tutoriatutorial. You should be able to use one of the interpolation tools Processing /(search 'interp') tools like Processing/Interpolation/IDW Interpolation, Processing/Interpolation/TIN Interpolation, Processing/SAGA/Raster Creation/Interpolate or others.

If your data is on a regular grid, (even with holes/missing data), sorted by y and x (y primary), as from the python code below, then the data can be imported directly as a raster.

import numpy as np
 
x = np.array([(y, x, 1.0) for x in range(5328530,5328560,10) for y in range(4390000,4390100,10)])
x[:,2] = np.random.normal(size=x.shape[0])
np.savetxt("/Users/drf/data/foo.csv",fmt="%8.1f %8.1f %8.5f",x,header="x y z",comments='')


x y z
4390000.0 5328530.0   1.69132
4390010.0 5328530.0  -0.96375
4390020.0 5328530.0  -0.96426
4390030.0 5328530.0   1.90196
4390040.0 5328530.0  -0.43301
4390050.0 5328530.0  -0.47332
4390060.0 5328530.0   0.44058
4390070.0 5328530.0   1.24625
4390080.0 5328530.0   0.01709
4390090.0 5328530.0   1.81022
4390000.0 5328540.0   1.48794
4390010.0 5328540.0   1.20569
4390020.0 5328540.0   0.08455
4390030.0 5328540.0  -1.33575
4390040.0 5328540.0   2.41027
4390050.0 5328540.0  -1.15869
4390060.0 5328540.0   0.41672
4390070.0 5328540.0   1.10926
4390080.0 5328540.0   0.22557
4390090.0 5328540.0  -0.65360
4390000.0 5328550.0  -0.49709
4390010.0 5328550.0   0.53986
4390020.0 5328550.0  -0.90243
4390030.0 5328550.0   0.09379
4390040.0 5328550.0   0.16449
4390050.0 5328550.0   0.55429
4390060.0 5328550.0  -0.55609
4390070.0 5328550.0  -0.78839
4390080.0 5328550.0  -1.76425
4390090.0 5328550.0  -1.31797

This data can be read directly from Layer/Add Layer/Add Raster Layer/ Dataset tool.

If your data isn't a regular grid, and you already have the points imported as a layer, with the accurate fields, then the problem might not be with your data import, its with transforming the point data into a raster, as in Interpolation on set of points in QGIS or this QGIS tutoria. You should be able to use one of the interpolation tools Processing /(search 'interp') tools like Processing/Interpolation/IDW Interpolation, Processing/Interpolation/TIN Interpolation, Processing/SAGA/Raster Creation/Interpolate or others.

If your data is on a regular grid, (even with holes/missing data), sorted by y and x (y primary), as from the python code below, then the data can be imported directly as a raster.

# Make a random CSV xyz file compatible with GDAL
import numpy as np
x = np.array([(y, x, 1.0) for x in range(5328530,5328560,10) for y in range(4390000,4390100,10)])
x[:,2] = np.random.normal(size=x.shape[0])
np.savetxt("foo.csv",fmt="%8.1f %8.1f %8.5f",x,
           header="x y z",comments='')


x y z
4390000.0 5328530.0   1.69132
4390010.0 5328530.0  -0.96375
4390020.0 5328530.0  -0.96426
4390030.0 5328530.0   1.90196
4390040.0 5328530.0  -0.43301
4390050.0 5328530.0  -0.47332
4390060.0 5328530.0   0.44058
4390070.0 5328530.0   1.24625
4390080.0 5328530.0   0.01709
4390090.0 5328530.0   1.81022
4390000.0 5328540.0   1.48794
4390010.0 5328540.0   1.20569
4390020.0 5328540.0   0.08455
4390030.0 5328540.0  -1.33575
4390040.0 5328540.0   2.41027
4390050.0 5328540.0  -1.15869
4390060.0 5328540.0   0.41672
4390070.0 5328540.0   1.10926
4390080.0 5328540.0   0.22557
4390090.0 5328540.0  -0.65360
4390000.0 5328550.0  -0.49709
4390010.0 5328550.0   0.53986
4390020.0 5328550.0  -0.90243
4390030.0 5328550.0   0.09379
4390040.0 5328550.0   0.16449
4390050.0 5328550.0   0.55429
4390060.0 5328550.0  -0.55609
4390070.0 5328550.0  -0.78839
4390080.0 5328550.0  -1.76425
4390090.0 5328550.0  -1.31797

This data can be read directly from Layer/Add Layer/Add Raster Layer/ Dataset tool.

If your data isn't a regular grid, and you already have the points imported as a layer, with the accurate fields, then the problem might not be with your data import, its with transforming the point data into a raster, as in Interpolation on set of points in QGIS or this QGIS tutorial. You should be able to use one of the interpolation tools Processing /(search 'interp') tools like Processing/Interpolation/IDW Interpolation, Processing/Interpolation/TIN Interpolation, Processing/SAGA/Raster Creation/Interpolate or others.

fix tabel formatting
Source Link
Dave X
  • 1.7k
  • 13
  • 26
import numpy as np

x = np.array([(y, x, 1.0) for x in range(5328530,5328560,10) for y in range(4390000,4390100,10)])
x[:,2] = np.random.normal(size=x.shape[0])
np.savetxt("/Users/drf/data/foo.csv",fmt="%8.1f %8.1f %8.5f",x,header="x y z",comments='')
 


x       y       z
44390000.390000000000000000e+06       0 55328530.328530000000000000e+06     0   1.015328864588257662e+0069132
44390010.390010000000000000e+06       0 55328530.328530000000000000e+06      0  -50.628257535238548881e-0196375
44390020.390020000000000000e+06       0 55328530.328530000000000000e+06      0  -40.046038883206812820e-0196426
44390030.390030000000000000e+06       0 55328530.328530000000000000e+06     0   81.817873776115265905e-0190196
44390040.390040000000000000e+06       0 55328530.328530000000000000e+06      0  4.097001571760452432e-010.43301
44390050.390050000000000000e+06       0 55328530.328530000000000000e+06      0  -70.780231463806006609e-0147332
44390060.390060000000000000e+06       0 55328530.328530000000000000e+06     0   10.276611440801514563e+0044058
44390070.390070000000000000e+06       0 55328530.328530000000000000e+06     0   1.487220007430405389e+0024625
44390080.390080000000000000e+06       0 55328530.328530000000000000e+06     0   -80.761006338524375270e-0101709
44390090.390090000000000000e+06       0 55328530.328530000000000000e+06     0   -1.859988973619862984e-0181022
44390000.390000000000000000e+06       0 55328540.328540000000000000e+06     0   -71.427614994399982240e-0248794
44390010.390010000000000000e+06       0 55328540.328540000000000000e+06     0   -91.425023376749808168e-0120569
44390020.390020000000000000e+06       0 55328540.328540000000000000e+06     0   10.323964776987769654e-0108455
44390030.390030000000000000e+06       0 55328540.328540000000000000e+06      0  8.889046410107322993e-011.33575
44390040.390040000000000000e+06       0 55328540.328540000000000000e+06     0   2.653416825844922000e-0141027
44390050.390050000000000000e+06       0 55328540.328540000000000000e+06      0  4.796456869260552480e-011.15869
44390060.390060000000000000e+06       0 55328540.328540000000000000e+06     0   -70.438068196825314837e-0141672
44390070.390070000000000000e+06       0 55328540.328540000000000000e+06     0   31.184221970890085962e-0110926
44390080.390080000000000000e+06       0 55328540.328540000000000000e+06     0   10.391780647464825327e+0022557
44390090.390090000000000000e+06       0 55328540.328540000000000000e+06      0  -70.167399876719116047e-0165360
44390000.390000000000000000e+06       0 55328550.328550000000000000e+06      0  -20.341421481517296233e+0049709
44390010.390010000000000000e+06       0 55328550.328550000000000000e+06     0   30.345464281172759735e-0153986
44390020.390020000000000000e+06       0 55328550.328550000000000000e+06      0  -10.494134402336438017e+0090243
44390030.390030000000000000e+06       0 55328550.328550000000000000e+06     0   20.142616394224636234e-0109379
44390040.390040000000000000e+06       0 55328550.328550000000000000e+06     0   20.857439432942754931e-0116449
44390050.390050000000000000e+06       0 55328550.328550000000000000e+06     0   -30.657708254450416363e-0155429
44390060.390060000000000000e+06       0 55328550.328550000000000000e+06      0  -50.120046389202982384e-0155609
44390070.390070000000000000e+06       0 55328550.328550000000000000e+06      0  4.942802209477887843e-010.78839
44390080.390080000000000000e+06       0 55328550.328550000000000000e+06      0  2-1.181192673092847478e+0076425
44390090.390090000000000000e+06       0 55328550.328550000000000000e+06      0  -71.518000569745769690e-0131797
import numpy as np

x = np.array([(y, x, 1.0) for x in range(5328530,5328560,10) for y in range(4390000,4390100,10)])
x[:,2] = np.random.normal(size=x.shape[0])
np.savetxt("/Users/drf/data/foo.csv",x,header="x y z",comments='')
 


x       y       z
4.390000000000000000e+06        5.328530000000000000e+06        1.015328864588257662e+00
4.390010000000000000e+06        5.328530000000000000e+06        -5.628257535238548881e-01
4.390020000000000000e+06        5.328530000000000000e+06        -4.046038883206812820e-01
4.390030000000000000e+06        5.328530000000000000e+06        8.817873776115265905e-01
4.390040000000000000e+06        5.328530000000000000e+06        4.097001571760452432e-01
4.390050000000000000e+06        5.328530000000000000e+06        -7.780231463806006609e-01
4.390060000000000000e+06        5.328530000000000000e+06        1.276611440801514563e+00
4.390070000000000000e+06        5.328530000000000000e+06        1.487220007430405389e+00
4.390080000000000000e+06        5.328530000000000000e+06        -8.761006338524375270e-01
4.390090000000000000e+06        5.328530000000000000e+06        -1.859988973619862984e-01
4.390000000000000000e+06        5.328540000000000000e+06        -7.427614994399982240e-02
4.390010000000000000e+06        5.328540000000000000e+06        -9.425023376749808168e-01
4.390020000000000000e+06        5.328540000000000000e+06        1.323964776987769654e-01
4.390030000000000000e+06        5.328540000000000000e+06        8.889046410107322993e-01
4.390040000000000000e+06        5.328540000000000000e+06        2.653416825844922000e-01
4.390050000000000000e+06        5.328540000000000000e+06        4.796456869260552480e-01
4.390060000000000000e+06        5.328540000000000000e+06        -7.438068196825314837e-01
4.390070000000000000e+06        5.328540000000000000e+06        3.184221970890085962e-01
4.390080000000000000e+06        5.328540000000000000e+06        1.391780647464825327e+00
4.390090000000000000e+06        5.328540000000000000e+06        -7.167399876719116047e-01
4.390000000000000000e+06        5.328550000000000000e+06        -2.341421481517296233e+00
4.390010000000000000e+06        5.328550000000000000e+06        3.345464281172759735e-01
4.390020000000000000e+06        5.328550000000000000e+06        -1.494134402336438017e+00
4.390030000000000000e+06        5.328550000000000000e+06        2.142616394224636234e-01
4.390040000000000000e+06        5.328550000000000000e+06        2.857439432942754931e-01
4.390050000000000000e+06        5.328550000000000000e+06        -3.657708254450416363e-01
4.390060000000000000e+06        5.328550000000000000e+06        -5.120046389202982384e-01
4.390070000000000000e+06        5.328550000000000000e+06        4.942802209477887843e-01
4.390080000000000000e+06        5.328550000000000000e+06        2.181192673092847478e+00
4.390090000000000000e+06        5.328550000000000000e+06        -7.518000569745769690e-01
import numpy as np

x = np.array([(y, x, 1.0) for x in range(5328530,5328560,10) for y in range(4390000,4390100,10)])
x[:,2] = np.random.normal(size=x.shape[0])
np.savetxt("/Users/drf/data/foo.csv",fmt="%8.1f %8.1f %8.5f",x,header="x y z",comments='')


x y z
4390000.0 5328530.0   1.69132
4390010.0 5328530.0  -0.96375
4390020.0 5328530.0  -0.96426
4390030.0 5328530.0   1.90196
4390040.0 5328530.0  -0.43301
4390050.0 5328530.0  -0.47332
4390060.0 5328530.0   0.44058
4390070.0 5328530.0   1.24625
4390080.0 5328530.0   0.01709
4390090.0 5328530.0   1.81022
4390000.0 5328540.0   1.48794
4390010.0 5328540.0   1.20569
4390020.0 5328540.0   0.08455
4390030.0 5328540.0  -1.33575
4390040.0 5328540.0   2.41027
4390050.0 5328540.0  -1.15869
4390060.0 5328540.0   0.41672
4390070.0 5328540.0   1.10926
4390080.0 5328540.0   0.22557
4390090.0 5328540.0  -0.65360
4390000.0 5328550.0  -0.49709
4390010.0 5328550.0   0.53986
4390020.0 5328550.0  -0.90243
4390030.0 5328550.0   0.09379
4390040.0 5328550.0   0.16449
4390050.0 5328550.0   0.55429
4390060.0 5328550.0  -0.55609
4390070.0 5328550.0  -0.78839
4390080.0 5328550.0  -1.76425
4390090.0 5328550.0  -1.31797
added 80 characters in body
Source Link
Dave X
  • 1.7k
  • 13
  • 26

If your data is on a regular grid, sorted(even with holes/missing data), sorted by y increasing slowestand x (y primary), as from thisthe python code: below, then the data can be imported directly as a raster.

Then itThis data can be read directly from Layer/Add Layer/Add Raster Layer/ Dataset which uses GDALtool.

If your data is a regular grid, sorted with y increasing slowest, as from this python code:

Then it can be read directly from Layer/Add Layer/Add Raster Layer/ Dataset which uses GDAL.

If your data is on a regular grid, (even with holes/missing data), sorted by y and x (y primary), as from the python code below, then the data can be imported directly as a raster.

This data can be read directly from Layer/Add Layer/Add Raster Layer/ Dataset tool.

Source Link
Dave X
  • 1.7k
  • 13
  • 26
Loading