Get raster value by xy coordinates.

        Args:
            x: X Coordinate.
            y: Y Coordinate.

        Returns:
            raster value, None if the input are invalid.
969164
def get_value_by_xy(self, x, y):
        
        if x < self.xMin or x > self.xMax or y < self.yMin or y > self.yMax:
            return None
            # raise ValueError("The x or y value must be within the Min and Max!")
        else:
            row = self.nRows - int(numpy.ceil((y - self.yMin) / self.dx))
            col = int(numpy.floor((x - self.xMin) / self.dx))
            value = self.data[row][col]
            if value == self.noDataValue:
                return None
            else:
                return value
321901
def x(self):
        '''
        
        '''
        if None not in (self.x_min, self.x_max, self.x_step) and \
                self.x_min != self.x_max:
            x = np.arange(self.x_min, self.x_max+self.x_step-self.y_step*0.1, self.x_step)
        else:
            x = np.array([])
        return x
623444
def rdist(x, y):
    
    result = 0.0
    for i in range(x.shape[0]):
        result += (x[i] - y[i]) ** 2

    return result
131209
def castroData_from_pix_xy(self, xy, colwise=False):
        
        ipix = self._tsmap.xy_pix_to_ipix(xy, colwise)
        return self.castroData_from_ipix(ipix)
370219
public double getInputValue(Axis input, double x, double y)
    {
        final double v;
        switch (input)
        {
            case X:
                v = Math.floor(x - tile.getX());
                break;
            case Y:
                v = Math.floor(y - tile.getY());
                break;
            default:
                throw new LionEngineException(input);
        }
        return v;
    }
1092569
def get_window_from_xy(self, xy):
        """"""
        a_transform = self._get_template_for_given_resolution(res=self.dst_res, return_="meta")["transform"]
        row, col = transform.rowcol(a_transform, xy[0], xy[1])
        ij_containing_xy = None
        for ji, win in enumerate(self.windows):
            (row_start, row_end), (col_start, col_end) = rasterio.windows.toranges(win)
            # print(row, col, row_start, row_end, col_start, col_end)
            if ((col >= col_start) & (col < col_end)) & ((row >= row_start) & (row < row_end)):
                ij_containing_xy = ji
                break
        if ij_containing_xy is None:
            raise ValueError("The given 'xy' value is not contained in any window.")
        return ij_containing_xy
130708
def get_xy_grids(ds, stride=1, getval=False):
    
    gt = ds.GetGeoTransform()
    #stride = stride_m/gt[1]
    pX = np.arange(0, ds.RasterXSize, stride)
    pY = np.arange(0, ds.RasterYSize, stride)
    psamp = np.meshgrid(pX, pY)
    mX, mY = pixelToMap(psamp[0], psamp[1], gt)
    return mX, mY
799553
def pixel(self, x, y, size=None):
        """"""
        if (size is None):
            size = self.sz
        # Have we go to the smallest element?
        if (size <= 3):
            if (_not_diagonal(x, y)):
                return None
            else:
                return (0, 0, 0)
        divisor = size // 3
        if (_not_diagonal(x // divisor, y // divisor)):
            return None
        return self.pixel(x % divisor, y % divisor, divisor)
943963
public Object getValue(int x) {
    if (x >= width())
      throw new IllegalArgumentException("Index out of scope on axis (" + x + " >= " + width() + ")!");

    return m_Min + m_Step*x;
  }
1075268
def check_X_y(X, y):
    
    if len(X) != len(y):
        raise ValueError('Inconsistent input and output data shapes. '\
                         'found X: {} and y: {}'.format(X.shape, y.shape))
906443
private int getSourcePixel(int[] srcImage, int x, int y)
    {
        int x1 = Math.max(0, x);
        x1 = Math.min(width - 1, x1);
        int y1 = Math.max(0, y);
        y1 = Math.min(height - 1, y1);

        return srcImage[x1 + y1 * width];
    }
145847
def getPixelAttrRandom(self, x, y):
        ''
        c = list(attr for attr, rows in self.pixels[y][x].items()
                         for r in rows if attr and attr not in self.hiddenAttrs)
        return random.choice(c) if c else 0
471770
def y(self):
        '''
        
        '''
        if None not in (self.y_min, self.y_max, self.y_step) and \
                self.y_min != self.y_max:
            y = np.arange(self.y_min, self.y_max-self.y_step*0.1, self.y_step)
        else:
            y = np.array([])
        return y
905476
def copysign(x, y, context=None):
    
    return _apply_function_in_current_context(
        BigFloat,
        mpfr.mpfr_copysign,
        (
            BigFloat._implicit_convert(x),
            BigFloat._implicit_convert(y),
        ),
        context,
    )
478726
def xy2rd(self,pos):
        
        if self.ctype1.find('TAN') < 0 or self.ctype2.find('TAN') < 0:
            print('XY2RD only supported for TAN projections.')
            raise TypeError

        if isinstance(pos,N.ndarray):
            # If we are working with an array of positions,
            # point to just X and Y values
            posx = pos[:,0]
            posy = pos[:,1]
        else:
            # Otherwise, we are working with a single X,Y tuple
            posx = pos[0]
            posy = pos[1]

        xi = self.cd11 * (posx - self.crpix1) + self.cd12 * (posy - self.crpix2)
        eta = self.cd21 * (posx - self.crpix1) + self.cd22 * (posy - self.crpix2)

        xi = DEGTORAD(xi)
        eta = DEGTORAD(eta)
        ra0 = DEGTORAD(self.crval1)
        dec0 = DEGTORAD(self.crval2)

        ra = N.arctan((xi / (N.cos(dec0)-eta*N.sin(dec0)))) + ra0
        dec = N.arctan( ((eta*N.cos(dec0)+N.sin(dec0)) /
                (N.sqrt((N.cos(dec0)-eta*N.sin(dec0))**2 + xi**2))) )

        ra = RADTODEG(ra)
        dec = RADTODEG(dec)
        ra = DIVMOD(ra, 360.)

        # Otherwise, just return the RA,Dec tuple.
        return ra,dec
170990
def check_coordinates(co, xy=None):
    
    if isinstance(co, ndarray):
        co = co.tolist()
    if not (isinstance(co[0][0], list) or isinstance(co[0][0], tuple)):
        co = [co]
    if xy is not True:
        co = map(lambda p: asarray(p)[:, ::-1].tolist(), co)
    return co
1281742
def get_xyz_1d(self, xcoord, x, ycoord, y, u, v):
        """"""
        xclose = xcoord.indexes[xcoord.name].get_loc(x, method='nearest')
        yclose = ycoord.indexes[ycoord.name].get_loc(y, method='nearest')
        uval = u[yclose, xclose].values
        vval = v[yclose, xclose].values
        return xcoord[xclose].values, ycoord[yclose].values, uval, vval