Created
August 24, 2021 09:35
-
-
Save ThomasG77/1aa1bf66d847be043a246df8bf74793e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import glob | |
import os | |
from urllib.parse import quote | |
# Define path to directory of your csv files | |
path_to_csv = "your_path" | |
x_field = '經度' # longitude | |
y_field = '緯度' # latitude | |
# Set current directory to path of csv files | |
os.chdir(path_to_csv) | |
for fname in glob.glob("*.csv"): | |
uri = "file:///" + path_to_csv + quote(fname) + "?delimiter=%s&crs=epsg:4326&xField=%s&yField=%s" % (",", quote(x_field), quote(y_field)) | |
name = fname.replace('.csv', '') | |
lyr = QgsVectorLayer(uri, name, 'delimitedtext') | |
QgsProject.instance().addMapLayer(lyr) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ID | OccurrenceUUID | 經度 | 緯度 | |
---|---|---|---|---|
1 | 001 | 18.78 | 89.7 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment