I have a map consisting of polygons and a line. I need to a new shapefile of polygons that are to the west of the red line, and are between the northmost and the southmost ends of the line. How can I do it in QGIS?
OK, this might not be the most elegant way to solve this, but it will work, and if you will only do it once you might as well go with this approach.
First of all, create a polygon (the button should be on the left side):
For this example you would have to enter absolutely no details, except for the coordinate system (CRS). Make sure it uses the same one that your other files use. Then you can hit OK, and you will be asked where to save the new shapefile. Save it, and then add it to your project.
Then you start the editing mode for that polygon (and make sure to enable snapping, so the polygon can snap to the endpoints of your line when digitizing, which means you have to check vertex, and then specify a tolerance of something like 5 pixels!):
Then you select both the polygon, and the line. And then you use the following tool from Digitizing Tools, to split both into two separate polyons:
Now you will have two different polygons, and you can discard the one on the right (just select it, and delete it), which leaves you with the area you are interested in (i.e. West of the line):
Then all you have to do is select by location. All the points that fall into that polygons, that is:
And at the very end you will export these to a new shapefile (or whatever vector you are using). You could also invert the selection and just delete all the other points.
PS: Not all the points on the west side have been included in my example, but I hope the approach makes sense; you'd just have to digitize your initial polygon differently.
I know this isn't exactly what you're after, but this is how you can do it in ArcGIS (10.1+) with arcpy.
myPoly =  # polygon container dist = 10000 # east-west distance with arcpy.da.SearchCursor("line",['SHAPE@']) as cursor: for row in cursor: # get new polygon coordinates feature_info = [[ [row.firstPoint.X-dist,row.firstPoint.Y], [row.lastPoint.X-dist,row.lastPoint.Y], [row.lastPoint.X+dist,row.lastPoint.Y], [row.firstPoint.X+dist,row.firstPoint.Y] ]] # create new polygon myPoly.append(arcpy.Polygon(arcpy.Array([arcpy.Point(*coords) for coords in feature_info]))) # persist polygon arcpy.CopyFeatures_management(myPoly,'in_memory\poly')
This creates the polygon you're after (straight east-west from line endpoints). Then, it's a matter of splitting the polygon into the part you want, and selecting the points.