All Collections
Guides leveraging external tools
Adding Latitude and Longitude Data to Shapefiles
Adding Latitude and Longitude Data to Shapefiles

How to calculate latitude and longitude columns from shapefile geometry. (Intermediate)

Kat Kim avatar
Written by Kat Kim
Updated over a week ago

Many point shapefiles don’t contain the latitude and longitude data as columns in the attribute table but have their geometry encoded within the shapefile. This guide will show you how to use Quantum GIS, a free GIS desktop app, to calculate and add those columns to your data, making it importable by Fulcrum once converted to CSV format.

Install QGIS

Quantum GIS (QGIS) is a free, open source GIS application for all platforms - super handy for doing work with GIS data. There are versions for Windows, Mac, and Linux available and you can download QGIS here.

Edit your Shapefile

Once you’ve got QGIS running, begin by adding your shapefile to your map by going to Layer → Add vector layer or dragging and dropping the file into the app window.

In my example, I have a dataset of schools in Pinellas County, Florida downloaded from the county GIS website that I’d like to import into my Fulcrum account to seed a set of points into a data collection form to investigate the viability of these schools as hurricane shelters.

There are a number of useful attributes here, but the attribute table doesn’t include latitude/longitude columns. However, we can calculate those from the shapefile geometry. To do that, first toggle editing mode on the layer by right-clicking on it and selecting “Toggle editing”. Then open the layer’s attribute table to add the new columns.

Calculate latitude & longitude

Now select the Field Calculator button on the bottom to add your new field. Select the option to “Create a new field”, add your output field name, pick Decimal as the field type, and a precision of 8 will give you a plenty accurate coordinate. To build the expression for calculating the field, expand the Geometry functions section, then double-click $y to use the Y value as the new field value for each record. Do get longitude, create a new field using the $x value.

If you are using a coordinate system other than EPSG:4326 WGS 84, then you need to convert the X, Y position into EPSG:4326.

For longitude: x(transform(make_point($x,$y),'EPSG:3735','EPSG:4326'))

For latitude: y(transform(make_point($x,$y),'EPSG:3735','EPSG:4326'))

Now save your edits and toggle editing mode off. Your shapefile now contains latitude and longitude columns making it more portable to other tools like Fulcrum.

Did this answer your question?