How To Make Your Own Jobs Map

  1. Download data on number of jobs at the smallest available level of spatial aggregation, and shapefiles of the associated geography. Also make sure you have GEOS installed on your computer (this should be installed if you have the osgeo or shapely packages in Python).

  2. Clone our git repo to get the files mentioned in the following steps.

  3. Open the script dotfile_wac.py. Fill in the dirpath variable on line 16 with the path to your working directory. Adjust the four categories makers, services, professions, and support on lines 34-37 to conform to whatever categories you prefer. Adjust or remove the fips2abbrev code on lines 182-186 if your data does not require translating from a FIPS code to a US postal abbreviation. Adjust the wac_filename, input_filename, and output_filename variables on lines 191-193 to conform to your files.

  4. Run the script dotfile_wac.py. This may take a while to run. It will produce one csv file per state (or whatever input files you used) with one line per job, giving the type of job, quadkey location, and lat/long coordinates associated with the random point assigned to that job.

  5. Run the script sort_by_quadkey.py, again filling in your directory and the output filenames you used. This will read in all the individual csv output files from step 3 and compile them into one large dataset, then sort that dataset by quadkey and output it is a csv.

  6. It may be the case that there are rows missing certain data in the csv from step 4. These should be output at the beginning or end of the file. You can check them by running tail csvfile.csv in the terminal and delete them by running sed linenum1,linenum2d csvfile.csv > newcsvfile.csv

  7. Open the text file zoomlevel.txt in a text editor. Edit it to list the zoom levels that you want to have.

  8. Open the script dotmap_server.pde in Processing. Edit the reader variable in line 92 to point at your data file. Edit the colors on lines 168-186 to whatever colors you prefer.

  9. Run the script dotmap_server.pde. This will read in your master csv and output a series of map tiles, organized in a directory as zoomlevel/tile_x_coordinate/tile_y_coordinate.png.

  10. Copy the output tiles to your website.

  11. Create a blank png image that is the same size as your tiles and copy it over to the website.

  12. You can create the webmap using leaflet:

    <script src="http://cdn.leafletjs.com/leaflet-0.7.5/leaflet.js"></script>
    <div id="map"></div>
    <script type="text/javascript">
    var map = L.map('map').setView([lat, long],zoomlevel);
        L.tileLayer('http://url_to_tile_directory/{z}/{x}/{y}.png', {
        maxZoom: 13,
        minZoom: 4,
        errorTileUrl: 'http://url_to_blank_tile.png',
        attribution: 'Make Sure to Attribute Your Data'
    }).addTo(map);
    </script>
    
  13. Congratulations! You’re done!

AS SEEN ON

Fuel us with Bitcoin
Greg Ferenstein
Unplugged: Episode #1
0:00