One of the desirable features for COD-AB datasets is a line shapefile with codes an 'admlevel' attribute field designating the administrative level of each line segment i.e., '0' representing international borders (but '99' representing coastlines), '1' representing lines between distinct administrative level 1 units, etc. These files are necessary for the best cartographic symbology so that, for instance, they avoid an administrative level 2 boundary symbol appearing along an international border.. The alternative is to symbolize all polygon boundaries so that higher level boundaries have multiple symbols. (Even if these are carefully disguised by symbol size and order, shorelines cannot be symbolized properly.) ITOS makes these line shapefiles when they process your countries but if you are a country is not yet ITOS processed you the coded line file can also make them yourself be made with these instructions instructions.
The process may be unnecessary for island , or landlocked , or enclave countries containing only administrative level 0 polygons because all boundary lines will have the same status but it may still be useful for consistency and differentiating international borders from coastlines. The process is advised for all other countries for proper cartography.
Step-by-step guide
- Create the polyline shapefile
.
INSERT EXAMPLE
STEP 1: Create the polyline shapefile.
The goal is to create a shapefile with individual line features between nodes and left and right polygon identifiers. (Polygon shapefile exterior features have their left polygon identified as '-1'.) This process is discussed below for four software environments.
Software environment | Remarks | Methodology | ||
---|---|---|---|---|
ArcGIS | Requires 'Advanced' versionlicense | Run the ArcGIS ‘Polygon to Polyline’ tool (Toolbox > Data Management Tools > Features > Polygon To Line) with: "Input Features" = (input polygon shapefile); "Output Feature Class" = (as desired); "Identify and store polygon neighboring information (optional)" selected; and all environment settings set as default. Sample input parameters: Sample output: | ||
ET GeoWizard free version | Limited to 100 features | Run 'Polygon to Polyline' tool: Sample input parameters: Then run the 'Clean Polylines' tool: Sample input parameters: | ||
ET GeoWizards paid version | Not yet evaluated | Anticipated to be the same as the 'ET GeoWizards' free version process described above | ||
QGIS | Not suitable. It appears that the QGIS plugin makes polylines around whole | polygons, rather than distinct lines between nodes. If any user has more information, please contact ocha-fis-data@un.org. |
The remaining processes are completed in ArcGIS, regardless of whether ArcGIS or ET GeoWizards was used for the creation of the line shapefile.the software environment used above.
STEP 2: PREPARE THE P-CODE FIELDS IN THE POLYLINE SHAPEFILE
- Add fields to the output boundary polyline shapefile as follows:
Administrative levels in boundary polygon shapefile | Required new fields in boundary polyline shapefile |
---|---|
Administrative level 0 | AdmLevel (integer) |
Administrative levels 0 and 1 | LEFT_A0, RIGHT_A0 (normally text) AdmLevel (integer) |
Administrative levels 0, 1, and 2 | LEFT_A1, LEFT_A0, RIGHT_A0, RIGHT_A1 (normally text) AdmLevel (integer) |
Administrative levels 0, 1, 2, and 3 | LEFT_A2, LEFT_A1, LEFT_A0, RIGHT_A0, RIGHT_A1, RIGHT_A2 (normally text) AdmLevel (integer) |
Note that in the unusual case of numeric P-codes, the new fields should be of the same type.
- Verify that the AdmLevel values have all been set to zero. Calculate them to zero if they are not.
STEP 3: POPULATE THE POLYLINE P-CODE FIELDS
- Right-click the polyline shapefile > "Joins & Relates" > "Join..." (or properties > Joins & Relates) and provide the Join Data as follows:
- "What do you want to join to this layer?" = Join attributes from a table
- "Choose the field in this layer that the join will be based on:" = LEFT_FID
- "Choose the table to join to this layer, or load the table from disk:" = (the input polygon shapefile)
- "Choose the field in the table to base the join on:" = OBJECTID (or FID)
- Select "Keep only matching records". These will be the line features that are not boarding the sea or a neighboring country.
- Optionally ) Click
- , click the ‘Validate Join’ button. Do not expect all records to match - because the ‘left’ side of all exterior lines will have no neighboring polygon. Do not worry if you receive a “Field names that match reserved words should not be used in database schema and can cause the join to fail. The following fields match reserved words….” message. Close the 'Join Validation' dialogue box after inspecting the result.
- (
- Click ‘OK’
- Begin editing the polyline shapefile
- Open the output polyline shapefile attribute table
- Use the Field Calculator to calculate all the LEFT_Ax values (for the LEFT_Ax fileds recently added to the polyline shapefile ) equal to the coresponding administrative levels of the polygon shapefile.
Administrative levels in boundary polygon shapefile | Required calculations | Administrative level 0|
---|---|---|
Administrative levels 0 and 1 | polyline shapefile LEFT_A0 = polygon shapefile Adm0codeADM0_PCODE | |
Administrative levels 0, 1, and 2 | polyline shapefile LEFT_A0 = polygon shapefile Adm0codeADM0_PCODE polyline shapefile LEFT_A1 = polygon shapefile Adm1codeADM1_PCODE | |
Administrative levels 0, 1, 2, and 3 | polyline shapefile LEFT_A0 = polygon shapefile Adm0codeADM0_PCODE polyline shapefile LEFT_A1 = polygon shapefile Adm1codeADM1_PCODE polyline shapefile LEFT_A2 = polygon shapefile Adm2codeADM2_PCODE |
- Close the attribute table, remove the join, and establish a new join basing on RIGHT_FID. Anticipate all records matching.
- This time there should be no need to make a definition query, as there should be no null values.
- Open the output polyline shapefile attribute table.
- Use the Field Calculator to calculate all the RIGHT_Ax values (for the RIGHT_Ax fileds recently added to the polyline shapefile ) equal to the coresponding administrative levels of the polygon shapefile.
- Create a definition query to select the line segments with different LEFT_A0 and RIGHT_A0 attributes.
Administrative levels in boundary polygon shapefile | Required calculations | Administrative level 0|
---|---|---|
Administrative levels 0 and 1 | polyline shapefile RIGHT_A0 = polygon shapefile Adm0codeshapefile ADM0_PCODE | |
Administrative levels 0, 1, and 2 | polyline shapefile RIGHT_A0 = polygon shapefile Adm0codeshapefile ADM0_PCODE polyline shapefile RIGHT_A1 = polygon shapefile Adm1codeshapefile ADM1_PCODE | |
Administrative levels 0, 1, 2, and 3 | polyline shapefile RIGHT_A0 = polygon shapefile Adm0codeshapefile ADM0_PCODE polyline shapefile RIGHT_A1 = polygon shapefile Adm1codeshapefile ADM1_PCODE polyline shapefile RIGHT_A2 = polygon shapefile Adm2code |
[IF THIS DOES NOT WORK, ENTER ' "LEFT_A0" IS NULL']
...
shapefile ADM2_PCODE |
- Remove all joins
STEP 4: CALCULATE THE ADMINISTRATION LEVELS
ADMINISTRATIVE LEVEL 0
- Open attribute table and calculate AdminLevel = 0 (Unless the Adm0 lines are all shoreline or all international boundary ... IN WHICH CASE....) open for all features. (Higher administrative level features will be adjusted later.)
Recall that shoreline features need to be coded specially as '99'. If the country has a shoreline follow the SHORELINE TREATMENT steps.
SHORELINE TREATMENT
- Open an editing session for the line shapefile.
- Manually select line segments that represent shorelines (splitting line segments where an international border meets the water). It may be useful to add a world country layer or neighboring country layers.
...
Check carefully for discontinuities
Calculate
HIGHER ADMINISTRATIVE LEVELS
Administrative level 1
Set a definition query for LEFT_A0 = RIGHT_A0 and LEFT_A1 <> RIGHT_A1; calculate AdminLevel = 1.
Explanation: LEFT Definition query "LEFT_A0 = RIGHT_A0 and LEFT_A1 <> RIGHT_A1" will find select the lines line features that are not administrative level 0 borders (either shorelines or international borders) but are separating administrative level 1 units. |
---|
In this map the administrative level 1 polygons are shaded to show that the lines separate administrative level 1 units. |
Set a definition query for LEFT_A1 = RIGHT_A1 and LEFT_A2 <> RIGHT_A2; calculate AdminLevel = 2.
In this map the administrative level 1 polygons are coloured to show that the lines are only inside the polygons |
---|
Set ISet a definition query for LEFT_A2 = RIGHT_A2; calculate AdminLevel = 3.
...