Use pixel centers when appropriate.
        See documentation for the GDAL function GetGeoTransform for details.
511776
def raster_to_projection_coords(self, pixel_x, pixel_y):
        
        h_px_py = np.array([1, pixel_x, pixel_y])
        gt = np.array([[1, 0, 0], self.geotransform[0:3], self.geotransform[3:6]])
        arr = np.inner(gt, h_px_py)
        return arr[2], arr[1]
1209967
function(moPixel) {
        var size = this.map.getSize();
        var lon = this.getLongitudeFromMapObjectLonLat(this.mapObject.center);
        var lat = this.getLatitudeFromMapObjectLonLat(this.mapObject.center);
        var res = this.map.getResolution();

        var delta_x = moPixel.x - (size.w / 2);
        var delta_y = moPixel.y - (size.h / 2);
    
        var lonlat = new OpenLayers.LonLat(
            lon + delta_x * res,
            lat - delta_y * res
        ); 

        if (this.wrapDateLine) {
            lonlat = lonlat.wrapDateLine(this.maxExtent);
        }
        return this.getMapObjectLonLatFromLonLat(lonlat.lon, lonlat.lat);
    }
652576
def pixel_coord(self):
        
        return self.get_pixel_coordinates(self.reading.pix_coord, self.reading.get_ccd_num())
603542
function(pixels, data) {
    const pixel = pixels[0];
    const value = vgi(pixel);
    summarize(value, data.counts);
    if (value >= data.threshold) {
      pixel[0] = 0;
      pixel[1] = 255;
      pixel[2] = 0;
      pixel[3] = 128;
    } else {
      pixel[3] = 0;
    }
    return pixel;
  }
49187
@Override
	public Matrix4d getGeometicCenterTransformation() {
		run();

		Matrix4d geometricCentered = new Matrix4d(reverseTransformationMatrix);
		geometricCentered.setTranslation(new Vector3d(getGeometricCenter()));

		return geometricCentered;
	}
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)
704086
def to_raster(self, vector):
        """"""
        return transform(vector.get_shape(vector.crs), vector.crs, self.crs, dst_affine=~self.affine)
1119568
function () {
        // Rect before any transform
        var rawRect = this.getBoundingRect();
        var cx = rawRect.x + rawRect.width / 2;
        var cy = rawRect.y + rawRect.height / 2;

        return [cx, cy];
    }
1033086
def center_image(self, no_reset=True):
        
        try:
            xy_mn, xy_mx = self.get_limits()
            data_x = float(xy_mn[0] + xy_mx[0]) / 2.0
            data_y = float(xy_mn[1] + xy_mx[1]) / 2.0

        except ImageViewNoDataError:
            # No data, so try to get center of any plotted objects
            canvas = self.get_canvas()
            try:
                data_x, data_y = canvas.get_center_pt()[:2]

            except Exception as e:
                self.logger.error("Can't compute center point: %s" % (str(e)))
                return

        self.panset_xy(data_x, data_y, no_reset=no_reset)

        if self.t_['autocenter'] == 'once':
            self.t_.set(autocenter='off')
1256161
def get_geo_info(filename, band=1):
    ''' 
    '''
    sourceds = gdal.Open(filename, GA_ReadOnly)
    ndv = sourceds.GetRasterBand(band).GetNoDataValue()
    xsize = sourceds.RasterXSize
    ysize = sourceds.RasterYSize
    geot = sourceds.GetGeoTransform()
    projection = osr.SpatialReference()
    projection.ImportFromWkt(sourceds.GetProjectionRef())
    datatype = sourceds.GetRasterBand(band).DataType
    datatype = gdal.GetDataTypeName(datatype)
    return ndv, xsize, ysize, geot, projection, datatype
877623
def geo(self):
        
        out = dict(zip(['xmin', 'xres', 'rotation_x', 'ymax', 'rotation_y', 'yres'],
                       self.raster.GetGeoTransform()))
        
        # note: yres is negative!
        out['xmax'] = out['xmin'] + out['xres'] * self.cols
        out['ymin'] = out['ymax'] + out['yres'] * self.rows
        return out
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)
596240
def _print_geotiff(self):
        
        if self.data is None:
            return "corrupt"
        in_mem_name = '/vsimem/geo.tif'
        gdal.FileFromMemBuffer(in_mem_name, self.raw_data)
        gtif = gdal.Open(in_mem_name)

        # Report projection
        proj_ref = gtif.GetProjectionRef()
        sref = osr.SpatialReference()
        sref.ImportFromWkt(proj_ref)
        psz_pretty_wkt = sref.ExportToPrettyWkt(False)

        # report geotransform
        geo_transform = gtif.GetGeoTransform(can_return_null=True)
        fmt = ('Origin = ({origin_x:.15f},{origin_y:.15f})\n'
               'Pixel Size = ({pixel_x:.15f},{pixel_y:.15f})')
        geotransform_str = fmt.format(origin_x=geo_transform[0],
                                      origin_y=geo_transform[3],
                                      pixel_x=geo_transform[1],
                                      pixel_y=geo_transform[5])

        # setup projected to lat/long transform if appropriate
        if proj_ref is not None and len(proj_ref) > 0:
            hProj = osr.SpatialReference(proj_ref)
            if hProj is not None:
                hLatLong = hProj.CloneGeogCS()

            if hLatLong is not None:
                gdal.PushErrorHandler('CPLQuietErrorHandler')
                hTransform = osr.CoordinateTransformation(hProj, hLatLong)
                gdal.PopErrorHandler()
                msg = 'Unable to load PROJ.4 library'

        # report corners
        uleft = self.GDALInfoReportCorner(gtif, hTransform, "Upper Left", 0, 0)
        lleft = self.GDALInfoReportCorner(gtif, hTransform, "Lower Left",
                                          0, gtif.RasterYSize)
        uright = self.GDALInfoReportCorner(gtif, hTransform, "Upper Right",
                                           gtif.RasterXSize, 0)
        lright = self.GDALInfoReportCorner(gtif, hTransform, "Lower Right",
                                           gtif.RasterXSize, gtif.RasterYSize)
        center = self.GDALInfoReportCorner(gtif, hTransform, "Center",
                                           gtif.RasterXSize / 2.0,
                                           gtif.RasterYSize / 2.0)

        gdal.Unlink(in_mem_name)

        fmt = ("Coordinate System =\n"
               "{coordinate_system}\n"
               "{geotransform}\n"
               "Corner Coordinates:\n"
               "{upper_left}\n"
               "{lower_left}\n"
               "{upper_right}\n"
               "{lower_right}\n"
               "{center}")
        msg = fmt.format(coordinate_system=self._indent(psz_pretty_wkt),
                         geotransform=geotransform_str,
                         upper_left=uleft, upper_right=uright,
                         lower_left=lleft, lower_right=lright, center=center)
        return msg
489967
function (pixel, paneCoordinates) {
		return this.translate(pixel - (paneCoordinates ? 0 : this.pos), true, !this.horiz, null, true);
	}
847099
public static Point getPixelRelative(LatLong latLong, long mapSize, Point origin) {
        return getPixelRelative(latLong, mapSize, origin.x, origin.y);
    }
1150050
def apply_xy_shift(ds, dx, dy, createcopy=True):
    
    print("X shift: ", dx)
    print("Y shift: ", dy)
   
    #Update geotransform
    gt_orig = ds.GetGeoTransform()
    gt_shift = np.copy(gt_orig)
    gt_shift[0] += dx 
    gt_shift[3] += dy

    print("Original geotransform:", gt_orig)
    print("Updated geotransform:", gt_shift)

    #Update ds Geotransform
    if createcopy:
        ds_align = iolib.mem_drv.CreateCopy('', ds, 0)
    else:
        #Update in place, assume ds is opened as GA_Update
        ds_align = ds
    ds_align.SetGeoTransform(gt_shift)
    return ds_align
692898
def pixel(self, coord_x, coord_y):
        # type: (int, int) -> Pixel
        

        try:
            return self.pixels[coord_y][coord_x]  # type: ignore
        except IndexError:
            raise ScreenShotError(
                "Pixel location ({}, {}) is out of range.".format(coord_x, coord_y)
            )