'Generating all points withing polygon/polyline at a certain interval

I am a beginner in python and a have a question. It is difficult for me to solve this problem by myself because I do not know how to use the right keywords when I Google my problem.

I need all the x- and y-coordinates with a interval of 500 meters that fit inside a polygon/polyline.

For example I want to generate a csv file that looks like this:

x, y,
10000, 30000
10500, 30000
11000, 30000
11500, 30000
12000, 30000
10000, 30500
10000, 31000
10000, 32000
10000, 32500

So It makes a kind of "grid" (maybe this is the wrong word) that fit inside the (polygon/polyline). I want to use these coordinates so I can do calculations on each point (x,y) inside my polygon.

Does anyone has an idea how to make this .csv file? And maybe knows a better word for the "grid" of x,y coordinates that I am trying to make.

Greetings,

Simon



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source