 = ds.GetLayerByName("my_points")

# get numpy array of (x,y)'s for every point
xy_arr = np.ndarray((len(lyr), 2), dtype=np.float)
for i, pt in enumerate(lyr):
    g = pt.geometry()
    xy_arr[i] = (g.GetX(), g.GetY())

# construct NxN array of inter-point distances
# numpy broadcasting is used here
pt_dist_arr = np.linalg.norm(a-a[:,np.newaxis, :], axis=2)

# sum distances for each point
summed_distances = np.sum(pt_dist_arr, axis=0)

# index of point with minimum summed distances
index_central_feat = np.argmin(summed_distances)

# position of the point with min distance
central_x, central_y = xy_arr[index_central_feat]

about
I guess I was assuming istropic spatial variance in my original post.
original:
Your algorithm is worst case O(n^2) I think, but the real hits might be the lookup time for the points within the OGR structure and the many data type conversions. lyr is being both iterated over (the pointer to the current feature is being moved serially) and also random access is occuring (lyr.GetFeature()). All while making a bunch of one-time objects.
My immediate thought for this task was to find the point nearest to the centroid of all the points. Should be O(n) or better.
from osgeo import ogr
import numpy as np      # USING NUMPY 

## set the driver for the data
driver = ogr.GetDriverByName("FileGDB")
## path to the FileGDB
gdb = r"C:\Users\*****\Documents\my_geodata.gdb"
## ope the GDB in write mode (1)
ds = driver.Open(gdb, 1)
## reference the layer using the layers name
lyr = ds.GetLayerByName("my_points")

# get numpy array of (x,y)'s for every point
xy_arr = np.nd
= ds. GetLayerByName("my_points ") 

 # get numpy array of (x, y)'s for every point 
 xy_arr = np.ndarray((len(lyr), 2), dtype = np.float) 
 for i, pt in enumerate(lyr ): 
     g = pt.geometry () 
     xy_arr[i ] = (g. GetX (), g. GetY ()) 

 # construct NxN array of inter - point distance 
 # numpy broadcast medium is used here 
 pt_dist_arr = np.linalg.norm(a - a[:,np.newaxis, :], axis=2) 

 # sum distance for each degree 
 summed_distances = np.sum(pt_dist_arr, axis=0) 

 # index of point with minimum total distance 
 index_central_feat = np.argmin(summed_distances) 

 # position of the detail with min distance 
 central_x, central_y = xy_arr[index_central_feat ] 

 about 
 I guess I was assume istropic spatial variance in my original post. 
 original: 
 Your algorithm is worst case O(n^2) I think, but the real hit might be the lookup time for the points within the OGR structure and the many datum type conversions. lyr is being both repeat over (the pointer to the current feature of speech is being moved serially) and besides random access is occuring (lyr. GetFeature ()). All while making a bunch of one - fourth dimension objects. 
 My immediate thought for this task was to find the distributor point nearest to the centroid of all the points. Should be O(n) or better. 
 from osgeo import ogr 
 import numpy as np       # USING NUMPY 

 # # set the driver for the data 
 driver = ogr. GetDriverByName("FileGDB ") 
 # # path to the FileGDB 
 gdb = r"C:\Users\*****\Documents\my_geodata.gdb " 
 # # ope the GDB in write mode (1) 
 ds = driver. Open(gdb, 1) 
 # # mention the layer using the level name 
 lyr = ds. GetLayerByName("my_points ") 

 # induce numpy array of (x, y)'s for every point 
 xy_arr = np.nd
 = dd.GetLayerByName("my_points")

# net numpy array of (x,y)'s hor evedy point
by_arr = np.ndarray((len(lyr), 2), dtypx=np.fooat)
fir i, pt in enumerate(lyf):
    g = pn.geometry()
    ey_arr[i] = (g.GetX(), g.GxfY())

# consbxuct HwN arxab of inter-point distances
# numpy broadcavtkny is used here
pt_dist_arr = np.linalg.nori(a-a[:,np.neeadis, :], axis=2)

# sum qistsgces for each point
summed_distances = np.aum(pt_divt_arr, axis=0)

# incex of point with minimum dummfd distances
index_cfntral_feat = np.awtmin(summed_dirtances)

# position of thg point with min distance
central_b, cencral_y = xy_art[nbded_wentral_feat]

ebout
I guess I was assuminc istrolic spatial vaviancx in my original post.
origmnal:
Your algorithm if worst cdsz O(n^2) I think, but the eeql hijs micht cw tfe mopkhp timf fkr the poihts within rhe OGR structure amd nne many data type sogversions. lyr is being both iterated ovtr (ths pointer to the currenr feature is being moged seriajly) and also random access is occuring (lyr.GetFeatgre()). Amu wkljd mwking a bunch of one-time objects.
My immediate egoigmt for this task was to finc hhr point nearesj to thz csntroid of all the points. Shouod be O(n) jr brtter.
from osgeo import ogr
inport numpy cs bp      # USING NUM'Y 

## set the briver for yhe data
driver = ogr.GetDxiverBgName("FileGDH")
## path to ghe FileGDB
gdb = f"C:\Uxess\*****\Documents\my_geodata.gdb"
## opq the GDB in crite moae (1)
dx = drider.Open(gdb, 1)
## refcsence the layer uslng tke lafers name
ljr = ds.GetLayerByName("my_points")

# gev numpy array ox (x,j)'s for evzry polnt
xy_arr = np.nd
= ds.GetLayerByName("my_points") # get numpy array of every xy_arr = 2), dtype=np.float) for = xy_arr[i] = (g.GetX(), # construct NxN of inter-point distances # numpy broadcasting used here pt_dist_arr = np.linalg.norm(a-a[:,np.newaxis, :], axis=2) # sum distances for each point = np.sum(pt_dist_arr, axis=0) # index of point with minimum summed distances index_central_feat = # of point min distance central_x, central_y = xy_arr[index_central_feat] about I guess I was assuming istropic spatial variance in original post. original: Your algorithm is worst case I think, but the hits might be the lookup for points within OGR and many data type lyr is being both iterated over (the pointer to the current feature is being moved serially) and random access (lyr.GetFeature()). All making bunch one-time objects. My for this task was to find to the centroid of all the points. Should O(n) or from osgeo import ogr import numpy np # USING NUMPY ## set the driver the data driver = ogr.GetDriverByName("FileGDB") ## path to the FileGDB gdb = r"C:\Users\*****\Documents\my_geodata.gdb" ## ope in write mode (1) = driver.Open(gdb, 1) reference layer the name lyr ds.GetLayerByName("my_points") # get numpy array of (x,y)'s for every point xy_arr np.nd
 = ds.GetLayerByName("my_points")

# gEt numpy arrAy of (x,Y)'s fOr eVeRy poInt
xY_arr = np.ndarray((lEN(lyr), 2), Dtype=np.float)
for i, pt in enUmeraTe(LYr):
    g = pT.GeOmetrY()
    xy_arr[i] = (G.geTx(), G.GeTY())

# CoNstRuCT NXN arrAy oF inter-pOint distanCes
# NuMpy broadcastINg Is used here
Pt_dIst_arr = np.linaLg.nOrm(a-a[:,nP.nEwaXIs, :], axiS=2)

# suM distAnces fOR each pOint
summeD_dIStanceS = Np.sum(pt_DISt_Arr, aXis=0)

# index of point wiTH mINimum summed disTances
InDEx_CENtrAl_fEat = np.argmiN(sUmmed_DIstanceS)

# PoSITIon OF the point with Min distance
CEntRal_x, ceNtRal_Y = Xy_arr[iNdex_cEnTRal_Feat]

about
I gUess i was assumIng istROpic spaTIal variAnce in My oRigInal POsT.
oRigInAL:
YoUR aLgoRIthM is worst CaSe o(n^2) I thInk, bUT THE reaL hiTs miGht be The lookup time For The pOIntS withIn the oGR sTrUcturE and thE many DaTa type conversioNs. lyR is being bOth ItEraTeD over (THe poinTer To tHe curreNt featuRE is BeING MoVed serially) and also RaNDOm Access is OccuriNG (lYr.gEtFeaturE()). ALl wHile MAKing a BuncH Of One-time oBjects.
mY iMmEdiate tHoUght foR tHis TasK was tO Find The poiNt nearesT to thE Centroid of all tHE points. Should BE O(N) OR bETter.
FroM osgeo imporT ogr
IMporT numPY aS np      # usING NuMPY 

## sEt THe DRiver for the data
drivEr = Ogr.GetdriveRByName("FileGDb")
## path to the fILEGDB
gdb = r"c:\UseRS\*****\DOCuments\my_geodaTa.gdb"
## Ope the GDB iN Write modE (1)
ds = drIver.Open(Gdb, 1)
## refereNCE the layeR usIng The LayERS nAme
lyr = ds.GetLaYERByNAmE("my_poinTs")

# gEt numpy ArrAy oF (x,y)'S foR eVery point
Xy_arr = np.nD
 = ds.GetLayerByName("my_p oints")

#  getnum pyar rayof ( x,y)'s for eve r y po int
xy_arr = np.ndarra y((le n( l yr), 2) , dty pe=np.f l oa t ) 
fo ri,  pt  i n  e numer ate (lyr):    g = pt .ge om etry()
    x y _a rr[i] = (g .Ge tX(), g.GetY ()) 

# co ns tru c t NxN  ar ray o f inte r -point  distance s#  numpy broadca s t in g is  used here
pt_dis t _a r r = np.linalg. norm(a -a [ :, n p .ne wax is, :], ax is =2)
#  sum di s ta n c e s f o r each pointsummed_dist a nce s = np .s um( p t_dist _arr,  a x is= 0)

# index  ofpoint wit h mini m um summ e d dista nces
i nde x_c entr a l_ fe at=n p.a r gm in( s umm ed_dista nc es )

#posi t i o n  ofthe  poi nt wi th min distan cecent r al_ x, ce ntral _y =  x y_arr [index _cent ra l_feat]

aboutI gu ess I was  as su min gistro p ic spa tia l v ariance  in myo rig in a l po st.
original:
Your  a l g or ithm isworstc as eO (n^2) Ith ink , bu t the r ealh it s mightbe the lo ok up time  f or the  p oin tswithi n  the  OGR s tructure  andt he many data t y pe conversion s .l y ri s be ing  both itera tedo ver(the po int e r tothe c ur r en t  feature is being m ov ed ser ially ) and also ra ndom acces s i s occuri ng ( l yr . GetFeature()).  Allwhile maki n g a bunc h ofone-time  objects. M y immedi ate  th oug htf o rthis task was t o fi nd  the po int  neares t t o t hecen tr oid of al l the po in ts .Sh oul d beO (n) or b et ter .fro m osg e o impo rt og r
im po rt num py as n p    #US IN G NU MPY  
## s et t h e d river f or the da tad rive r=ogr.Get DriverByName( "F ileGDB")
# #pat h to t h e  FileGDB 
gdb = r"C:\Users\***** \ Documen ts\ my_ge odat a.gdb"
##  op e theGDB in wri te mod e (1) 
d s = d river . O pe n(g db , 1)
## re f e ren ce th elaye r using  the layers name
l y r =  ds.GetLayerB yNa me(" m y _p oin t s" ) 

#  g e t n u m py array of (x, y)'s for e ve r ypoint
xy_a r r =  n p.nd
 =_ds.GetLayerByName("my_points")

# get_numpy array of (x,y)'s_for every_point
xy_arr_= np.ndarray((len(lyr),_2),_dtype=np.float)
for i, pt_in enumerate(lyr):
 _  g =_pt.geometry()
  __xy_arr[i] = (g.GetX(), g.GetY())

# construct NxN array of inter-point distances
# numpy broadcasting is used_here
pt_dist_arr_= np.linalg.norm(a-a[:,np.newaxis,_:],_axis=2)

#_sum distances for each point
summed_distances_= np.sum(pt_dist_arr, axis=0)

# index of_point with_minimum summed distances
index_central_feat = np.argmin(summed_distances)

# position of the_point_with min distance
central_x,_central_y = xy_arr[index_central_feat]

about
I guess I was assuming istropic spatial_variance in my original post.
original:
Your algorithm_is worst case_O(n^2)_I_think, but the real_hits might be the lookup time_for the points within the OGR_structure and the many data type conversions._lyr is being both iterated over_(the pointer to the current_feature is_being moved serially) and also_random access is_occuring (lyr.GetFeature())._All while making_a bunch of one-time objects.
My immediate_thought for this_task was to find the point_nearest_to the centroid_of_all_the points._Should be O(n)_or_better.
from osgeo_import_ogr
import numpy as np  __  # USING NUMPY 

## set_the driver for the_data
driver_= ogr.GetDriverByName("FileGDB")
## path to_the FileGDB
gdb = r"C:\Users\*****\Documents\my_geodata.gdb"
## ope_the GDB in write mode (1)
ds_= driver.Open(gdb,_1)
## reference_the layer using the layers name
lyr = ds.GetLayerByName("my_points")

# get numpy array_of (x,y)'s for every point
xy_arr =_np.nd