1

I'm trying to draw polygons with Python. Polygons are parcel of land with their actual coordinates. So far I have tried matplotlib and tkinter but no result. Is there a library where I can get these polygons scaled and vector based? The scale will be subject to change according to the size of the plot. Like 1/50, 1/100 or 1/200. As a result, can I have an architectural drawing with real coordinates?

Some example:

enter image description here

def fDraw(self, x, y):
    x.append(x[0])
    y.append(y[0])

    xs = np.array(x)
    ys = np.array(y)

    plt.plot(xs,ys) 
    plt.show()

    y = [19803.76, 19827.50, 19829.54, 19805.39]
    x = [21065.67, 21063.77, 21079.64, 21081.62]
    VLand.fDraw(x,y)

enter image description here

user3132616
  • 67
  • 1
  • 6
  • You'll just need to set the axes for your plot correctly - right now one is much smaller than the other. – AKX Jan 10 '23 at 09:05
  • but, for example, what is the scale in that picture? the draw always changing when i change the window scale... it must be absolute. – user3132616 Jan 10 '23 at 09:23
  • I would recommend your drawing coordinates to be absolute real world units (e.g. meters) and setting the plot axes to your desired map extents. You can't display something on an absolute scale without knowing the DPI of the monitor it's being shown on, anyway... – AKX Jan 10 '23 at 10:10
  • I think it would be more correct to say it like this, I want it to show the drawing just like the autocad program. Even if I don't know the exact scale, it should be vector based. The coordinates I gave are in ITRF format. – user3132616 Jan 10 '23 at 10:55
  • What you've plotted now is a vector, sure, but again, you just need to make sure the coordinate axes are suitable for what you want to display. Right now Matplotlib is not using a square coordinate system, so you're seeing a very stretched-out shape. – AKX Jan 10 '23 at 12:18

1 Answers1

0

You'll want to call set_aspect('equal') so the plotted chart retains a square aspect ratio:

import matplotlib.pyplot as plt

xs = [21065.67, 21063.77, 21079.64, 21081.62]
ys = [19803.76, 19827.50, 19829.54, 19805.39]

plt.fill(xs, ys, edgecolor="r", fill=False)
plt.gca().set_aspect('equal')
plt.show()

This renders enter image description here which shows the same visual shape as the original screenshot.

AKX
  • 152,115
  • 15
  • 115
  • 172