How do I rewrite to eliminate warning below?
sdf_ = features.SpatialDataFrame(geometry=lines)
print(type(sdf_.spatial))
<class 'arcgis.features.geo._accessor.GeoAccessor'>
/Users/zaifmar/anaconda3/lib/python3.7/site-packages/arcgis/features/_data/geodataset/geodataframe.py:221: UserWarning: SpatialDataFrame has been deprecated. Please switch to the GeoAccessor/GeoSeriesAccessor. warnings.warn("SpatialDataFrame has been deprecated. Please switch to the GeoAccessor/GeoSeriesAccessor.")
Solved! Go to Solution.
Thanks Dan and just added the warning suppression to my code.
Also, here's how I avoided using deprecated SpatialDataFrame class:
sdf_A = GeoAccessor.from_xy(df_A, "x", "y", sr=102100)
sdf_B = GeoAccessor.from_xy(df_B, "x", "y", sr=102100)
lines = []
for i in range(len(sdf_A)):
a = sdf_A.iloc["SHAPE"]
b = sdf_B.iloc["SHAPE"]
line = {
"paths": [
[
[a.coordinates()[0], a.coordinates()[1]],
[b.coordinates()[0], b.coordinates()[1]],
]
],
"spatialReference": a.spatialReference,
}
lines.append(geometry.Polyline(line))
# sdf_lines = features.SpatialDataFrame(geometry=lines)
sdf_AB = sdf_A
sdf_AB["SHAPE_"] = lines
# sdf_AB["SHAPE_"] = sdf_lines["SHAPE"]
sdf_A.spatial.set_geometry("SHAPE_")
sdf_A.spatial.geometry_type
you need to add code to suppress warnings.. with the warning, that the deprecation warning won't last for many arcgis versions, so you should begin to move on.
From here
How to disable python warnings - Stack Overflow
import sys
import warnings
if not sys.warnoptions:
warnings.simplefilter("ignore")
Thanks Dan and just added the warning suppression to my code.
Also, here's how I avoided using deprecated SpatialDataFrame class:
sdf_A = GeoAccessor.from_xy(df_A, "x", "y", sr=102100)
sdf_B = GeoAccessor.from_xy(df_B, "x", "y", sr=102100)
lines = []
for i in range(len(sdf_A)):
a = sdf_A.iloc["SHAPE"]
b = sdf_B.iloc["SHAPE"]
line = {
"paths": [
[
[a.coordinates()[0], a.coordinates()[1]],
[b.coordinates()[0], b.coordinates()[1]],
]
],
"spatialReference": a.spatialReference,
}
lines.append(geometry.Polyline(line))
# sdf_lines = features.SpatialDataFrame(geometry=lines)
sdf_AB = sdf_A
sdf_AB["SHAPE_"] = lines
# sdf_AB["SHAPE_"] = sdf_lines["SHAPE"]
sdf_A.spatial.set_geometry("SHAPE_")
sdf_A.spatial.geometry_type