Python Forum
Putting many coordinates number inside codes - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Putting many coordinates number inside codes (/thread-10798.html)



Putting many coordinates number inside codes - fyec - Jun-06-2018

Hi everyone,
I have a coordinate list. This ranges from (0,0) to (10,10). Each x and y coordinate increases by 1, this is like

(0,0) (0,1) (0,2) (0,3) ... (0,10)
(1,0) (1,1) (1,2) (1,3) ... (1,10)
.
.
.
(10,0) (10,1) (10,2) (10,3) ... (10,10).

I need to put all these coordinates inside my codes respectively without entering the numbers manually.

My code is supposed to be like that:

"inpNETCDF ='abc.nc'
dataset = Dataset(inpNETCDF, mode='r')
lat_site, lon_site = 0, 0"

"inpNETCDF ='abc.nc'"
dataset = Dataset(inpNETCDF, mode='r')
lat_site, lon_site = 0, 1"
...

Could you help me do that?
Thank you.


RE: Putting many coordinates number inside codes - scidam - Jun-07-2018

I didn't work with netcdf, but you can create desired array of coordinates using list comprehension in Python:
coordinates = [(i, j ) for i in range(11) for j in range(11)]