<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Intersect between multiple points and polygons / gis.content.import_data error &amp;quot;The following rows could not be written to the table: 0&amp;quot; in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/intersect-between-multiple-points-and-polygons-gis/m-p/862778#M4250</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Irrespective of what I try I cannot do an intersect between multiple&amp;nbsp;points&amp;nbsp;and multiple polygons&amp;nbsp;and neither can I save the results from the intersect as a new feature layer collection in AGOL. Here is what I do:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;From my AGOL folder I get a polygon layer "&lt;SPAN style="font-size: 11.0pt;"&gt;cadastre_layer" and a point layer "poi_layer" (both are layer objects).&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My aim is to generate an output FeatureSet object from all intersects between 3 points and 3 polygons, but I cannot seem to do this. All the examples I have found only use a single point as the object to select with. So I tried this:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I create a query object from the point layer:&amp;nbsp;&lt;/P&gt;&lt;P&gt;poi_queryResult = poi_layer.query()&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for poi_geom in poi_queryResult.features:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; cadastre_filter_result = cadastre_layer.query(where='1=1',&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; geometry_filter=filters.intersects(poi_geom.geometry),return_all_records=True)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But then "&lt;SPAN&gt;cadastre_filter_result" merely only contains the result of the last point geometry passed through&amp;nbsp;the loop.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;So I tried to create a geometry object that would contain all three points and also ensures the right projection:&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;output_geometry = geometry.project(geometries = [f.geometry for f in poi_queryResult.features],in_sr = 3857, out_sr =3857,&amp;nbsp; gis = gis)&amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But I cannot pass&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;output_geometry into the geometry_filter (above). I tried several other things, but nothing seems to work.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;So my first question is: how do you do a spatial intersect between several points and several polygons?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The second problem is that I would like to use gis.content.import_data to import the FeatureSet (cast to a DataFrame) so I end up with a new Feature Layer Collection in my home folder. However that does not work either:&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt; gis.content.import_data(df=cadastre_filter_result.df, target_sr =3857,title="Cadaste Spatial Query Results" )&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;There is a new&amp;nbsp;object in my home folder in AGOL, but it contains no data. Indeed the error from executing the above line is:&amp;nbsp;&lt;/SPAN&gt;"The following rows could not be written to the table: 0"&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;But if I try to save the results of the spatial query to a shape file, I get (at least) one polygon (presumably&amp;nbsp;the&amp;nbsp; one that intersected with the last point). So this works:&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;cadastre_filter_result.save(out_name='my_layer',save_location=r'C:\Data')&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;So my second question is, how do I get gis.content.import_data to work on the results of the spatial intersect?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Hugo&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 05 Nov 2018 08:55:23 GMT</pubDate>
    <dc:creator>HugoBouckaert1</dc:creator>
    <dc:date>2018-11-05T08:55:23Z</dc:date>
    <item>
      <title>Intersect between multiple points and polygons / gis.content.import_data error "The following rows could not be written to the table: 0"</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/intersect-between-multiple-points-and-polygons-gis/m-p/862778#M4250</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Irrespective of what I try I cannot do an intersect between multiple&amp;nbsp;points&amp;nbsp;and multiple polygons&amp;nbsp;and neither can I save the results from the intersect as a new feature layer collection in AGOL. Here is what I do:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;From my AGOL folder I get a polygon layer "&lt;SPAN style="font-size: 11.0pt;"&gt;cadastre_layer" and a point layer "poi_layer" (both are layer objects).&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My aim is to generate an output FeatureSet object from all intersects between 3 points and 3 polygons, but I cannot seem to do this. All the examples I have found only use a single point as the object to select with. So I tried this:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I create a query object from the point layer:&amp;nbsp;&lt;/P&gt;&lt;P&gt;poi_queryResult = poi_layer.query()&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for poi_geom in poi_queryResult.features:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; cadastre_filter_result = cadastre_layer.query(where='1=1',&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; geometry_filter=filters.intersects(poi_geom.geometry),return_all_records=True)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But then "&lt;SPAN&gt;cadastre_filter_result" merely only contains the result of the last point geometry passed through&amp;nbsp;the loop.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;So I tried to create a geometry object that would contain all three points and also ensures the right projection:&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;output_geometry = geometry.project(geometries = [f.geometry for f in poi_queryResult.features],in_sr = 3857, out_sr =3857,&amp;nbsp; gis = gis)&amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But I cannot pass&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;output_geometry into the geometry_filter (above). I tried several other things, but nothing seems to work.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;So my first question is: how do you do a spatial intersect between several points and several polygons?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The second problem is that I would like to use gis.content.import_data to import the FeatureSet (cast to a DataFrame) so I end up with a new Feature Layer Collection in my home folder. However that does not work either:&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt; gis.content.import_data(df=cadastre_filter_result.df, target_sr =3857,title="Cadaste Spatial Query Results" )&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;There is a new&amp;nbsp;object in my home folder in AGOL, but it contains no data. Indeed the error from executing the above line is:&amp;nbsp;&lt;/SPAN&gt;"The following rows could not be written to the table: 0"&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;But if I try to save the results of the spatial query to a shape file, I get (at least) one polygon (presumably&amp;nbsp;the&amp;nbsp; one that intersected with the last point). So this works:&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;cadastre_filter_result.save(out_name='my_layer',save_location=r'C:\Data')&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;So my second question is, how do I get gis.content.import_data to work on the results of the spatial intersect?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Hugo&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Nov 2018 08:55:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/intersect-between-multiple-points-and-polygons-gis/m-p/862778#M4250</guid>
      <dc:creator>HugoBouckaert1</dc:creator>
      <dc:date>2018-11-05T08:55:23Z</dc:date>
    </item>
  </channel>
</rss>

