I would like to generate a numpy array of 200×200 elements in size and put into it a circle centered into 100,100 coordinates, radius 80 and stroke width of 3 pixels. How to do this in python 2.7 without involving file operations? Possibly using geometry or imaging libraries to allow generalisation to other shapes.

# Python – How to write simple geometric shapes into numpy arrays

geometryimagenumpypython

###### Related Question

- Python – How to the Euclidean distance be calculated with NumPy
- Python – How to print the full NumPy array, without truncation
- Python – Sorting arrays in NumPy by column
- Python – How to read a file line-by-line into a list
- Python – How to read CSV data into a record array in NumPy
- Python – How to access the ith column of a NumPy multidimensional array
- Python – Dump a NumPy array into a csv file
- Python – How to write JSON data to a file

## Best Solution

The usual way is to define a coordinate mesh and apply your shape's equations. To do that the easiest way is to use

`numpy.mgrid`

:http://docs.scipy.org/doc/numpy/reference/generated/numpy.mgrid.html