Skip to main content
added 70 characters in body
Source Link

You are assigning lat to X, whileRemember that latitude is actually the Y axis, so if you are entering the coordinates, it should be long, lat not lat, long. You should also create a weight field for the feature, not for the geometry.

This is a working example:

import arcpy

lats = [0, 1, 2]
longs = [1, 3, 4]
wts = [1, 3, 5000]

pointGeoms = []
feature_class = arcpy.CreateFeatureclass_management(
    "in_memory", "tempfc", "POINT")[0]
arcpy.AddField_management(feature_class, "weight", "LONG")

with arcpy.da.InsertCursor(feature_class, ["weight", "SHAPE@XY"]) as cursor:
    for i in range(len(longs)):
        cursor.insertRow([wts[i], (longs[i], lats[i])])
try:
    arcpy.MeanCenter_stats(feature_class, 'c:\\temp\\mean.shp', "weight", "#", "#")

except:
    # If an error occurred when running the tool, print out the error message.
    print(arcpy.GetMessages())

You are assigning lat to X, while latitude is actually the Y. You should also create a field for the feature, not for the geometry.

This is a working example:

import arcpy

lats = [0, 1, 2]
longs = [1, 3, 4]
wts = [1, 3, 5000]

pointGeoms = []
feature_class = arcpy.CreateFeatureclass_management(
    "in_memory", "tempfc", "POINT")[0]
arcpy.AddField_management(feature_class, "weight", "LONG")

with arcpy.da.InsertCursor(feature_class, ["weight", "SHAPE@XY"]) as cursor:
    for i in range(len(longs)):
        cursor.insertRow([wts[i], (longs[i], lats[i])])
try:
    arcpy.MeanCenter_stats(feature_class, 'c:\\temp\\mean.shp', "weight", "#", "#")

except:
    # If an error occurred when running the tool, print out the error message.
    print(arcpy.GetMessages())

Remember that latitude is actually the Y axis, so if you are entering the coordinates, it should be long, lat not lat, long. You should also create a weight field for the feature, not for the geometry.

This is a working example:

import arcpy

lats = [0, 1, 2]
longs = [1, 3, 4]
wts = [1, 3, 5000]

pointGeoms = []
feature_class = arcpy.CreateFeatureclass_management(
    "in_memory", "tempfc", "POINT")[0]
arcpy.AddField_management(feature_class, "weight", "LONG")

with arcpy.da.InsertCursor(feature_class, ["weight", "SHAPE@XY"]) as cursor:
    for i in range(len(longs)):
        cursor.insertRow([wts[i], (longs[i], lats[i])])
try:
    arcpy.MeanCenter_stats(feature_class, 'c:\\temp\\mean.shp', "weight", "#", "#")

except:
    # If an error occurred when running the tool, print out the error message.
    print(arcpy.GetMessages())
Source Link

You are assigning lat to X, while latitude is actually the Y. You should also create a field for the feature, not for the geometry.

This is a working example:

import arcpy

lats = [0, 1, 2]
longs = [1, 3, 4]
wts = [1, 3, 5000]

pointGeoms = []
feature_class = arcpy.CreateFeatureclass_management(
    "in_memory", "tempfc", "POINT")[0]
arcpy.AddField_management(feature_class, "weight", "LONG")

with arcpy.da.InsertCursor(feature_class, ["weight", "SHAPE@XY"]) as cursor:
    for i in range(len(longs)):
        cursor.insertRow([wts[i], (longs[i], lats[i])])
try:
    arcpy.MeanCenter_stats(feature_class, 'c:\\temp\\mean.shp', "weight", "#", "#")

except:
    # If an error occurred when running the tool, print out the error message.
    print(arcpy.GetMessages())