Skip to content
← Back to QGIS from first project to capstone
QGIS · Part 05 of 20Beginner· 8 min readSources

QGIS Data Capture: Google Earth, Google Maps, Bing, OpenStreetMap and Format Conversion

Collect vector data from Google Earth and OpenStreetMap, use web basemaps for reference, and convert between Shapefile, KML, GML and GeoJSON.

Where vector data can come from

SourceHow you get itNotes
Your own digitizingTrace on imagery in QGISYou own the result, if the imagery licence allows tracing
Google Earth ProDraw placemarks, paths and polygons, then save as KMLFeatures you draw are your own data
Google My MapsDraw online, export as KMLGood for sharing with field teams
OpenStreetMapDownload with QuickOSM or OverpassOpen licence (ODbL). Credit OpenStreetMap contributors
Bing aerial imageryView as a basemap, trace for OSMMicrosoft allows tracing Bing imagery to contribute to OSM, and not for other uses

1. Add web basemaps

QuickMapServices

  1. Plugins > Manage and Install Plugins, search QuickMapServices, and install it.
  2. Open Web > QuickMapServices > Settings > More Services, and click Get contributed pack.
  3. Return to Web > QuickMapServices and choose OSM > OSM Standard. More basemaps appear in the list.
QuickMapServices menu with the basemap list
Figure 5.1. QuickMapServices menu with the basemap list

Add a tile layer yourself (XYZ Tiles)

  1. Open the Browser panel, right-click XYZ Tiles > New Connection.
  2. Name: OpenStreetMap. URL: https://tile.openstreetmap.org/{z}/{x}/{y}.png.
  3. Double-click the new entry to add it to the map.

Use basemaps as a background to check position. Basemap tiles are pictures. You cannot select or query their features, and many providers limit heavy use, so do not pull them in bulk.

OSM basemap under the places layer
Figure 5.2. OSM basemap under the places layer

2. Capture data in Google Earth

Google Earth Pro on the desktop lets you draw features and save them as KML.

  1. Install Google Earth Pro from Google, and search for your area (for example, Lalbagh Botanical Garden).
  2. Use the toolbar tools: Add Placemark for points, Add Path for lines, Add Polygon for areas.
  3. Name each feature and, optionally, write a description. These become attributes.
  4. In the Places panel, right-click the folder holding your features > Save Place As.
  5. Choose KML, name it lalbagh_features.kml, and save.
A polygon drawn in Google Earth Pro
Figure 5.3. A polygon drawn in Google Earth Pro
Save Place As dialog with KML selected
Figure 5.4. Save Place As dialog with KML selected

Load the KML in QGIS

  1. Layer > Add Layer > Add Vector Layer, and choose lalbagh_features.kml.
  2. QGIS lists the sub-layers (points, lines and polygons are separate). Select the ones you need.
  3. Click Add.

KML is always in EPSG:4326, so QGIS places it correctly with no extra setup. The name and description columns hold the labels you typed in Google Earth.

KML loaded in QGIS over Sentinel-2
Figure 5.5. KML loaded in QGIS over Sentinel-2

Google My Maps

Create a map at mymaps.google.com, draw your features, then use the three-dot menu > Export to KML/KMZ. QGIS reads the KML directly. A KMZ is a zipped KML. QGIS can usually open it directly, and if it does not, rename it to .zip and extract the KML inside.

3. Download OpenStreetMap data

QuickOSM

  1. Install QuickOSM from the plugin manager. A new menu appears under Vector > QuickOSM.
  2. Open Vector > QuickOSM > QuickOSM.
  3. Key: amenity. Value: hospital.
  4. In the area options, choose In and type Bengaluru (or use Canvas Extent to limit to the map view).
  5. Click Run Query.

QuickOSM creates up to three layers (points, lines and multipolygons), depending on how the mapped features are stored.

QuickOSM dialog with key, value and area
Figure 5.6. QuickOSM dialog with key, value and area
Hospital points over OSM
Figure 5.7. Hospital points over OSM

Other useful key and value pairs:

FeatureKeyValue
Roadshighwayleave blank, or primary
Buildingsbuildingyes
Lakesnaturalwater
Parksleisurepark
Railway stationsrailwaystation

Large areas with building data can return hundreds of thousands of features, so start with a small canvas extent.

Clean and save

OSM layers carry many tag columns, most of them empty. Remove the ones you do not need with Processing > Refactor Fields, then save to GeoPackage. Keep the OpenStreetMap attribution in your map: "© OpenStreetMap contributors".

4. Trace from imagery

To digitize a feature yourself (a building, a pond, a field), use a Sentinel-2 true-colour layer or a basemap you are allowed to trace.

  1. Create a new GeoPackage layer, as in Part 3.
  2. Add the basemap underneath.
  3. Turn on editing, snapping and the Add Polygon Feature tool.
  4. Zoom to about 1:1,000 and trace the outline.
  5. Fill in the attribute form, then save edits.

Sentinel-2 has 10 m pixels, so it suits large features such as lakes, fields and runways. It cannot resolve single buildings or narrow roads.

5. Convert between formats

The quickest way to convert is Export > Save Features As.

  1. Right-click the layer > Export > Save Features As.
  2. Pick a format, a file name and a CRS.
  3. Check Select fields to export and Add saved file to map, then click OK.
Save Vector Layer As with format list open
Figure 5.8. Save Vector Layer As with format list open

Format notes

FormatExtensionWhat to know
ESRI Shapefile.shp, .shx, .dbf, .prjSeveral files. Field names up to 10 characters. One geometry type per file
GeoPackage.gpkgOne file. Many layers, rasters and styles. Open standard
GeoJSON.geojsonText file. Uses EPSG:4326. Easy for web maps. Large files get slow
KML.kmlFor Google Earth. EPSG:4326 only. Styles are basic
GML.gmlXML based. Used in data exchange, often with an .xsd schema
CSV.csvAttributes only, unless you add geometry as WKT or X and Y columns

Worked conversions

  1. Shapefile to GeoJSON: Save Features As, format GeoJSON, CRS EPSG:4326. In Layer Options, set COORDINATE_PRECISION to 6 to keep the file small. Six decimal places in degrees is about 0.1 m.
  2. GeoPackage to KML: format KML, CRS EPSG:4326. Set NameField to the column holding the name, so Google Earth shows labels.
  3. Layer to GML: format GML. Keep the generated .xsd file with it.
  4. Layer to CSV with coordinates: format CSV, and in Layer Options set GEOMETRY to AS_XY for points. The output has X and Y columns.
GeoJSON layer options with coordinate precision
Figure 5.9. GeoJSON layer options with coordinate precision

Convert in bulk

Processing Toolbox > Batch Process on the Save Features As tool (or GDAL > Vector conversion > Convert format) runs the same conversion on many files at once.

Check after converting

  • Open the converted file and compare feature count with the original.
  • Check that attribute names did not change (Shapefile truncation is the usual cause).
  • Confirm the CRS. A GeoJSON or KML will be EPSG:4326 even if the source was projected.

Common mistakes

  • Assuming Google Maps data can be reused freely.
  • Forgetting the OSM attribution on a published map.
  • Querying a whole city for buildings in one go.
  • Expecting a KML to keep QGIS styling.
  • Converting to Shapefile and losing long field names.
  • Not checking the CRS after converting.

Key takeaways