-1

I have an array like this (in which the first row correspond to the latitudes and the second to the longitudes of some points):

array([[53.6 , 53.6 , 53.6 , ..., 52.9, 52.9, 52.9],
       [8.7, 8.7, 8.7, ..., 12.1 , 10.0 , 10.7]])

I need to, for each coordinate of lat and lon create an array for the latitudes and another for the longitudes, in which the array has a fixed length (let's say 100) that looks like this:

 array([[53.6, 53.6, 53.6, ..., 53.6, 53.6, 53.6]])
 array([[8.7, 8.7, 8.7, ..., 8.7, 8.7, 8.7]])

I'm not 100% sure of how to achieve this for all the coordinates. I have tried to create an empty array and fill it with as such:

for i in estimate: #(estimate is the name of the first array presented above) 
    lat = np.empty(100)
    lat = lat.fill(point_a[0])

But it's returning

ValueError: Input object to FillWithScalar is not a scalar

Any ideas on how I could do this?

Nocas
  • 357
  • 1
  • 4
  • 14
  • The error is telling you that `point_a[0]` is not a scalar, but you haven't shown the code for `point_a` so it's impossible for anyone to tell you why your code isn't working. – Dan Jul 21 '19 at 23:22
  • That said, what is your end goal? Do you really only care about the first element of each `lat` and `lon` or are you going to want to make such arrays for all the elements? If the latter, `np.meshgrid` might solve this for you in one go. – Dan Jul 21 '19 at 23:23
  • Looks like you want to fill the first array with `point_a[0,0]`, and the second with `point_a[1,0]`. – hpaulj Jul 21 '19 at 23:50

1 Answers1

1

Try this.

for i in estimate.T: #(estimate is the name of the first array presented above) 
    lat = np.tile(i, (10000, 1))
    print(lat)

Tanks to Linuxios.

Dan
  • 45,079
  • 17
  • 88
  • 157
DeepBlue
  • 415
  • 4
  • 9