I am new to QGIS, but familiar with Python.
I have one .csv file (Towers_US.csv" ) that contains latitude and longitude of mobile towers of United States (US), and a folder (vectors) with shapefiles of grids for the entire map of US (see image below).
I have attempted to write the Python script (see the code below) to take as input the locations and loop each shapefile grid and do select by location (within) for each of the grids and save the outputs as shapefiles in the folder vectors_1.
import glob, os, processing
p_layer = "C:/Users/Miro_Saide/Documents/QGIS/US/Towers_US.csv"
G_layers = "C:/Users/Miro_Saide/Documents/QGIS/US/Files_Qgis/vectors"
output_dir = "C:/Users/Miro_Saide/Documents/QGIS/US/Files_Qgis/vectors/vectors_1"
os.chdir(G_layers)
for fname in glob.glob("*.shp"):
processing.run("native:selectbylocation", {'INPUT':p_layer,'PREDICATE' [6],'INTERSECT':G_layers,'METHOD':0})
I have executed this script but no output is coming. I wonder what could be improved.