<html><head></head><body><div class="yahoo-style-wrap" style="font-family:Helvetica Neue, Helvetica, Arial, sans-serif;font-size:13px;"><div dir="ltr" data-setdir="false">I want have some points and I want to find out if they are in a polygon.</div><div dir="ltr" data-setdir="false"><br></div><div dir="ltr" data-setdir="false">I have two shape files one defining a polygon and the other two points here are the csv files for both and the vrt files:</div><div dir="ltr" data-setdir="false"><br></div><div dir="ltr" data-setdir="false">My_Polygon.csv:</div><div dir="ltr" data-setdir="false"><div><div>ID,WKT</div><div>1,"POLYGON ((1 1, 4 1, 4 3, 1 3, 1 1))"</div></div><div><br></div><div dir="ltr" data-setdir="false">My_points.csv:</div><div dir="ltr" data-setdir="false"><div><div>ID X Y</div><div>1 2 2</div><div>2 0 1</div></div><div><br></div><div dir="ltr" data-setdir="false">My_Polygon.vrt:</div><div dir="ltr" data-setdir="false"><div><div><OGRVRTDataSource><span style="white-space: pre-wrap;"> </span></div><div><span style="white-space: pre-wrap;"> </span><OGRVRTLayer name="My_Polygon"></div><div><span style="white-space: pre-wrap;"> </span><SrcDataSource relativeToVRT="1">My_polygon.csv</SrcDataSource></div><div><span style="white-space: pre-wrap;"> </span><GeometryType>wkbPolygon</GeometryType></div><div><span style="white-space: pre-wrap;"> </span><GeometryField encoding="WKT" field="WKT"/></div><div><span style="white-space: pre-wrap;"> </span></OGRVRTLayer></div><div></OGRVRTDataSource></div></div><div><br></div><div dir="ltr" data-setdir="false">My_Points.vrt:</div><div dir="ltr" data-setdir="false"><div><div><OGRVRTDataSource><span style="white-space: pre-wrap;"> </span></div><div> <OGRVRTLayer name="My_Points"></div><div><span style="white-space: pre-wrap;"> </span><SrcDataSource relativeToVRT="1">My_points.csv</SrcDataSource></div><div><span style="white-space: pre-wrap;"> </span><GeometryType>wkbPoint</GeometryType></div><div><span style="white-space: pre-wrap;"> </span><GeometryField encoding="PointFromColumns" x="X" y="Y"/></div><div><span style="white-space: pre-wrap;"> </span></OGRVRTLayer></div><div></OGRVRTDataSource></div></div><div><br></div><div dir="ltr" data-setdir="false">I created the two shape files with:</div><div dir="ltr" data-setdir="false"><span>ogr2ogr -f "ESRI Shapefile" My_Polygon.shp My_Polygon.vrt </span><br></div><div dir="ltr" data-setdir="false"><span><span>ogr2ogr -f "ESRI Shapefile" My_Points.shp My_Points.vrt </span><br></span></div><div dir="ltr" data-setdir="false"><span><span><br></span></span></div><div dir="ltr" data-setdir="false"><span><span>If I use the following org2org command I can select the polygon that has one of the points and it works fine:</span></span></div><div dir="ltr" data-setdir="false"><span><span><br></span></span></div><div dir="ltr" data-setdir="false"><span><span><span>ogr2ogr -f "ESRI Shapefile" selection.shp My_Polygon.shp -dialect sqlite -sql "SELECT polygon.Geometry, polygon.id FROM My_Polygon polygon, 'My_Points.shp'.My_Points point WHERE ST_Contains(polygon.geometry, point.geometry)"</span><br></span></span></div><div dir="ltr" data-setdir="false"><span><span><span><br></span></span></span></div><div dir="ltr" data-setdir="false"><span><span><span>But I want an org2org command that will select which points are in the polygon and can't seem to to do it. I tried:</span></span></span></div><div dir="ltr" data-setdir="false"><span><span><span><br></span></span></span></div><div dir="ltr" data-setdir="false"><span><span><span><span>ogr2ogr -f "ESRI Shapefile" selectpts.shp My_Points.shp -dialect sqlite -sql "SELECT point.Geometry, point.id FROM My_Points, 'My_Polygon.shp'.My_Polygon polygon WHERE ST_Contains(point.Geometry,polygon.geometry)"</span><br></span></span></span></div><div dir="ltr" data-setdir="false"><span><span><span><span><br></span></span></span></span></div><div dir="ltr" data-setdir="false"><span><span><span><span>But it gets an error:</span></span></span></span></div><div dir="ltr" data-setdir="false"><span><span><span><div><div>ERROR 1: In ExecuteSQL(): sqlite3_prepare_v2(SELECT point.Geometry, point.id FROM My_Points, "_OGR_1" polygon WHERE ST_Contains(point.Geometry,polygon.geometry)):</div><div> no such column: point.Geometry</div></div><div><br></div><div dir="ltr" data-setdir="false">Can anyone tell me the correct org2org command to select the points within the polygon? Thanks,</div></span></span></span></div><br></div><br></div><br></div><br></div></div></body></html>