Transportation Planning: Road Data Export
Extract and export road segments within municipal boundaries with specific attributes for transportation planning analysis.
Scenario Overviewβ
Goal: Export all major roads (highway, primary, secondary) within city limits with proper CRS transformation for CAD/engineering software.
Real-World Application:
- Transportation departments preparing data for contractors
- Engineering firms analyzing road networks
- GIS analysts creating data subsets for modeling
- Urban planners evaluating infrastructure coverage
Estimated Time: 10 minutes
Difficulty: β Beginner
Prerequisitesβ
Required Dataβ
-
Roads Network Layer (lines)
- Road segments/centerlines
- Required attributes:
road_typeorhighwayclassificationname(street name)
- Optional:
surface,lanes,speed_limit,condition
-
Municipality Boundary (polygon)
- City, county, or district boundary
- Single feature preferred (use Dissolve if multiple)
- Must match or overlap road network extent
Sample Data Sourcesβ
Roads Data:
# OpenStreetMap via QuickOSM
Key: "highway", Value: "*"
# Road types to include:
- motorway
- trunk
- primary
- secondary
- tertiary
Boundaries:
- Municipal GIS portals (official boundaries)
- Census TIGER/Line files (USA)
- OpenStreetMap administrative boundaries
- National mapping agencies (UK Ordnance Survey, etc.)
Backend Recommendationβ
Any Backend - This workflow focuses on export features:
- OGR: Universal compatibility, works with all formats
- Spatialite: If you need temporary processing
- PostgreSQL: If exporting very large networks (>100k segments)
All backends export identically - choose based on your setup.
Step-by-Step Instructionsβ
Step 1: Load and Verify Dataβ
-
Load layers into QGIS:
roads_network.gpkg(or OSM .shp, .geojson)city_boundary.gpkg
-
Check CRS:
Both layers should ideally be in same CRS
Right-click β Properties β Information β CRS
Note: Not critical for this workflow (FilterMate handles reprojection) -
Inspect attributes:
Open roads attribute table (F6)
Find road classification field: "highway", "road_type", "fclass", etc.
Note field name for next step -
Verify boundary:
Select city_boundary layer
Should show single feature covering your area of interest
If multiple polygons: Vector β Geoprocessing β Dissolve
OpenStreetMap highway values:
motorway: Freeway/interstatetrunk: Major roads between citiesprimary: Main roads within citiessecondary: Connecting roadstertiary: Local important roadsresidential: Neighborhood streets
Step 2: Filter Roads by Type and Locationβ
Using FilterMate:
- Open FilterMate panel
- Select roads_network layer
- Choose any backend (OGR is fine)
- Enter filter expression:
- OpenStreetMap Data
- Generic Road Data
- Advanced Filtering
-- Major roads only (exclude residential, service roads)
"highway" IN ('motorway', 'trunk', 'primary', 'secondary')
-- Within city boundary
AND intersects(
$geometry,
aggregate(
layer:='city_boundary',
aggregate:='collect',
expression:=$geometry
)
)
-- Adjust field name to match your data
"road_type" IN ('highway', 'arterial', 'collector')
-- Within municipality
AND within(
$geometry,
aggregate('city_boundary', 'collect', $geometry)
)
-- Major roads + additional criteria
"highway" IN ('motorway', 'trunk', 'primary', 'secondary')
AND intersects($geometry, aggregate('city_boundary', 'collect', $geometry))
-- Optional: Add condition filters
AND ("surface" = 'paved' OR "surface" IS NULL) -- Exclude unpaved
AND "lanes" >= 2 -- Multi-lane only
AND "access" != 'private' -- Public roads only
- Click Apply Filter
- Review count: "Showing X of Y features"
- Visually inspect: Only major roads within boundary should be highlighted
Expected Result: Road segments filtered to major types within city limits
Step 3: Review and Refine Selectionβ
Check coverage:
- Zoom to full extent of city_boundary
- Verify filtered roads cover entire municipality
- Look for gaps or missing segments
Adjust if needed:
-- If too many roads included, be more strict:
"highway" IN ('motorway', 'trunk', 'primary') -- Exclude secondary
-- If missing important roads, expand:
"highway" IN ('motorway', 'trunk', 'primary', 'secondary', 'tertiary')
-- If using custom classification:
"functional_class" IN (1, 2, 3) -- Numeric codes
Edge cases - Roads partially outside boundary:
- Include Partial Segments
- Only Completely Inside
- Clip to Boundary (Manual)
-- Use intersects (includes partially overlapping)
intersects($geometry, aggregate('city_boundary', 'collect', $geometry))
-- Use within (only fully contained roads)
within($geometry, aggregate('city_boundary', 'collect', $geometry))
After filtering, use QGIS Clip tool:
Vector β Geoprocessing β Clip
Input: filtered roads
Overlay: city_boundary
Result: Roads trimmed exactly to boundary
Step 4: Select Attributes to Exportβ
Identify useful fields:
-
Open Attribute Table of filtered layer
-
Note relevant columns:
Essential:
- road_id, osm_id (identifier)
- name (street name)
- highway / road_type (classification)
Useful:
- surface (paved, unpaved, etc.)
- lanes (number of lanes)
- maxspeed (speed limit)
- length_m (calculated or existing) -
Optional: Remove unnecessary columns before export:
Layer β Properties β Fields
Toggle editing mode (pencil icon)
Delete unwanted fields (osm metadata, etc.)
Save edits
Step 5: Add Calculated Fields (Optional)β
Add road length in your preferred units:
- Open Field Calculator (Ctrl+I)
- Create new field:
Field name: length_m
Type: Decimal (double)
Precision: 2
Expression:
$length
Add length in different units:
Field name: length_ft
Expression: $length * 3.28084 -- meters to feet
Field name: length_km
Expression: $length / 1000 -- meters to kilometers
Add functional classification (if converting OSM data):
Field name: functional_class
Type: Integer
Expression:
CASE
WHEN "highway" IN ('motorway', 'trunk') THEN 1
WHEN "highway" = 'primary' THEN 2
WHEN "highway" = 'secondary' THEN 3
WHEN "highway" = 'tertiary' THEN 4
ELSE 5
END
Step 6: Choose Target CRS for Exportβ
Common CRS choices:
- WGS84 (Universal)
- UTM (Engineering)
- State Plane (USA)
- Local Grid
EPSG:4326 - WGS84 Geographic
Use for:
- Web mapping (Leaflet, Google Maps)
- GPS applications
- Maximum interoperability
β οΈ Not suitable for CAD (uses degrees, not meters)
EPSG:326XX - UTM Zones
Examples:
- EPSG:32633 - UTM Zone 33N (Central Europe)
- EPSG:32617 - UTM Zone 17N (Eastern USA)
Use for:
- CAD software (AutoCAD, MicroStation)
- Engineering drawings
- Accurate distance measurements
β Meters-based, preserves accuracy
State Plane Coordinate Systems
Examples:
- EPSG:2249 - Massachusetts State Plane (meters)
- EPSG:2278 - Texas State Plane Central (feet)
Use for:
- Local government projects (USA)
- Compliance with state standards
- Integration with official datasets
National/Regional Systems
Examples:
- EPSG:27700 - British National Grid (UK)
- EPSG:2154 - Lambert 93 (France)
- EPSG:3857 - Web Mercator (web maps)
Use for:
- National mapping agency compatibility
- Regional standards compliance
Find your CRS:
- Search epsg.io by location
- Check project requirements/specifications
- Ask receiving organization for preferred CRS
Step 7: Export Filtered Roadsβ
Using FilterMate Export (Recommended):
-
In FilterMate panel, click Export Filtered Features
-
Configure export settings:
Format: Choose based on recipient's needs
For GIS:
βββ GeoPackage (.gpkg) - Best for QGIS/modern GIS
βββ Shapefile (.shp) - Universal GIS format
βββ GeoJSON (.geojson) - Web mapping, lightweight
For CAD:
βββ DXF (.dxf) - AutoCAD, most compatible
βββ DWG (.dwg) - AutoCAD (requires plugin)
For Databases:
βββ PostGIS - Direct database export
βββ Spatialite - Embedded database
For Other:
βββ CSV with WKT geometry - Text-based
βββ KML - Google Earth
βββ GPX - GPS devices -
Set CRS (Coordinate Reference System):
Click CRS selector
Search for target CRS (e.g., "UTM 33N" or "EPSG:32633")
Select and confirm
βΉοΈ FilterMate will reproject automatically -
Configure options:
β Export selected features only (already filtered)
β Skip attribute fields: [choose unnecessary fields]
β Add geometry column (for CSV exports)
β Force multi-linestring type (if required) -
Name and save:
Filename: city_major_roads_utm33n_2024.gpkg
Naming convention tip:
[location]_[content]_[crs]_[date].[ext] -
Click Export β Wait for confirmation
Step 8: Validate Exportβ
Quality checks:
-
Load exported file back into QGIS:
Layer β Add Layer β Add Vector Layer
Browse to exported file -
Verify CRS:
Right-click layer β Properties β Information
Check CRS matches your target (e.g., EPSG:32633) -
Check feature count:
Should match filtered count from Step 2
Open attribute table (F6) to verify -
Inspect attributes:
All selected fields present and populated
No NULL values in critical fields
Text encoding correct (no garbled characters) -
Visual comparison:
Overlay exported layer with original
Verify geometries match exactly
Check no segments were lost or duplicated
Test with recipient's software (if possible):
- Open in AutoCAD/MicroStation (for DXF exports)
- Load in ArcGIS/MapInfo (for Shapefile)
- Import to database (for SQL exports)
Understanding the Resultsβ
What You've Exportedβ
β Included:
- Major roads (motorway, trunk, primary, secondary) only
- Roads intersecting/within city boundary
- Selected attributes relevant for analysis
- Geometry reprojected to target CRS
β Excluded:
- Minor roads (residential, service, paths)
- Roads outside municipality
- OSM metadata and technical fields
- Original CRS (if reprojected)
File Size Expectationsβ
Typical sizes for medium city (500kmΒ² area):
Format | ~10k segments | Notes
------------|---------------|----------------------------
GeoPackage | 2-5 MB | Smallest, fastest
Shapefile | 3-8 MB | Multiple files (.shp/.dbf/.shx)
GeoJSON | 5-15 MB | Text-based, larger but readable
DXF | 4-10 MB | CAD format
CSV+WKT | 10-30 MB | Text geometry, very large
If file unexpectedly large:
- Check for hidden attributes (OSM metadata)
- Simplify line geometry (Simplify tool, 1-5m tolerance)
- Verify filter actually applied (check feature count)
Common Export Issuesβ
Issue 1: "CRS transformation failed"
Solution:
1. Verify source layer has valid CRS set
2. Choose different target CRS (try WGS84 first)
3. Reproject layer manually first:
Vector β Data Management β Reproject Layer
4. Then export without CRS change
Issue 2: "Some features were not exported"
Solution:
1. Check for invalid geometries:
Vector β Geometry Tools β Check Validity
2. Fix invalid geometries:
Vector β Geometry Tools β Fix Geometries
3. Re-apply filter and export fixed layer
Issue 3: Shapefile truncates field names
Limitation: Shapefile format limits field names to 10 characters
Solution:
Option A: Use GeoPackage instead (no limits)
Option B: Rename fields before export:
- "maxspeed_mph" β "max_speed"
- "functional_classification" β "func_class"
Best Practicesβ
Data Preparationβ
Before export checklist:
β‘ Filter applied and verified
β‘ Attribute table reviewed
β‘ Unnecessary fields removed
β‘ Calculated fields added (length, etc.)
β‘ Geometries validated
β‘ CRS determined
β‘ Export format confirmed with recipient
Naming Conventionsβ
File naming best practices:
Good:
β boston_major_roads_utm19n_20240312.gpkg
β denver_highways_stateplane_ft_v2.shp
β london_transport_network_bng_2024.geojson
Bad:
β roads.shp (too generic)
β export_final_FINAL_v3.gpkg (unclear versioning)
β γγΌγΏ.gpkg (non-ASCII characters)
Folder structure:
project_name/
βββ 01_source_data/
β βββ roads_raw_osm.gpkg
β βββ boundary_official.shp
βββ 02_processed/
β βββ roads_filtered.gpkg
βββ 03_deliverables/
βββ roads_utm33n.gpkg
βββ roads_utm33n.dxf
βββ metadata.txt
Metadata Documentationβ
Always include metadata file:
metadata.txt or README.txt contents:
=== Road Network Export ===
Date: 2024-03-12
Analyst: Jane Smith
Project: City Transportation Master Plan
Source Data:
- Roads: OpenStreetMap (downloaded 2024-03-01)
- Boundary: City GIS Portal (official 2024 boundary)
Processing:
- Filter: Major roads only (motorway, trunk, primary, secondary)
- Area: Within city limits
- Tool: QGIS FilterMate plugin v2.8.0
Export Specifications:
- Format: GeoPackage
- CRS: EPSG:32633 (UTM Zone 33N)
- Feature Count: 8,432 segments
- Total Length: 1,247.3 km
Attributes:
- osm_id: OpenStreetMap identifier
- name: Street name
- highway: Road classification
- surface: Pavement type
- lanes: Number of lanes
- length_m: Segment length in meters
Quality Notes:
- Geometries validated and repaired
- Roads partially outside boundary included (intersects)
- Speed limits: 15% missing data (default to city standard)
Contact: jane.smith@city.gov
Performance Tipsβ
For large networks (>50k segments):
-
Create spatial index first:
Layer Properties β Create Spatial Index
Speeds up spatial filtering -
Export in chunks if hitting memory limits:
Filter by district/zone, export separately, merge later
Processing β Vector General β Merge Vector Layers -
Use PostgreSQL backend for fastest export:
Direct database to file export (bypass QGIS memory) -
Simplify geometry if millimeter precision not needed:
Vector β Geometry β Simplify
Tolerance: 1-5 meters (invisible change, major size reduction)
Common Issuesβ
Issue 1: Roads along boundary partially cut offβ
Cause: Using within() instead of intersects()
Solution:
-- Change from:
within($geometry, aggregate('city_boundary', 'collect', $geometry))
-- To:
intersects($geometry, aggregate('city_boundary', 'collect', $geometry))
-- Or clip geometrically after export:
Vector β Geoprocessing β Clip
Issue 2: Export fails with "write error"β
Cause: File permissions, path issues, or disk space
Solutions:
1. Check disk space (need 2-3x final file size)
2. Export to different location (e.g., Desktop instead of network drive)
3. Close file if open in another program
4. Use shorter file path (<100 characters)
5. Remove special characters from filename
Issue 3: CAD software won't open DXFβ
Cause: QGIS DXF export may not match CAD version expectations
Solutions:
Option A: Try different DXF export settings
Project β Import/Export β Export Project to DXF
- DXF format version: AutoCAD 2010
- Symbology mode: Feature symbology
Option B: Use intermediate format
Export to Shapefile β Open in AutoCAD (has built-in SHP support)
Option C: Use specialized plugin
Install "Another DXF Exporter" plugin
Better CAD compatibility than native export
Issue 4: Attribute encoding issues (special characters)β
Cause: Shapefile encoding limitations
Solutions:
For GeoPackage: (Recommended, no encoding issues)
Format: GeoPackage
Encoding: UTF-8 (automatic)
For Shapefile:
Format: ESRI Shapefile
Encoding: UTF-8 or ISO-8859-1
Layer Options β ENCODING=UTF-8
Next Stepsβ
Related Workflowsβ
- Real Estate Analysis: Attribute filtering techniques
- Emergency Services: Buffer-based selection
- Urban Planning Transit: Multi-layer spatial filtering
Advanced Techniquesβ
1. Network Topology Export:
Export roads with connectivity maintained for routing analysis
Processing β Vector Analysis β Network Analysis β Service Areas
2. Multi-CRS Batch Export:
# Python console - export to multiple CRS simultaneously
target_crs_list = [32633, 32634, 4326] # EPSG codes
layer = iface.activeLayer()
for epsg in target_crs_list:
output_file = f'roads_epsg{epsg}.gpkg'
# Use QgsVectorFileWriter for programmatic export
3. Scheduled Export Automation:
# Create QGIS processing model
# Schedule with cron (Linux) or Task Scheduler (Windows)
# Auto-export updated road data weekly
4. Attribute Aggregation (summarize by road type):
-- Before export, create summary statistics
GROUP BY "highway"
COUNT(*), SUM($length), AVG("lanes")
5. Multi-Format Batch Export:
Export same filtered data to multiple formats simultaneously
Processing β QGIS Model Designer β Batch export node
Outputs: .gpkg, .shp, .geojson, .dxf
Further Learningβ
- π Export Features Guide
- π Buffer Operations
- π Performance Tuning
- π QGIS Processing Documentation
Summaryβ
β You've learned:
- Filtering roads by classification and boundary
- Selecting and preparing attributes for export
- Choosing appropriate target CRS
- Exporting to multiple formats (GeoPackage, Shapefile, DXF, etc.)
- Validating export quality
- Creating metadata documentation
β Key techniques:
- Spatial predicates:
intersects()vswithin() - CRS transformation during export
- Format selection based on use case
- Field calculator for derived attributes
- Batch processing for large datasets
π― Real-world impact: This workflow streamlines data preparation for transportation projects, ensures data interoperability between GIS and CAD systems, and maintains data quality through the analysis pipeline.
π‘ Pro tip: Create a QGIS Processing Model for this workflow to automate filtering + export in one click. Save the model and reuse for different cities or time periods.
Appendix: Export Format Quick Referenceβ
| Format | Extension | Use Case | Max File Size | CRS Support | Attribute Limits |
|---|---|---|---|---|---|
| GeoPackage | .gpkg | Modern GIS, QGIS | 140 TB | β Any | None |
| Shapefile | .shp | Legacy GIS, universal | 2-4 GB | β Any | 10-char field names, 254 chars text |
| GeoJSON | .geojson | Web mapping, APIs | Unlimited (but slow if >100 MB) | β Any (WGS84 recommended) | None |
| DXF | .dxf | CAD (AutoCAD) | Unlimited | β Limited | Limited attribute support |
| CSV+WKT | .csv | Spreadsheets, databases | Unlimited (text) | Manual | None |
| KML | .kml | Google Earth | Slow if >10 MB | WGS84 only | Limited styling |
| PostGIS | SQL | Database | Unlimited | β Any | None |
Recommendation: Use GeoPackage unless you have specific compatibility requirements. It's the modern standard with no artificial limitations.