1

I have been working on a project where I need to create rasters from irregularly spaced point clouds. I am resampling my point clouds to a regular 0.25 cm grid using a nearest neighbor method pyresample. I am using the output array to make a raster using GDAL and my raster is inverted on the y-axis. For a particular dataset I get the extents and apply a geotransfrom using the following parameters:

top_left_x(i.e., xMin)
top_left_y(i.e., yMax)
x_resolution
y_resolution
x_rotation
y_rotation

For a hypothetical dataset, let's say my geo transform parameters are:

top_left_x(i.e., xMin)=223280.0
top_left_y(i.e., yMax)=577877.75
x_resolution=0.25
y_resolution=-0.25
x_rotation=0
y_rotation=0

Using GDAL's GTiff driver I am successfully creating rasters by writing the output array Result to rasterband(1). The problem is the output raster us upside down w.r.t the y axis. If I flip the array result using numpy like: np.flipud(result), the raster is plotted in the correct position. I am at a loss why I need to flip result and want to see if someone can help me understand why.

  • Perhaps because of this line lats = np.fromfunction(lambda y, x: 75 - y, (50, 10)) the sign of the y_resolution is changed and you change it another time by giving it as negative. – user30184 Feb 20 '16 at 14:38
  • If I switch y_resolution to a positive value, the raster will plot in the same reversed y order, with different extents (i.e., the nothing of the top_left_y becomes the nothing of the bottom_right_y pixel) – dubbbdan Feb 22 '16 at 18:26
  • I think it has to do with the fact rows are counted upwards in the negative-positive northing direction while geographical counts upwards in the positive-negative northing direction. – dubbbdan Feb 22 '16 at 19:06

Your Answer

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

Browse other questions tagged or ask your own question.