0

I've been doing some image processing in OpenCV. I have a numpy array which has x1,y1 and x2,y2 coordinates as raster cell positions (so not spatially referenced). I need these coordinates marked off on a raster image, which is spatially referenced in QGIS. Is there a way to plot vector points to raster cell positions?

So to recap I have:

  • a raster image I can project properly in a map document
  • raster cell coordinates that don't have spatial information

and I want to plot vector points over the raster cell coordinates, not geographic coordinates.

2
  • Would it work if you just remove the georeferencing from the image with gdal_edit? Or by making a copy without georeferencing with GeoTIFF creation option profile=baseline? Then the image would have a default geotransform in QGIS, that is 1 unit pixel size and origin at 0,0.
    – user30184
    Commented Apr 20, 2021 at 11:24
  • I think you need to copy the Numpy raster to a new dataset in GDAL and set up a Geotransform. Then you can use the transform to go from pixel coordinates to map coordinates. You need the location of the top left point as origin and the vertical and horizontal spacings.
    – wingnut
    Commented Apr 20, 2021 at 16:22

1 Answer 1

0

I think a solution would be to georeference your opencv output before import in QGIS. Transforming the coordinates to your georefenced coordinate system.

I think a way to do it would be to export your georefenced raster in tiff with world file and then take the parameter of your worldfile to process your data with numpy. This way it could be esay and reproducible.

The structure of world file is described in wikipedia : (lien)[https://fr.m.wikipedia.org/wiki/World_file]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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