How can I convert the output png Image coordinate to dxf coordinate? #269
-
I have gone over the approach in #219 which shows how to convert dxf co-ordinates to image co-ordinates. I have been converting dxf to png using the matplotlib backend approach.
Once I have the image, My requirement is the exact opposite of issue #219 i.e getting dxf co-ordinates given its location on the output png. Is something of this sort possible @mbway @mozman Any help would be greatly appreciated. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
the def get_image_to_wcs_transform(ax: plt.Axes, image_size: Tuple[int, int]) -> np.ndarray:
return np.linalg.inv(get_wcs_to_image_transform(ax, image_size)) If you won't have access to the axes (eg if you are reading in the image in a separate script) then you could generate the matrix when you save the image and write the resulting matrix to a file kind of like a world file which is literally just a matrix stored column-major used to georeference images (transform them into some geo coordinate system). |
Beta Was this translation helpful? Give feedback.
-
Thanks @mbway for the (very) quick reply. Will try it out. |
Beta Was this translation helpful? Give feedback.
the
get_wcs_to_image_transform
function produces a matrix which should be invertible, so as a least effort thing you could implement:If you won't have access to the axes (eg if you are reading in the image in a separate script) then you could generate the matrix when you save the image and write the resulting matrix to a file kind of like a world file which is literally just a matrix stored column-major used to georeference images (transform them into some geo coordinate system).
The easiest way to save and load the matrix would be …