-{ a hewer of maps }-

Automatic download and conversion of Geobase Road Network

Note: BC and Alberta archives are 68mb, Yukon & NWT only 2mb. Simply remove ab bc from the set regions line.

Requires fwtools, wget, and 7zip to be in path.

*update: use ogr2ogr newer than 1.4.2 else some of the attributes will be truncated! Please see gdal bug#1844 for more info.*

 @echo off
 :: rev 0.1 ~ 2007 Nov 10, Matt.Wilkie@gov.yk.ca
 echo. Going to download National Road Network files from Geobase
 echo. for Yukon and adjacent regions.
 echo. When finished downloading I will attempt to unpack the archives
 echo. and project the data to Yukon Albers, in shapefiles.

call :ChkReqs wget.exe
call :Unpack
call :gml2shp
goto :EOF

    :: test for wget, if it is in path we can carry on.
    if exist%\~\$PATH:1″ (
        call :Download ) else (
            echo %1 not found! can’t continue
    goto :EOF

     set urlRoot=http://ftp2.cits.rncan.gc.ca/pub/geobase/official/nrn_rrn/

    :: Regions to download (ab = alberta, etc.)
     set regions=yt nt bc ab

    :: gml or shapefiles?
     set type=gml
     rem set type=shp

    if not exist zips mkdir zips
     cd zips
     for %%a in (%regions%) do (
     wgetcontinue %urlRoot%/%%a/nrn_rrn_%%a_%type%_en.zip
     cd ..

    goto :EOF

    :: FIXME: chkreq is hardcoded to download on successful check
    rem call :ChkReqs 7z.exe
    if not exist unpack mkdir unpack
    cd unpack
    7z x ..\zips*.zip
    cd ..

    echo. Finished unpacking.
    goto :EOF

    echo. Now Im going to convert from GML to shapefile,
    echo. and project to Yukon Albers in the process.
    echo. This could take awhile.

    :: projection parameters. Example is of NAD83CSRS in lat-long to NAD83
    Yukon Albers
    :: refer to gdal/ogr docs for more info on how to use these parameters
    set prj_params=-s_srs epsg:4617 -t_srs epsg:3578
    for %%a in (%regions%) do (
        echo ogr2ogr -fesri shapefile-overwrite %prj_params% %%a unpack\NRN_%%a*.gml
        ogr2ogr -fesri shapefile-overwrite %prj_params% %%a unpack\NRN_%%a*.gml
    goto :EOF
Recent changes » « Search PATH for duplicates