I changed "states" to "nebraska_counties_wgs84" to pull from the correct boundaries array. I also changed the variable name to counties_features instead of state_features since we are now talking about counties. This line converts the geometries inside a topojson into geosjon features.
I used Mapshaper to transfer the Nebraska County Boundaries shapefile into a Topojson file by importing the shp, .dbf, and .shx files into Mapshaper with the "import files" button. I then used the simplify tool to round out some of the complex border lines of Nebraska counties so it would be easier to map. I clicked "export" and choosing a Topojson file.
I checked that it was already projected in WGS 84 by opening the .prg file and investigating to objects in this observable. The file need to be in WGS 84 because most geojson, topojson, and D3 geographic functions assume coordinates are in latitude, longitude format. It will not be able to map the data onto the counties file if it doesn't know where the counties coordinates are.
I uploaded the Nebraska County Boundaries by clicking the attach files in the top right hand corner and then in the code line deleted "states.json" and replaced it with "nebraska_counties_wgs84.json". I read the topojson file by expanding the "object" titles and the "array" titles.
I also changed the object's name from states to counties since we are now listing counties.
I checked that the cvs file "NebraskaPop" was projected in WGS 84 in the .prg file and then I attached the file by clicking on the paperclip icon in the right corner of the screen and chose the file. I deleted the previous file attachment in the code line and replaced it with "NebraskaPop.csv". I also changed the attributes to match the Nebraska Population file which are CTYNAME, AGE18PLUS_TOT, and POPESTIMATE. This creates a percentage of the people over 18 years of age in each county by dividing the age 18 plus by the population estimate of each county. It is written to create a variable from existing variables with the division and multiplying by 100 to get a percentage. Normalization is important because getting ratios from the data is the correct way to be able to compare data to one another while considering multiple variables. We can look into the arrays and see which counties have what percentage.
I changed d[1][1] to d[1] because there is not an array at d[1]. I instead want to access the second element of each array of d, which is thenumber of people over 18 and the population estimate. This results in an array of all of the percentages of each counties population over 18.
This line creates a mapping between the elements in csv_data, where the countyID is mapped to the percentage of pop over 18. I changed the title to reflect this.
This line imports the topojson library into the project. The library provides tools for manipulating and converting topojson files. The line assigns the topojson variable to an object that contains the functions for doing such tasks.
A Geojson file stores each geographic feature independently which means that shared borders are duplicated and this makes files larger but keeps the format simpler and more widely supported. Topojson stores shared boundaries just once using topology which gives us smaller file sizes and better efficiency for larger maps.