GIS Data
Loading, exporting, and creating data layers are the operations you’ll use regularly in GIS. Download the Madrid datasets from the datasets page before continuing.
Loading Data
Use GeoPackage files whenever possible. However, data is often provided in other formats like Shapefiles or CSVs.
Unzip the Madrid Neighbourhoods madrid_nbhds.zip folder. Notice that this folder contains a collection of five files. Shapefiles need a bundle of multiple files, which makes them awkward; the file that serves as the entry point is the one ending in .shp.
- It is generally easiest to drag and drop layers into your map view. In this case, you would drag the Shapefile (ending in
.shp) into the map view to open it. - Notice the layer is now displayed and a layer will have been added to your
Layerpanel. - Select the layer, then click the
Remove Layerbutton in theLayerpanel to remove it. - We’ll now re-add the layer using the menu approach so you’re familiar with both methods. Go to the
Layermenu, thenAdd Layer, thenAdd Vector Layer. Set source type asFile, select the browse button next to the source field, then navigate to the file. Then add it to the project.
Practise the basic navigation operations. These tools are in the toolbars at the top of the screen. If you can’t find a tool, go to View → Toolbars and ensure Attributes Toolbar and Selection Toolbar are enabled.
- Toggle layer visibility using the checkbox next to the layer name in the Layers Panel.
- Use
Select Features(yellow rectangle icon) to select a neighbourhood and see it highlighted. - Use
Identify Features(blue circle with “i” icon) to see attribute information for a particular neighbourhood. - Click
Zoom to Selectionto zoom the map to the currently selected feature. This only works with actual selections, not features highlighted viaIdentify Features. - Click
Zoom Fullto return to a view of all features. - Click
Toggle Editing(pencil icon). This lets you delete existing features or add new features. Use with caution! Don’t make any changes for now, just clickToggle Editingagain to exit edit mode.
Saving and exporting data
We don’t want to edit the original dataset, so let’s make a copy and work with that instead:
- Right click the layer in the Layer Panel and select
export->Save Features as - Select the
GeoPackageformat. - Select the browse button next to the
File Namefield, then select a file location on disk and give it a distinctive name such astest_madrid_nbhds. - You can export to the same or to another CRS. Keep it as
EPSG:25830(the standard CRS for Madrid that we set up in the previous module). This will ensure your exported file uses the same CRS as your project. - Check that
Add saved file to mapat the bottom of the window is selected - Select
OK - The file will be saved and will automatically load into your map.
- Remove the original
SHPfile from your Layers Panel since it is no longer needed. This can be done with theRemove Layerbutton.
Save your data in GeoPackage format unless you have a reason not to.
Create copies of important data before editing so you don’t accidentally lose anything. GIS works differently from other software: it is more like a database meaning that edits are persisted to the data source as soon as you exit edit mode.
Loading CSV files
Data sometimes comes as CSV (comma separated values) or similar text formats. If spatial, the geometry is usually stored in columns (like x and y, or easting and northing). CSVs can be opened and edited in spreadsheet software like Excel.
Some CSVs have no geometry at all. You can still add them to your project, but nothing will appear on the map. These are useful when you want to join tabular data to a spatial layer using a shared identifier.
- To load the CSV file we’ll go to the
Layermenu bar,Add Layer, thenAdd Delimited Text Layer. - For
File name, click the browse button and navigate to themadrid_premises.csvfile, then select the CSV file and open it. Hint: If the load window disappears, it might be hiding behind the main application window. - For file format, select CSV. Note that not all CSV files use commas to separate values, in which case you either need to find out which form of delimiter is used, or you can experiment with the settings until the
Sample Datapreview pane looks correct. - Under
Record and Fields Options, check theSample Datapreview at the bottom of the window. Look at the first row: does it contain column names (like “id”, “name”, “easting”) or actual data values? If it contains column names, selectFirst record has field names. In this case, there is a header row, so select that option. The preview should update to show the column names as headers rather than as a data row. - Place a check in the option to
Detect field typesas well asTrim fields. - If a CSV contains point geometry, it will often contain columns such as
xandyoreastingandnorthing(when working with a projected CRS). - In this case, notice that the last two columns listed in the
Sample Datapreview pane are a potential source of Point geometry information. - Under
Geometry Definitionoptions, selectPoint coordinates. Check that theXfield is associated with theeastingcolumn and that theYfield is associated with thenorthingcolumn. - In this case, the geometry coordinates are based on
EPSG:25830, so set the geometry CRS accordingly. - Under layer settings check that
Use spatial indexis selected, this will speed things up! - Select
AddthenClose.
You should now see a Point layer in your Layers panel. The premises should appear as dots scattered across Madrid.
Layer appears in panel but not on map:
- Check that the layer visibility checkbox is ticked
- Drag the layer above any polygon layers that might be obscuring it
- Right-click the layer and select
Zoom to Layerto confirm it loaded correctly
Data appears in the wrong location (near Africa, in the ocean, etc.):
- The CRS wasn’t set correctly. Remove the layer and re-add it, making sure to set
EPSG:25830for the geometry CRS
Sample Data preview looks garbled:
- Try different delimiter settings (comma, semicolon, tab)
- Check the encoding (UTF-8 is most common)
Importing CSVs involves several settings to get right. Convert to GeoPackage once you have it working. Repeat the above steps to export data, this time saving your premises data to another distinctively named GeoPackage.
Creating data
Sometimes you’ll want to create your own data layers. Let’s practise by creating a new LineString GeoPackage.
- Go to
LayerthenCreate Layerand selectNew GeoPackage Layer. Click the browse button (three dots) next toDatabasethen browse to a file location and select a distinctive name such asnew_lines. - For
Geometry typeselectLineString. - For CRS select
EPSG:25830. - Uncheck the option to include
ZandM. - You can create a layer without attributes, but chances are you’ll want some sort of attribute information in your data, so let’s practise adding a new field. Under
New Fieldenter “description” for theNameand select “Text” for theType, then clickAdd to Fields List. - Click
OKto create the new layer.
Now that the layer has been created, it will appear in your Layer panel. Let’s add a few lines.
- Select the layer in the
Layerpanel, then clickToggle Editing(pencil icon) to activate editing mode. - Click
Add Line Feature(green line with star icon). If you don’t see this tool, go toView→Toolbarsand enableSketching Toolbar. Draw a LineString by clicking a few times on the map, then right-click to finish. - It will now give you the option to fill your
descriptionfield. - Select
OK. - Click
Toggle Editingto deactivate editing mode and selectSave.
The new GeoPackage file now contains your lines and can be shared with others or opened in a new project. The same workflow applies for Polygon and Point data.
Challenge
Create a new Point layer to mark three locations in Madrid you’ve visited so far. Your layer should:
- Be saved as a GeoPackage named
visited_sites.gpkg - Use CRS
EPSG:25830 - Have two text attributes:
nameanddescription - Contain at least three points with filled-in attributes
When you’re done, export the attribute table to verify your data saved correctly: right-click the layer → Open Attribute Table.
Layer→Create Layer→New GeoPackage Layer- Browse to location, name it
visited_sites.gpkg - Set Geometry type to
Point, CRS toEPSG:25830 - Add fields:
- Name:
name, Type:Text - Name:
description, Type:Text
- Name:
- Click
OK - Select the layer, click
Toggle Editingto enter edit mode - Click
Add Point Feature, then click on the map to place a point - Fill in the attributes (e.g., name: “Gran Vía / Callao”, description: “Famous shopping street”)
- Repeat for two more points
- Click
Toggle Editingto exit edit mode, save when prompted
Open the attribute table to verify all three records have names and descriptions filled in.