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]]
-
That is not an Albers coordinate, unless you mean to offset <100 meters from the origin.Vince– Vince2021年01月12日 16:55:12 +00:00Commented 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"Florian Mlehliv– Florian Mlehliv2021年01月12日 16:59:25 +00:00Commented Jan 12, 2021 at 16:59
-
1No, I mean you've specified sub-Angstrom precision on meters values that look suspiciously like degrees.Vince– Vince2021年01月12日 17:02:26 +00:00Commented Jan 12, 2021 at 17:02
-
1I'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.Florian Mlehliv– Florian Mlehliv2021年01月12日 17:21:28 +00:00Commented Jan 12, 2021 at 17:21
-
3I 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 onlymikewatt– mikewatt2021年01月12日 19:41:08 +00:00Commented Jan 12, 2021 at 19:41
1 Answer 1
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
-
2This issue has been reported and has an internal issue to track it, will be resolved in a future release.scw– scw2021年01月20日 03:24:02 +00:00Commented Jan 20, 2021 at 3:24
Explore related questions
See similar questions with these tags.