I am now wondering if it is possible to modify the above call to choose a specific polygon with gmtselect. I went through the gmtselect man page and did not get how to select a polygon based on its name (“ChooseMe” in the 6th column called “names”), so, using the -e option. I tried the following without success:
Thanks Esteban for the idea, unfortunately it did not work, grdmask says:
grdmask [ERROR]: Without -S, we expect to read polygons but none found
it seems to me that the “ChooseMe” polygon is not being identified by the -e option, so it did not select that polygon. I have the impression that I am misusing or misunderstanding the purpose of the -e flag (or its combination with the -a flag). I thought the problem was the shapefile itself, but this gmtseslect call works as expected (ie. all points falling within/intersecting the whole polygon are selected):
Many thanks for all the answers, I just found that @Esteban82 and @mkononets were right, “ChooseMe” is in the header because a shp-to-gmt conversion with ogr2ogr showed me that. So, the -e flag does not apply here as pointed by @Esteban82. Not sure if a specific polygon can be selected with the -a flag as I expected, though.
cool, it works! I had problems with -a at some point before. Just as you wrote above, empty output or nothing plotted when I called gmt text and tried to populate text strings on the fly using -a. Now seems working totally fine.
Thanks @Esteban82 “muchas gracias genio”, that one did the trick. In case someone else is trying something similar, I got it working first with the good ogr2ogr like this:
ogr2ogr -f "ESRI Shapefile" selected.shp poi.shp -dialect sqlite -sql "select point.geometry from poi point, 'pol.shp'.pol polygon where st_intersects(poi.geometry, pol.geometry) and pol.names like 'ChooseMe'"