loadthemall
loadthemall copied to clipboard
Unable to load point geometry in CSV files
LoadThemAll loads the CSV files as "attribute-only" data. Currently, the dialog does not allow the user to specify the longitude/latitude fields which represents a point or to indicate a Point field.
Requesting ability to define lon/lat or point fields similar to something like the QGIS "Create a Layer From Delimited Text File" menu shown in two example jpg files.
-
lon_lat_sample.jpg shows "Geometry definition" item with "Point coordinates" option selected
-
point_sample.jpg shows "Geometry definition" item with "Well Known Text" option selected.
Sample csv, sample.csv.txt file is attached with comma delimiter where "lon" field represents longitude or X value and "lat" field represents latitude or Y value. The "Point" field represents the WKT geometry point field constructed from the "lon" and "lat" field. Hoping solution will also be able to recognize tab delimited fields.
Found code that shows how to pick up the "lon" and "lat" field:
# Find each .csv file and load them as vector layers
for fname in glob.glob("*.csv"):
uri = "file:///" + path_to_csv + fname + "?delimiter=%s&crs=epsg:4326&xField=%s&yField=%s" % ("\t", "lon", "lat")
name = fname.replace('.csv', '')
lyr = QgsVectorLayer(uri, name, 'delimitedtext')
QgsMapLayerRegistry.instance().addMapLayer(lyr)
Note to self: https://github.com/qgis/QGIS/blob/a8de679601be931bd356a69f4b1cbb224581339d/src/providers/delimitedtext/qgsdelimitedtextsourceselect.cpp#L107-L219
hello, Do you plan to fix this problem and create a new version of this plugin ? I thank you in advance.
@guilldet, thanks for raising this up.
I've had the plan in the past but nowadays there is no much free time to implement it. If you're able to fund the feature, that would speed things up. :+1: