Sunday, April 15, 2018

Using 3rd party GIS Shapefile Maps in XASTIR (APRS)

A problem many Ham radio operators have with open source APRS (Automated Position Reporting System) software (in this case XAstir) is getting freely available map data files to display correctly.

Making maps is hard, there is just as much art to it as science.  One day I decided I wanted to create some custom map layers to use for my Amateur radio APRS rig.  Amateur radio geeks are quick to point out the folly of relying on the internet and cell phone data systems.  So I needed to get some good quality map layers as well as be able to to display them along with all of the needed labels and icons to identify what's what.

So here are the steps I took to get this all to work.
  1. Don't use the pre-package versions of Xastir, compile from source in order to have all of the map support you will need. Follow these steps here and make sure you include GDAL support. https://xastir.org/index.php/HowTo:Ubuntu_14.04-17.04
  2. Find a shapefile map you like.  For example Johnson County Kansas has a GIS department which releases up to date map Shape files. https://aims.jocogov.org/AIMSData/FreeData.aspx
  3. Download the maps in shapefile format and place the folder containing the map files into the /usr/local/share/xastir/maps folder.  There should be multiple files per map layer(.cpg, .dbf, .prj, .shp, .shx).
  4. using the testdbfawk command, extract the field names in the shapefile: testdbfawk -D /usr/local/share/xastir/config -d /usr/local/share/xastir/maps/your_map/your_map.dbf
  5. Create a new file in /usr/local/share/xastir/config/ called "your_map.dbfawk" :
#A colon separated list of all of the fields in this shapefile
dbfinfo="field1:field2:field3:field4"; 


#A colon separated list of the fields that we want to do something with
dbffields="field2:field4";


#sets the map settings (ex. what level these are displayed, what color and background color are to be used ...etc)

BEGIN_RECORD {key=""; lanes=1; color=4; name=""; filled=0; pattern=2; display_level=1; label_level=32; label_color=8; symbol=""; font_size=3}

#a list of the fields from dbffields (above) specifically that we want to do something with.
/^field2=(.+)$/ {name="$1";}
/^field4=(.+)$/ {name="$1";}


Once finished you can enable your map in xastir and everything that has the fields listed in "dbfinfo" will get formatted with these settings. 

Happy mapping!

No comments:

Post a Comment