1

Could you please help with selection problem. I have about 1000 of shapefiles. Each shapefile has points located in a rectangular net. But size of that nets (and as a result number of points) differ in every shapefile. Only thing all shapefiles have in common are distances, net size is 10 meters. Is there any way to select points in chessboard like pattern? Image below there is an example, I need to select all rows (not only first three as in image) in that pattern. enter image description here edit: Second picture with labels and result of selecting odds by: MOD ("ID", 2) = 1 suggested in answer enter image description here

2 Answers 2

2

you could do something with mod, but on the X and Y coordinates.

1) compute relative coordinate

X rel = ( X coordinate of point - X coordinate of upper left point)/distance between sucessive points

Y rel = (  Y coordinate of upper left point - Y coordinate of point )/distance between successive points

2) select the points where (MOD(X_rel,2)+MOD(Y_rel,2))=1

1
  • You could also do X_rel%2 == Y_rel%2 to start with the top left point selected. (I think your method will start with the second point in from the top left, which could obviously just be inverted too to get the top left point as the start.) Dec 4, 2015 at 14:28
1

Not sure I really have the most elegant answers but you could maybe use the extent of each shapefile and divide by 10 (then add 1, I think?) to get the number of points in the horizontal. Same for the vertical. Once you have the dimensions of the grid you could generate a list of the OIDs you are interested in.

E.g say the were 10 points on horizontal and vertical. The OIDs you want are:

1 3 5 7 9 12 14 16 18 20 etc

You could generate a list of these OIDs by creating a list for each diagonal of points you want to select. So first list would be 1, 12, 23, .. (+11 each time). Second list would be 3, 14, 25,... (+11 each time) then string these various lists together and use to select by attribute.

Would take a bit of coding but definitely possible. However, I've not done many complicated selections so there could well be a much easier way. If your shapefiles are all consistent with each other you could create an overarching shapefile like a huge chessboard and then select by intersection with your chessboard shapefile?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.