Get center coordinates of GDAL Dataset
505962
def get_center(ds, t_srs=None):
    
    gt = ds.GetGeoTransform()
    ds_srs = get_ds_srs(ds)
    #Note: this is center of center pixel, not ul corner of center pixel
    center = [gt[0] + (gt[1] * ds.RasterXSize/2.0), gt[3] + (gt[5] * ds.RasterYSize/2.0)]
    #include t_srs.Validate() and t_srs.Fixup()
    if t_srs is not None and not ds_srs.IsSame(t_srs):
        ct = osr.CoordinateTransformation(ds_srs, t_srs)
        center = list(ct.TransformPoint(*center)[0:2])
    return center
416296
def center(self, axis=1):
        
        if axis == 1:
            return self.map(lambda x: x - mean(x))
        elif axis == 0:
            meanval = self.mean().toarray()
            return self.map(lambda x: x - meanval)
        else:
            raise Exception('Axis must be 0 or 1')
918988
def _compute_centers(self, X, sparse, rs):
        """"""

        # use supplied centers if present
        centers = self._get_user_components('centers')

        # use points taken uniformly from the bounding
        # hyperrectangle
        if (centers is None):
            n_features = X.shape[1]

            if (sparse):
                fxr = range(n_features)
                cols = [X.getcol(i) for i in fxr]

                min_dtype = X.dtype.type(1.0e10)
                sp_min = lambda col: np.minimum(min_dtype, np.min(col.data))
                min_Xs = np.array(map(sp_min, cols))

                max_dtype = X.dtype.type(-1.0e10)
                sp_max = lambda col: np.maximum(max_dtype, np.max(col.data))
                max_Xs = np.array(map(sp_max, cols))
            else:
                min_Xs = X.min(axis=0)
                max_Xs = X.max(axis=0)

            spans = max_Xs - min_Xs
            ctrs_size = (self.n_hidden, n_features)
            centers = min_Xs + spans * rs.uniform(0.0, 1.0, ctrs_size)

        self.components_['centers'] = centers
1230072
def get_element_centroids(self):
        
        centroids = np.vstack((
            np.mean(self.grid['x'], axis=1), np.mean(self.grid['z'], axis=1)
        )).T

        return centroids
775347
def get_coord_box(centre_x, centre_y, distance):
    """Todo: return coordinates inside a circle, rather than a square"""
    return {
        'top_left': (centre_x - distance, centre_y + distance),
        'top_right': (centre_x + distance, centre_y + distance),
        'bottom_left': (centre_x - distance, centre_y - distance),
        'bottom_right': (centre_x + distance, centre_y - distance),
    }
326310
def _get_coordinates_for_dataset_key(self, dsid):
        """"""
        ds_info = self.ids[dsid]
        cids = []

        for cinfo in ds_info.get('coordinates', []):
            if not isinstance(cinfo, dict):
                cinfo = {'name': cinfo}

            cinfo['resolution'] = ds_info['resolution']
            if 'polarization' in ds_info:
                cinfo['polarization'] = ds_info['polarization']
            cid = DatasetID(**cinfo)
            cids.append(self.get_dataset_key(cid))

        return cids
854645
def axes(self):
        """"""
        return tuple(i for i in range(self.domain.ndim)
                     if self.domain.shape[i] != self.range.shape[i])
186008
def image_coordinates(self, point):
        ''''''
        # the dragpos is the top left position in image coordinates
        ret = wx.Point(int(self.dragpos.x + point.x/self.zoom),
                       int(self.dragpos.y + point.y/self.zoom))
        return ret
1332731
def centering_centroid(data, xi, yi, box, nloop=10, toldist=1e-3,
                       maxdist=10.0):
    '''
        
    '''

    # Store original center
    cxy = (xi, yi)
    origin = (xi, yi)
    # initial background
    back = 0.0

    if nloop == 0:
        return xi, yi, 0.0, 0, 'not recentering'

    for i in range(nloop):
        nxy, back = _centering_centroid_loop_xy(data, cxy, box)
        # _logger.debug('new center is %s', ncenter)
        # if we are to far away from the initial point, break
        dst = distance.euclidean(origin, nxy)
        if dst > maxdist:
            msg = 'maximum distance (%5.2f) from origin reached' % maxdist
            return cxy[0], cxy[1], back, 2, msg

        # check convergence
        dst = distance.euclidean(nxy, cxy)
        if dst < toldist:
            return nxy[0], nxy[1], back, 1, 'converged in iteration %i' % i
        else:
            cxy = nxy

    return nxy[0], nxy[1], back, 3, 'not converged in %i iterations' % nloop
48707
function _getRectangleImageCoordinates(startHandle, endHandle) {
  return {
    left: Math.min(startHandle.x, endHandle.x),
    top: Math.min(startHandle.y, endHandle.y),
    width: Math.abs(startHandle.x - endHandle.x),
    height: Math.abs(startHandle.y - endHandle.y),
  };
}
84979
def get_coordinate_system(self):
        
        coordinate_list = ['specimen']
        initial_coordinate = 'specimen'
        for specimen in self.specimens:
            if 'geographic' not in coordinate_list and self.Data[specimen]['zijdblock_geo']:
                coordinate_list.append('geographic')
                initial_coordinate = 'geographic'
            if 'tilt-corrected' not in coordinate_list and self.Data[specimen]['zijdblock_tilt']:
                coordinate_list.append('tilt-corrected')
        return initial_coordinate, coordinate_list
1158965
def _get_coordinates_for_dataset_keys(self, dsids):
        """"""
        coordinates = {}
        for dsid in dsids:
            cids = self._get_coordinates_for_dataset_key(dsid)
            coordinates.setdefault(dsid, []).extend(cids)
        return coordinates
1361570
def center(self):
        

        if np.all(np.isfinite(self.xyz)):
            return np.mean(self.xyz, axis=0)
1158504
function getCenter(points) {
        var center = {x: 0, y: 0};
        for (var i =0; i < points.length; ++i ) {
            center.x += points[i].x;
            center.y += points[i].y;
        }
        center.x /= points.length;
        center.y /= points.length;
        return center;
    }
227743
def _get_x_axis(self):
        """"""
        # 0,0 is top/left top top/left pixel. Actual x/y coord of that pixel are (.5,.5).
        x_centers = np.linspace(.5, self.x_size - .5, self.x_size)
        y_centers = x_centers * 0
        return (self.geotransform[0]
                + self.geotransform[1] * x_centers
                + self.geotransform[2] * y_centers)
1076833
def get_center_of_mass(self):
        
        xsum, ysum, counter = 0., 0., 0
        for stroke in self.get_pointlist():
            for point in stroke:
                xsum += point['x']
                ysum += point['y']
                counter += 1
        return (xsum / counter, ysum / counter)
1125892
def get_center_offset(self):
        
        return (-self.view_rect.centerx + self._half_width,
                -self.view_rect.centery + self._half_height)