I have a filename with the columns: lon, lat, val1, val2 etc. and I want to join it with a grid shapefile in WGS84. I use the following command but I get an error in ST_PointFromText
ogr2ogr -sql "SELECT a.*, b.* FROM '$Grid_shapefile".shp"'.$Grid_shapefile AS a LEFT JOIN '$filename".csv"'.$filename AS b ON ST_Within(ST_PointFromText('POINT('lon' 'lat')', 4326), a.geometry)" $filename"gridded.shp" $Grid_shapefile".shp"
I tried also this
ogr2ogr -sql "SELECT a.*, b.* FROM '$Grid_shapefile".shp"'.$Grid_shapefile AS a LEFT JOIN '$filename".csv"'.$filename AS b ON ST_Within(ST_PointFromText('POINT(' || b.lon || ' ' || b.lat || ')', 4326), a.geometry)" $filename"gridded.shp" $Grid_shapefile".shp"
but I always get error
ERROR 1: SQL Expression Parsing Error: syntax error, unexpected identifier, expecting ')'. Occurred around :
b ON ST_Within(ST_PointFromText('POINT('lon' 'lat')', 4326), a.geometry)
||
) and float-string formatting (orST_Point
)