Files to be transferred:
- The geojson file for the 37 towns. Label: cwp-37-towns-v8.geojson. This file contains the data provided by the Capital Workforce Partners. The organization owns and has access to the file.
- The csv file for 37 towns. Label: cwp-37-towns-v8.csv. This file contains the data in the geojson file but in the excel format.
Part 1: Maintain the website
- Sign up for a free GitHub account.
- Go to https://github.com/ngocdo67/cwp-map. This is the repository for the Leaflet map. Click on “Fork” to make your own copy of the map.
- Go to the README file. Click on the edit icon. In the demo link http://ngocdo67.github.io/cwp-map/index.html change “ngocdo67” to your github username. Click on the green button Commit changes.
- Go to the branches tab. Delete all branches, except for the master branch. Go back to the repository main page. Click on Branch: master. On the Find or create a branch, type in gh-pages to create your own gh-pages branch. The code in here would be the one that goes live on the link you have on the README file.
- Replace the current link on your account with your own demo link.
How to do a pull request
- On the main page of the repository, click on the green button New Pull Request
Make sure the base fork is your username, NOT “ngocdo67”. Use the drop-down menus to CAREFULLY select the direction of the merge in this TO-FROM format. In this example, it is TO master branch FROM gh-pages branch
- Follow these steps to finish the pull request, which merges all content TO the master branch FROM gh-pages branch:
- Create the pull request (select green button)
- Give it a title (such as “updated index and ReadMe”)
- Send pull request (green button)
- Merge pull request (another green button)
- Confirm merge (and another green button!)
- Always double-check your repository branch names to do editing and live web testing in the gh-pages branch, then make sync a copy to public share in the master branch.
Part 2: Update the Information
- On the main page of the repository, download the zip file. Open the compressed file.
- Open the cwp-37-towns.csv file in the zip. The column number corresponds to the tab number. For example, number 2 means Median age. Change the data and save it as a new csv file
Solution 1: Mapshaper
- Import the geojson file to mapshaper.org by dragging the file to the site’s browser window. Click on the i icon and hover over (NOT clicking on) the map to check if the field that contains towns’ names is named “name”.
- Import the new csv file to mapshaper by dragging the file to the site’s browser window. When a window pops up, select the Import button to add the csv file as a second layer. This table layer will appear as a rectangular cells, because it does not contain geographic information.
- Click the drop-down menu and select the map to display it as the active layer
- Click the Console button, type this command( -join your-new-csv-file-name.csv keys=name,name) and press return
- Click the Export button, select the GeoJSON option to download your new GeoJSON file.
Solution 2: geojson.io: If the merge fail in mapshaper, you can go to the page geojson.io to fix the data manually
- Go to the website geojson.io. If there already exists a file on the website, click New. Click Open and select File to upload your geojson file.
- On the right side of the website, select the Table tab. In here you could directly change the data in that table.Click Save and select GeoJSON to download the new geojson file to your computer.
- Click on the New pull request to see if the master branch and gh-pages branch are similar or not.
- If there is any difference, then do a pull request from gh-pages to master branch.
- Upload the GeoJSON file to the master branch by clicking the Upload button on the main repository page. After dragging the new GeoJSON file to the browser, click the green button Commit changes.
- Do a pull request from master to gh-pages branch
- Go to script.js in the gh-pages branch. Find the line $.getJSON(“cwp-37-towns-v4.geojson”, function (data) and change “cwp-37-towns-v4.geojson” to the name of the new geojson file. Click the Commmit Changes button.
- Go back the the main page of the repository. Do a pull request from gh-pages to master branch.
Delete a Repository
- On the main page of the repository, go to Settings.
- Click on Delete this Repository
- Type in the name of your repository to confirm that you want to delete it.
Reference: Data Visualization for All – Jack Dougherty