Arcpy - 如何更改空间启用数据框中几何对象的空间参考?
Arcpy - How to change spatial reference of geometry objects in a spatially enabled dataframe?
我正在使用以下代码将数据从 arcgis pro 功能 class 导出到启用空间的数据框中。导出的数据空间参考必须是 4326。
out_coordinate_system = arcpy.SpatialReference(4326)
arcpy.env.addOutputsToMap = False
arcpy.Project_management(fc, fc.name + "_wgs84", out_coordinate_system)
arcpy.env.addOutputsToMap = True
#Create a spatially enabled dataframe from featureclass
sdf = pd.DataFrame.spatial.from_featureclass(fc.name + "_wgs84")
#Cleanup temporary layer created for reprojection
arcpy.Delete_management(fc.name + "_wgs84")
有没有办法避免使用投影工具创建临时 feature_class 并使用 arcpy.geometry 将几何对象重新投影到 sdf 对象的 SHAPE 列中的 SR 4326?
设法使其与 project_as() 函数一起工作,因为存储在 sdf 的 SHAPE 列中的对象具有 arcgis.geometry objects
数据类型。
out_coordinate_system = arcpy.SpatialReference(4326)
sdf = pd.DataFrame.spatial.from_featureclass(fc.name)
sdf.dropna(inplace=True)
sdf['SHAPE'] = sdf['SHAPE'].apply(lambda x: x.project_as(out_coordinate_system))
sdf['SHAPE'].apply(lambda x: type(x))
0 <class 'arcgis.geometry._types.Polygon'>
1 <class 'arcgis.geometry._types.Polygon'>
2 <class 'arcgis.geometry._types.Polygon'>
Name: SHAPE, dtype: object
dir(sdf['SHAPE'][0])
['EWKT', 'JSON', 'WKB', 'WKT', '_HASARCPY', '_HASSHAPELY', '__class__', '__contains__', '__delattr__', '__delitem__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__geo_interface__', '__getattr__', '__getattribute__', '__getitem__', '__getstate__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__iter__', '__le__', '__len__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__setattribute__', '__setitem__', '__setstate__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_ao', '_check_geometry_engine', '_class_attributes', '_from_geojson', '_repr_svg_', '_shoelace_area', '_type', '_wkt', 'angle_distance_to', 'area', 'as_arcpy', 'as_shapely', 'boundary', 'buffer', 'centroid', 'clear', 'clip', 'contains', 'convex_hull', 'coordinates', 'copy', 'crosses', 'cut', 'densify', 'difference', 'disjoint', 'distance_to', 'envelope', 'equals', 'extent', 'first_point', 'from_shapely', 'fromkeys', 'generalize', 'geoextent', 'geometry_type', 'get', 'get_area', 'get_length', 'get_part', 'has_m', 'has_z', 'hull_rectangle', 'intersect', 'is_empty', 'is_multipart', 'is_valid', 'items', 'keys', 'label_point', 'last_point', 'length', 'length3D', 'measure_on_line', 'overlaps', 'part_count', 'point_count', 'point_from_angle_and_distance', 'pop', 'popitem', 'position_along_line', 'project_as', 'query_point_and_distance', 'rotate', 'scale', 'segment_along_line', 'setdefault', 'skew', 'snap_to_line', 'spatial_reference', 'svg', 'symmetric_difference', 'touches', 'translate', 'true_centroid', 'type', 'union', 'update', 'values', 'within']
我正在使用以下代码将数据从 arcgis pro 功能 class 导出到启用空间的数据框中。导出的数据空间参考必须是 4326。
out_coordinate_system = arcpy.SpatialReference(4326)
arcpy.env.addOutputsToMap = False
arcpy.Project_management(fc, fc.name + "_wgs84", out_coordinate_system)
arcpy.env.addOutputsToMap = True
#Create a spatially enabled dataframe from featureclass
sdf = pd.DataFrame.spatial.from_featureclass(fc.name + "_wgs84")
#Cleanup temporary layer created for reprojection
arcpy.Delete_management(fc.name + "_wgs84")
有没有办法避免使用投影工具创建临时 feature_class 并使用 arcpy.geometry 将几何对象重新投影到 sdf 对象的 SHAPE 列中的 SR 4326?
设法使其与 project_as() 函数一起工作,因为存储在 sdf 的 SHAPE 列中的对象具有 arcgis.geometry objects
数据类型。
out_coordinate_system = arcpy.SpatialReference(4326)
sdf = pd.DataFrame.spatial.from_featureclass(fc.name)
sdf.dropna(inplace=True)
sdf['SHAPE'] = sdf['SHAPE'].apply(lambda x: x.project_as(out_coordinate_system))
sdf['SHAPE'].apply(lambda x: type(x))
0 <class 'arcgis.geometry._types.Polygon'>
1 <class 'arcgis.geometry._types.Polygon'>
2 <class 'arcgis.geometry._types.Polygon'>
Name: SHAPE, dtype: object
dir(sdf['SHAPE'][0])
['EWKT', 'JSON', 'WKB', 'WKT', '_HASARCPY', '_HASSHAPELY', '__class__', '__contains__', '__delattr__', '__delitem__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__geo_interface__', '__getattr__', '__getattribute__', '__getitem__', '__getstate__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__iter__', '__le__', '__len__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__setattribute__', '__setitem__', '__setstate__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_ao', '_check_geometry_engine', '_class_attributes', '_from_geojson', '_repr_svg_', '_shoelace_area', '_type', '_wkt', 'angle_distance_to', 'area', 'as_arcpy', 'as_shapely', 'boundary', 'buffer', 'centroid', 'clear', 'clip', 'contains', 'convex_hull', 'coordinates', 'copy', 'crosses', 'cut', 'densify', 'difference', 'disjoint', 'distance_to', 'envelope', 'equals', 'extent', 'first_point', 'from_shapely', 'fromkeys', 'generalize', 'geoextent', 'geometry_type', 'get', 'get_area', 'get_length', 'get_part', 'has_m', 'has_z', 'hull_rectangle', 'intersect', 'is_empty', 'is_multipart', 'is_valid', 'items', 'keys', 'label_point', 'last_point', 'length', 'length3D', 'measure_on_line', 'overlaps', 'part_count', 'point_count', 'point_from_angle_and_distance', 'pop', 'popitem', 'position_along_line', 'project_as', 'query_point_and_distance', 'rotate', 'scale', 'segment_along_line', 'setdefault', 'skew', 'snap_to_line', 'spatial_reference', 'svg', 'symmetric_difference', 'touches', 'translate', 'true_centroid', 'type', 'union', 'update', 'values', 'within']