Converting Google Maps HTML to QGIS Format

Learn how to extract coordinates from Google Maps HTML and convert them to QGIS-compatible formats like CSV, GeoJSON, and KML. Step-by-step guide with Python code examples.
Google Maps
Author

Mapcrafty Team

Published

October 2, 2025

Converting Google Maps HTML to QGIS Format

Working with geographic data often requires converting between different formats. If you have Google Maps data embedded in HTML and need to use it in QGIS, this guide will walk you through the process.

Understanding the Problem

Google Maps embed codes and HTML objects contain coordinate data that isn’t directly compatible with QGIS. To use this data in your GIS projects, you need to extract the coordinates and convert them into a format QGIS can read.

Step 1: Extract Coordinates from HTML

Google Maps HTML typically contains latitude and longitude data in various formats: - URL parameters (?q=lat,lng) - Data attributes (data-lat, data-lng) - JavaScript objects within script tags

You’ll need to parse your HTML to extract these coordinate pairs along with any associated metadata (names, descriptions, etc.).

Step 2: Choose Your Target Format

QGIS supports multiple geographic data formats. Choose based on your needs:

CSV (Comma-Separated Values)

Best for: Simple point data

Pros: Easy to create, human-readable, works with spreadsheet software

Structure:

name,latitude,longitude,description
Location 1,40.7128,-74.0060,New York City
Location 2,51.5074,-0.1278,London

GeoJSON

Best for: Points, lines, or polygons with properties

Pros: Web-friendly, preserves geometry types, includes properties

Structure:

{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "geometry": {
        "type": "Point",
        "coordinates": [-74.0060, 40.7128]
      },
      "properties": {
        "name": "New York City",
        "description": "The Big Apple"
      }
    }
  ]
}

Important: GeoJSON uses [longitude, latitude] order, not [latitude, longitude].

KML (Keyhole Markup Language)

Best for: Google Earth/Maps data

Pros: Native Google format, supports styling and descriptions

Structure:

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
  <Document>
    <Placemark>
      <name>New York City</name>
      <Point>
        <coordinates>-74.0060,40.7128,0</coordinates>
      </Point>
    </Placemark>
  </Document>
</kml>

Step 3: Convert the Data

Using Python

Here’s a Python script to convert extracted coordinates to CSV:

import pandas as pd

# Your extracted data
locations = [
    {"name": "Location 1", "lat": 40.7128, "lng": -74.0060},
    {"name": "Location 2", "lat": 51.5074, "lng": -0.1278}
]

# Create DataFrame
df = pd.DataFrame(locations)
df.rename(columns={"lat": "latitude", "lng": "longitude"}, inplace=True)

# Save as CSV
df.to_csv('locations.csv', index=False)
print("CSV file created successfully!")

Converting to GeoJSON

import json

# Your extracted data
locations = [
    {"name": "Location 1", "lat": 40.7128, "lng": -74.0060},
    {"name": "Location 2", "lat": 51.5074, "lng": -0.1278}
]

# Create GeoJSON structure
geojson = {
    "type": "FeatureCollection",
    "features": []
}

# Add each location as a feature
for loc in locations:
    feature = {
        "type": "Feature",
        "geometry": {
            "type": "Point",
            "coordinates": [loc["lng"], loc["lat"]]  # Note: [lng, lat]
        },
        "properties": {
            "name": loc["name"]
        }
    }
    geojson["features"].append(feature)

# Save to file
with open('locations.geojson', 'w') as f:
    json.dump(geojson, f, indent=2)
print("GeoJSON file created successfully!")

Using Online Tools

If you prefer not to code: - CSV: Use Excel or Google Sheets to organize your data - GeoJSON: Use geojson.io to manually create features - KML: Use Google Earth Pro to create and export KML files

Step 4: Import into QGIS

For CSV Files

  1. Open QGIS
  2. Go to Layer → Add Layer → Add Delimited Text Layer
  3. Browse to your CSV file
  4. Set the following:
    • File Format: CSV
    • Geometry Definition: Point coordinates
    • X field: longitude
    • Y field: latitude
    • Geometry CRS: EPSG:4326 (WGS 84)
  5. Click Add

For GeoJSON or KML Files

  1. Open QGIS
  2. Simply drag and drop the file into the map canvas, or
  3. Go to Layer → Add Layer → Add Vector Layer
  4. Browse to your file and click Add

Step 5: Set the Coordinate Reference System

After importing, ensure your layer uses the correct CRS:

  1. Right-click the layer in the Layers panel
  2. Select Properties → Source
  3. Verify the CRS is set to EPSG:4326 - WGS 84 (for lat/lng data)
  4. If needed, reproject to your project’s CRS via Processing → Toolbox → Reproject layer

Troubleshooting

Points appear in the wrong location: - Check if lat/lng values are swapped - Verify the CRS is set to EPSG:4326 - Ensure longitude values are negative for western hemisphere

CSV import fails: - Check for proper column headers - Ensure no extra commas or special characters - Verify coordinates are numeric (not text)

GeoJSON displays incorrectly: - Remember: GeoJSON uses [longitude, latitude] order - Validate your GeoJSON at geojsonlint.com

Best Practices

  1. Always keep a backup of your original HTML data
  2. Document your CRS - different projects may use different coordinate systems
  3. Validate coordinates - ensure they fall within valid ranges:
    • Latitude: -90 to 90
    • Longitude: -180 to 180
  4. Include metadata - add descriptions, timestamps, or other relevant information
  5. Use version control for your data files if working on long-term projects

Conclusion

Converting Google Maps HTML data to QGIS format is straightforward once you understand the workflow: extract coordinates, convert to a compatible format, and import into QGIS. Choose CSV for simplicity, GeoJSON for flexibility, or KML for Google ecosystem compatibility.

With these tools and techniques, you can seamlessly integrate web-based geographic data into your GIS analysis workflows.


📧 Contact & Collaboration

Have questions about this analysis or interested in collaborating on geospatial projects? We’d love to hear from you!

Get in touch with our research team: - Email: mapcrafty@gmail.com

Whether you’re working on similar research, need technical consultation, or want to discuss potential collaborations in geospatial analysis, don’t hesitate to reach out. Our team is always excited to connect with fellow researchers and practitioners in the GIS and remote sensing community.

We typically respond within 24-48 hours and welcome discussions about methodology, data sources, and potential research partnerships.