[Numpy-discussion] Subdividing NumPy array into Regular Grid

Paul Hobson pmhobson at gmail.com
Sun Oct 26 22:10:39 EDT 2014


I think you want np.meshgrid
-paul

On Sun, Oct 26, 2014 at 2:09 AM, Artur Bercik <vbubbly21 at gmail.com> wrote:

> I have a rectangle with the following coordinates:
>
> import numpy as np
>
> ulx,uly = (110, 60) ##uppper left lon, upper left lat
> urx,ury = (120, 60) ##uppper right lon, upper right lat
> lrx, lry = (120, 50) ##lower right lon, lower right lat
> llx, lly = (110, 50) ##lower left lon, lower left lat
>
> I want to divide that single rectangle into 100 regular grids inside that,
> and want to calculate the (ulx, uly), (urx,ury), (lrx, lry), and (llx, lly)
> for each grid separately:
>
> lats = np.linspace(60, 50, 10)
> lons = np.linspace(110, 120, 10)
>
> lats = np.repeat(lats,10).reshape(10,10)
> lons = np.tile(lons,10).reshape(10,10)
>
> I could not imagine what to do then?
>
> Is somebody familiar with such kind of problem?
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20141026/e126dd64/attachment.html>


More information about the NumPy-Discussion mailing list