I downloaded gridded meteorological data as .csv file from the JRC CGMS database for a territory of interest. The file has data for predefined point locations over the territory in a regular-spacing grid. The data are daily and cover a period, say 1 year. So, in the .csv file there is a separate row for each combination of point and date (for example, we have 365 rows for the same point, each with data for particular date; then the next 365 rows for the next point. etc). The data also include geographic coordinates of the points.
I would like to automatically handle such data with the final goal of obtaining, let say, 365 shapefiles, each containing meteorological attributes from the .csv for a single date for all points.
Sample of the data (1 month; 2 points only) can be obtained from this link: https://www.dropbox.com/s/0v5764swgewsdrd/Gridded_AgroMet_Data_Europe_ver2_0_sample2.csv?dl=0
What I tried so far is to open the .csv file in QGIS and export as a point shapefile. This shapefile, however has, for each point, 365 features lying on top of each other. I want a python script to select features based on the 'DAY' attribute end export in new shapefile. And I want this procedure to iterate over all unique values of the attribute 'DAY'. So far my script is just that:
shapefile = iface.activeLayer() selection= shapefile.getFeatures(QgsFeatureRequest().setFilterExpression("\"DAY\"='20150101'")) shapefile.selectByIds([s.id() for s in selection])
How to continue from here? How to export the selection? How to iterate between dates?