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.")
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_Asdf_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
<SPAN class="keyword token">import</SPAN> sys <SPAN class="keyword token">import</SPAN> warnings <SPAN class="keyword token">if</SPAN> <SPAN class="operator token">not</SPAN> sys<SPAN class="punctuation token">.</SPAN>warnoptions<SPAN class="punctuation token">:</SPAN> warnings<SPAN class="punctuation token">.</SPAN>simplefilter<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"ignore"</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
Les membres connectés peuvent publier, suivre les mises à jour, et plus encore. Nouveau ici ? Inscrivez-vous gratuitement.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.