code: def latlon2pixel(
      lat, lon, input_raster="", targetsr="", geom_transform=""
  ):
      # type: (object, object, object, object, object) -> object
  
      sourcesr = osr.SpatialReference()
      sourcesr.ImportFromEPSG(4326)
  
      geom = ogr.Geometry(ogr.wkbPoint)
      geom.AddPoint(lon, lat)
  
      if targetsr == "":
          src_raster = gdal.Open(input_raster)
          targetsr = osr.SpatialReference()
          targetsr.ImportFromWkt(src_raster.GetProjectionRef())
      coord_trans = osr.CoordinateTransformation(sourcesr, targetsr)
      if geom_transform == "":
          src_raster = gdal.Open(input_raster)
          transform = src_raster.GetGeoTransform()
      else:
          transform = geom_transform
  
      x_origin = transform[0]
      # print(x_origin)
      y_origin = transform[3]
      # print(y_origin)
      pixel_width = transform[1]
      # print(pixel_width)
      pixel_height = transform[5]
      # print(pixel_height)
      geom.Transform(coord_trans)
      # print(geom.GetPoint())
      x_pix = (geom.GetPoint()[0] - x_origin) / pixel_width
      y_pix = (geom.GetPoint()[1] - y_origin) / pixel_height
  
      return (x_pix, y_pix)
  
imports: from osgeo import gdal, osr, ogr
  import numpy
label_desc: Use image node_id 1 for calling a global function with example usage: latlon2pixel(lat, lon, input_raster, targetsr, geom_transform) and returns: x_pix,  y_pix