A simple Python tool to query a table of all roads from the ArcGIS server of the Department of Public Works and Highways (DPWH)'s Road and Bridge Information Application. The tool retrieves data from the Road Classification features layer, which classifies whether a road or a segment of a road is an Expressway or a Primary, Secondary, or Tertiary road.
The generated data contains the following columns:
For Expressways:
region: The region that the road is located in.province: The province that the road is located in.deo: Name of the District Engineering Office that the road segment is a part of. Note that DEOs may span one or more cities or municipalities.cong_district: The congressional district that the road segment is a part of.road_class: Labels whether the road is aPrimary,Secondary, orTertiaryroad.road_name: The road that the road segment is a part of; this may be the whole segment or a divided one-way segment of a road.road_length: Road segment length in meters.
For National Roads:
region: The region that the road is located in.road_class: Labels whether the road is anExpressway,Elevated Expressway, orSkyway.xpres_way: The road segment name; this may be a whole segment or a divided one-way segment of the expressway.xpres_name: The expressway that the road segment is a part of.road_length: Road segment in meters.
- Python 3.8+
-
Clone or download the project:
git clone <repository-url> cd DPWH_GIS
-
Create and activate a virtual environment:
python -m venv env env\Scripts\activate.bat # On Windows # or source env/bin/activate # On macOS/Linux
Run the main script:
python query_gis_data.pyThe script supports the following options:
- Expressways or National Roads (Primary, Secondary, and Tertiary Roads)
- Roads from all regions or a specific region
- Maximum number of roads (or set to
-1to get all available data)
The average time it takes to query all national roads should be no more than 2 seconds. After querying the data, it will get all unique roads and save the data as a CSV file in the gis_data/ directory.