Episode #125 of the Stack Overflow podcast is here. We talk Tilde Club and mechanical keyboards. Listen now
56

Two possible solutions: You can use the "Vector->Research tools->Select by Location" and tick the "Use selected features only" checkbox. If you want to actually export the points which intersect your selected polygon to a new shapefile then "Vector->Geopressing tools->Intersect" and again tick the "Use only selected features" checkbox. The input layer will ...


23

Use Select By Location, have it select all students within the boundaries, then reverse the selection. Ta da, you have a "Not-In" selection! To reverse the selection, use the "Switch Selection" command. This can be accessed from at least two different places in ArcMap. Within the attribute table: Or, from the Table of Contents, right mouse click on a ...


10

You don't need a special function (as "Ray Casting"), everything is in PyQGIS (contains() in PyQGIS Geometry Handling) polygons = [feature for feature in polygons.getFeatures()] points = [feature for feature in points.getFeatures()] for pt in points: point = pt.geometry() # only and not pt.geometry().asPolygon() for pol in polygons: poly ...


10

Yes. Under the Analysis menu select 'Find Locations' and then 'Find Existing Locations'. Select the layer you want to run your analysis over and click 'Add Expression'. The drop-down on the right hand side of the popup window should show some spatial selection options.


10

If you want to select all features that are within 100 m of the selected "buffer" feature you can use next code: layer = iface.activeLayer() feats = [ feat for feat in layer.getFeatures() ] #selected feature fid = 0 geom_buffer = feats[0].geometry().buffer(100, -1) #erasing selected feature in original list del feats[0] new_feats = [feat for feat in ...


9

Select the features that intersect and then switch the selection. One way to switch the selection is to use Select Layer by Attribute with the SWITCH_SELECTION option.


8

Instead of "C:\\temp\M0TASHT\M0TASHT.gdb\sLine" you need to double all your back slashes to escape them i.e. "C:\\temp\\M0TASHT\\M0TASHT.gdb\\sLine" And instead of where_clause = '"ManholeSubtype" = ('"4515" ')' Try where_clause = ' "ManholeSubtype" = ' + " '4515' " Or where_clause = ' ' ' "ManholeSubtype" = 4515 ' ' ' Which will ...


8

While I think you could do with refining your question with a bit more detail (how much of the line has to be within to qualify, how do you want to handle lines coincident with polygon edges, etc... I do have a thought on generally how you might be able to approach this problem. Yes, this would be a relatively elaboarate method to accomplish what should be ...


8

This depends a little on whether the small features are dependent on the larger features: do they actually share a common boundary, or are there small discrepancies along their apparently common edges? ST_Within(a.geom, b.geom): gives you the geometries in b that are fully within a.geom. And it means fully within. ST_Intersects(a.geom, b.geom): this is a ...


8

I was able to get this to work (in 2.18.3), although I confess it took me a couple of tries ;-) You've checked the CRSes so it's not that - if the CRSes didn't match you'd usually get a warning anyway. You need to make sure you put the layers the right way round. This first is the layer you want the selection to come from (buffered circles layer) and the ...


7

I found an example that used the Point geometry, for example: point = arcpy.Point(x, y) point_geom = arcpy.PointGeometry(point) Then you can use that in a Select by Location arcpy.SelectLayerByLocation_management("Layer", "CONTAINS", point_geom)


7

PostGIS has a function that addresses just this centroid problem: use ST_PointOnSurface() to return a point guaranteed to be inside your county, then just find the ST_Intersection() of the county-points and region. Like this: SELECT * FROM counties c, regions r WHERE ST_Intersects(ST_PointOnSurface(c.the_geom), r.the_geom);


7

Sounds like you're using a Reader followed by a SpatialFilter in FME. In that workflow we do have to read everything. Suggest instead you use a FeatureReader transformer to read the big feature class. And route your search area into that transformer as the Initiator. Then ask the FeatureReader to do a spatial envelope search. We'll then use the spatial ...


7

Check to make sure those polygons you're pointing to (the ones that shouldn't have been selected) are not multi-part polygons. If one part of a multi-part feature is intersecting your source (pink) feature, all parts of it (even if others are outside the source feature) will be selected when using Select by Location. If they are multi-part features, and you ...


7

I suggest these steps to Select Lines that Intersect another Point FC only at Line End Points. Export the Line endpoints to a Point featureclass (named Line_endpoints) - "Feature Vertices to Points", select Point type = "END". Select By Location, Line_endpoints with Point_FC, Intersect. You can add a small Search Tolerance if needed (if Points don't match ...


6

One way to achieve this is to first buffer your city polygon and then use the Spatial query plugin with intersect. Adding a "within a distance of" option would be a nice extra for the Spatial query plugin.


6

To do this with python you need to create some variables first so you can call the selection and with the arcpy.CopyFeatures tool copy the selection to a new feature class. # Define output feature class location fc = "C:\Users\Documents\ArcGIS\Default.gdb\Testers" # Define Selection criteria Selection = arcpy.SelectLayerByLocation_management('Points', "...


6

If you read the syntax section of the select by location tool you will see that it takes Feature Layers as inputs. A string which is a path to a shapefile is not a Feature Layer object. If you think about it how can you represent a selection of polygons with nothing more that a full path string to some file? A Feature Layer has this ability, it is called a ...


6

Create a Feature layer and then use Select Layer by location with a polygon of your extent. Example: import arcpy arcpy.env.workspace = r'D:\test.gdb' fc = r'Polygon' fcselectionpolygon = r'selection' arcpy.MakeFeatureLayer_management(in_features=fc, out_layer='fclyr') arcpy.SelectLayerByLocation_management(in_layer='fclyr', overlap_type='INTERSECT', ...


6

The Make Feature Layer tool needs two parameter values, and you are only supplying one. MakeFeatureLayer_management (in_features, out_layer, {where_clause}, {workspace}, {field_info}) Try replacing: citiesLyr = arcpy.MakeFeatureLayer_management(cities) pnrsLyr = arcpy.MakeFeatureLayer_management(pnrs) selection = arcpy.SelectLayerByLocation_management("...


5

ArcMap has a built-in tool for that: Select Layer by Location (Data Management). Just select all features from the Select Layer, then use Select by Location (Data Management) with the overlap type "Intersect" and the selection type "Remove_From_Selection." This will remove from the selection all those that intersect the other layer, and you'll be left with ...


5

I am thinking you could do a spatial join of the points to your buffered polys which will join the attributes of both together, then you can select back the points that have matching ColumnX and ColumnY values.You can do just a Intersect or Identify as well, all three will give you a very similar result to append the attributed from the poly to the point ...


5

The Intersect (Analysis) tool should be able to do the point-in-polygon overlay that you are after quite quickly. I would recommend having both shapefiles on your local disk (or copying them into an in_memory workspace) for best performance.


5

In order to use select layer by location (or attribute), you need to operate on a feature layer. Then you can use SQL to select by FID. You place this in a loop that loops over the number of entries in the attribute table. MakeFeatureLayer can be also used to select by attributes. Just make sure to delete the layer after using it to get ready for the next ...


5

This will take multiple steps: Get a cursor from you selection set public static IFeatureCursor GetSelectedFeatures(IFeatureLayer featureLayer) { if (featureLayer == null) return null; IFeatureSelection fSel = (IFeatureSelection)featureLayer; ISelectionSet selSet = (ISelectionSet)fSel.SelectionSet; ICursor cursor = null; selSet....


5

The Arc Select by location tool does not work so well for buffer analysis if your data is not projected (WGS 1984). It will draw the resulting buffer as a perfect circle shape, instead of a ovular shape by default (Euclidian vs. Geodesic). The circle does not represent distances accuratly because it does not take into account the curvature of the earth, and ...


5

instead using Select by location try to use the Spatial Query core plugin. Go in the plugin menu and activate it if you cannot see it. Spatial query is available in the Vector menu. In the dialog window select your grid layer as source layer and the point layer as the reference layer: and this is the result: I hope this can help you!


5

Split Layers by Attributes check out this python toolbox. Split Layer by Attributes, State Name, being the attribute you want.


5

Here i used generation of a list of paired tuple of OID and Result of select by location operation.Then i created an update cursor to to update a filed named COUNT by the select by layer location result. You need to just create a field in Practice_Stops feature class named COUNT which is a type of short integer.Here inF is the layer will be updated with ...


5

You can use the "Ray Casting" algorithm that I have slightly adapted for using with PyQGIS: def point_in_poly(point,poly): x = point.x() y = point.y() n = len(poly) inside = False p1x,p1y = poly[0] for i in range(n+1): p2x,p2y = poly[i % n] if y > min(p1y,p2y): if y <= max(p1y,p2y): ...


Only top voted, non community-wiki answers of a minimum length are eligible