Short answer: In QGIS choose Layer › Add Layer › Add Delimited Text Layer, pick your CSV, and under Geometry Definition choose Point coordinates. Set X field to your longitude column, Y field to your latitude column and Geometry CRS to EPSG:4326 - WGS 84, then click Add. To keep the points, right-click the new layer and choose Export › Save Features As… with the format set to GeoPackage.
This is part 1 of QGIS essentials, a weekly series of short tutorials on the jobs every QGIS user needs. We start with the commonest of all: you’ve been given a spreadsheet of places with a latitude and a longitude for each, and you want them on a map.
Our example is a real file anyone can download: the Environment Agency’s list of its 1,046 rainfall gauges, published as a CSV under the Open Government Licence. It has a column of latitudes, a column of longitudes and, usefully, each gauge’s British National Grid easting and northing too, so we can check our points against the Environment Agency’s own positions. Every step below was run in QGIS 3.40.12 LTR, and the script that repeated it, csv_to_points.py, produced every number on this page.
What you need
- QGIS 3.34 or later. Everything here is built in.
- A CSV of points. Each row is one place, with one column for latitude and one for longitude. To follow along exactly, download the rainfall gauge CSV and save it as
rainfall-stations.csv.
Step 1: check the CSV before you start
Open the file in a text editor or spreadsheet and look at three things.
- There is a header row, so QGIS can name the columns. Ours starts
@id,label,notation,…,lat,long,easting,northing,…. - The coordinates are decimal degrees, such as
52.186277and-1.171327. Places west of Greenwich have a negative longitude, so almost every longitude in England is negative. If yours look like52°11'10.6"N, see degrees, minutes and seconds below. - Which column is which. Latitude runs from -90 to 90 and is the north–south position; in Britain it is around 50 to 59. Longitude is the east–west position; in Britain it is around -8 to 2. Our columns are called
latandlong, which makes it easy. Some files useyandx, orlatitudeandlongitude.
Our file had 1,046 rows and 25 columns. Three rows (gauges 6666LO, 4549 and 4548) have empty lat and long cells. We left them in on purpose to see what QGIS does with them.
Step 2: open Add Delimited Text Layer
Choose Layer › Add Layer › Add Delimited Text Layer…, or press Ctrl+Shift+T. This opens the Data Source Manager on its Delimited Text page. Click the … button next to File name and pick the CSV.
QGIS reads the first rows straight away and shows them under Sample Data, which is your first check that the file has been read properly. The Layer name defaults to the file name; you can change it to something friendlier, such as Rainfall gauges.
Under File Format, leave CSV (comma separated values) selected for a normal CSV. Choose Custom delimiters for files separated by tabs or semicolons. Semicolons are common in files saved by European versions of Excel, where the comma is the decimal separator.
Step 3: tell QGIS which columns hold the coordinates
Open Geometry Definition and set:
| Setting | Value |
|---|---|
| Geometry type | Point coordinates |
| X field | long (your longitude column) |
| Y field | lat (your latitude column) |
| Geometry CRS | EPSG:4326 - WGS 84 |
QGIS often fills in X and Y by itself when the columns have obvious names, but always check them: the next section shows what happens when they’re the wrong way round.
EPSG:4326 is the code for WGS 84 latitude and longitude. It’s the right choice for nearly every CSV of lat/long, including GPS readings, phone exports and web downloads. The CRS here describes the numbers in the file; it doesn’t have to match your project. QGIS reprojects the points on the fly, which is how they sit correctly on the OpenStreetMap basemap in Web Mercator in the map above.
Click Add, then Close. Your points appear as a new layer.
Step 4: check the points landed in the right place
A layer that draws isn’t necessarily right, so take a minute to check it.
Count the features. Right-click the layer and choose Show Feature Count. Ours shows 1,046: every row of the CSV, including the three with no coordinates. Those three load as features with no location. They’re in the attribute table but not on the map. Find them with Select Features by Expression and "lat" IS NULL, and either fix the coordinates in the CSV or delete them.
Look at the extent. Right-click › Zoom to Layer. Ours runs from longitude -5.5685 to 1.7358 and latitude 50.0353 to 55.7654: from a gauge near Land’s End in the west to one near Lowestoft in the east, and from the Lizard in the south to near Berwick-upon-Tweed in the north. That is England, as it should be.
Compare with a second source. Our file also gives each gauge’s British National Grid easting and northing. When the script converted every point to British National Grid and measured the gap, all 1,043 located gauges were within 4 m of the Environment Agency’s position, and the median gap was 2.6 m. The eastings and northings in the file are rounded to the nearest 10 m, which accounts for gaps of a few metres. If your file has a second set of coordinates, an address or a postcode, check a handful of points against it.
The classic mistake: X and Y swapped
X is longitude and Y is latitude. It feels backwards, because we say “lat/long”, but X is the horizontal axis and longitude is the horizontal, east–west position.
We loaded the same file with X = lat and Y = long to see what happens. QGIS gave no warning. All 1,046 points loaded, with an extent of x 50.04 to 55.77 and y -5.57 to 1.74. Every gauge in England had moved to the Indian Ocean, near the Seychelles, because 52° north had become 52° east.
If your points appear somewhere absurd, or in a thin sliver, swapped columns are the first thing to check. Points sitting near 0, 0 in the Gulf of Guinea usually mean the coordinates are missing or were read as zero, and points in the right shape but in the wrong country usually mean the wrong CRS.
Step 5: save the points as a GeoPackage
A delimited text layer isn’t a copy of your data. It’s a live, read-only view of the CSV that QGIS re-reads when it needs to. You can’t edit it, and it gets slow with large files.
To keep the points, right-click the layer and choose Export › Save Features As…:
- Format: GeoPackage
- File name: for example
rainfall-gauges.gpkg - Layer name:
rainfall_gauges - CRS: leave it as EPSG:4326, or pick your project’s CRS, such as EPSG:27700 for British National Grid
Our GeoPackage came to 532 KB and held all 1,046 features. The three without coordinates came across too, still with no location, so remove them first if you don’t want them.
Save to GeoPackage unless someone has asked for a shapefile. A shapefile cuts field names to 10 characters, so catchmentName becomes catchmentN, and it needs several files that must travel together. A GeoPackage is one file with no such limits.
Other ways to do the same thing
Eastings and northings instead of lat/long
If your CSV has British National Grid eastings and northings, use exactly the same dialogue with X field = easting, Y field = northing and Geometry CRS = EPSG:27700 - OSGB36 / British National Grid. Eastings are the X values here too. The same pattern works for any projected system: use the CRS the coordinates were recorded in.
Degrees, minutes and seconds
If the coordinates are written like 52°11'10.6"N, tick DMS coordinates under Geometry Definition. QGIS reads several common styles. Make sure the hemisphere letter or a minus sign is there, or western longitudes will land east of Greenwich.
The Processing tool
Processing › Toolbox › Vector creation › Create points layer from table does the same job in one step and is handy in a model or batch. With X = long, Y = lat and EPSG:4326 it produced 1,046 features, three of them with no geometry: exactly the same result as the dialogue.
Columns read as text
Under Sample Data, each column shows the type QGIS detected. In our file lat and long came in as decimals, easting as a whole number and dateOpened as a date. period, which is nearly always 900 (15 minutes in seconds), came in as text. One gauge with two measures lists it as 900|900, and a single value that isn’t a number makes the whole column text. If a coordinate column ever shows as text, look for a stray value such as n/a, a space or a comma used as the decimal point.
The script
csv_to_points.py runs the whole workflow with the Python that ships with QGIS, without opening the QGIS window. It downloads the CSV, loads it with X = long and Y = lat, checks every point against the Environment Agency’s grid references, repeats the swapped-columns test, saves the GeoPackage, runs the Processing tool and writes a QGIS project. The key line is the layer source, which holds the same settings as the dialogue:
uri = (f"{CSV_PATH.as_uri()}?type=csv&delimiter=,&detectTypes=yes" "&xField=long&yField=lat&crs=EPSG:4326&spatialIndex=yes")layer = QgsVectorLayer(uri, "Rainfall gauges", "delimitedtext")Run it from the folder that holds it:
"C:\Program Files\QGIS 3.40.12\bin\python-qgis-ltr.bat" -u csv_to_points.pyWhere next
- Put a basemap under your points: see the list of XYZ tile URLs for QGIS for OpenStreetMap, Esri World Imagery and others.
- Find more data to map in our free GIS data sources, sorted by country and theme.
- Next week in QGIS essentials: converting latitude and longitude to UTM.
FAQ
Which is X and which is Y, latitude or longitude?
X is longitude and Y is latitude. X is the horizontal, east–west axis, and longitude measures position east or west of Greenwich. If your points appear in the wrong ocean, swap them.
What CRS should I choose for a CSV of latitude and longitude?
EPSG:4326 - WGS 84. It’s the system GPS, phones and almost every web download use. Choose another CRS only if the file says its coordinates are in one, such as EPSG:27700 for British National Grid eastings and northings.
Why do some rows not appear on the map?
Rows with empty or unreadable coordinates load as features with no location. They are in the attribute table but don’t draw. Select them with the expression "lat" IS NULL (using your latitude column’s name) and fix or delete them.
Why can’t I edit my CSV layer?
A delimited text layer is a read-only view of the file. Save it as a GeoPackage with Export › Save Features As… and edit the copy.
Can I load a CSV of addresses or postcodes the same way?
Not directly. Add Delimited Text Layer needs coordinates. Addresses and postcodes have to be geocoded first, which means looking up a coordinate for each one with a geocoding service or a postcode lookup table, then loading the result as shown here.