2

I'm creating a PointGeometry using arcpy:

data_path = "E:/Seafile/Seafile/Meine Bibliothek/02_Paper/02_ArcMap/Data/"
point = arcpy.Point(75.9039059275, 35.6928318018)
ptGeometry = arcpy.PointGeometry(point)
arcpy.CopyFeatures_management(ptGeometry, data_path + "point.shp")

So far, so good. However, if I try to add a spatial reference from a prj. file, it gives me this error RuntimeError: Object: CreateObject cannot create geometry from inputs with this code:

Albers = arcpy.SpatialReference(data_path + "projection.prj")
point = arcpy.Point(75.9039059275, 35.6928318018)
ptGeometry = arcpy.PointGeometry(inputs=point,
 spatial_reference=Albers)

I don't get why this would not work. According to the ESRI website I'm following procedure. I don't necessarily need to use the .prj file if there is another way.
So far, I have tried using the Describe function to get the coordinate system from another file, but that didn't work, too. I'm looking for a way to assign a spatial reference to this PointGeometry. It is probably very easy but I'm lost.

EDIT: The error also occurs if I just add inputs to the code as the parameter name:

ptGeometry = arcpy.PointGeometry(inputs = point)

So maybe the coordinate system is not the problem?

If necessary, this is the content of the prj. file: PROJCS["Albers_Conic_Equal_Area",GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Albers"],PARAMETER["false_easting",0.0],PARAMETER["false_northing",0.0],PARAMETER["central_meridian",87.0],PARAMETER["standard_parallel_1",25.0],PARAMETER["standard_parallel_2",50.0],PARAMETER["latitude_of_origin",37.0],UNIT["Meter",1.0]]

asked Jan 12, 2021 at 16:43
11
  • That is not an Albers coordinate, unless you mean to offset <100 meters from the origin. Commented Jan 12, 2021 at 16:55
  • No, but it should be an Albers with some custom meridians to match my study area better. The proj-string looks like this: "+proj=aea +lat_1=25 +lat_2=50 +lat_0=37 +lon_0=87 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs" Commented Jan 12, 2021 at 16:59
  • 1
    No, I mean you've specified sub-Angstrom precision on meters values that look suspiciously like degrees. Commented Jan 12, 2021 at 17:02
  • 1
    I'm using this path for all my data in this testing phase, so I don't think that there is a typo, but I've added the string to my question. Commented Jan 12, 2021 at 17:21
  • 3
    I might be misremembering, but I don't think you can use keyword arguments when creating geometry objects, despite what the documentation suggests. Try using positional arguments only Commented Jan 12, 2021 at 19:41

1 Answer 1

3

Despite what the documentation suggests (and how Python objects normally work in 99.9% of cases) you can't use keyword arguments when creating geometry objects. Using positional arguments only should solve the problem

answered Jan 13, 2021 at 19:12
1
  • 2
    This issue has been reported and has an internal issue to track it, will be resolved in a future release. Commented Jan 20, 2021 at 3:24

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.