In order to transform spatial data into a TopoJSON or a GeoJSON, we were taught to utilize the website Mapshaper. This website allows the user to upload .shp, .dbf. and .prj files into the software, simplify the polygons (reduces file size by reducing number of vertices in the data) and then export this original shapefile to either TopoJSON or GeoJSON formats. Mapshaper also allows this simplification of shapefiles with the topology preserved.
TopoJSONs and GeoJSONs are very similar in the capacity they have for data storage and manipulation, albeit both with different strengths and weaknesses. TopoJSONs' main advantages come from a reduced file size compared to GeoJSONs as this format is encoded using fixed-precision integers rather than coordinates. As GeoJSONs store coordinates, the encoding can involved a varied range of data types: Point, LineString, Polygon, MultiPoint, MultiLineString, and MultiPolygon. Both formats store spatial information, TopoJSONs are also a more consolidated package that saves memory space. GeoJSONs are simpler to work (less work to use Python with in d3) with when the user is not worried about this space, but they also do not have the capacity for topology preserving simplification.
To upload either a GeoJSON or TopoJSON within ObservableHQ, the user must first convert a shapefile into either JSON format using online converters such as Mapshaper or the "save as" feature in QGIS. Once these files are converted, uploading them into ObservableHQ is as simple as clicking the paper-clip icon on the right hand side of the screen, hitting the + sign next to file attachments, and attaching the desired JSON file. Once the file is uploaded within ObservableHQ like this, it is ready to be utilized within a workbook. To read my topojson in this example, wanted my spatial data for Texas to be listed as "counties". The line beginning with just that, "counties", above is where the JSON file gets read in this workbook. The FileAttachment.json command with the file listed within the parentheses ensured the workbook was reading the converted JSON of Texas' counties.
Uploading csv files into ObservableHQ is as simple as locating a csv from wherever it is being stored on a machine into the ObservableHQ software. In order to read this csv, however, it is slightly more complicated than uploading the JSONs earlier in this workbook. In order to read the csv correctly for this assignment, we used a software called D3 to provide a csv parse tool. The code above shows that we created "csv_data" using the D3 command "csvParse". This command essentially takes the raw plain text from a csv and converts it into meaningful values that are compatible with the software, whereas without this command, the data within the csv would be meaningless to ObservableHQ.
This line demonstrates how to create a new variable from our existing variables that were established in the line above, beginning with "csv_data". Most of the work was actually done in there, with the normalization simply being executed in this line being commented on. In the command prior, I listed the variables I knew I wanted to use for normalization from my csv within a nested query. These included the county FIPS codes, the high school graduation percentage by county, and county total populations. I also provided the equation for normalization, which is just a simple calculation to find the percentage of high school graduates by county. The command directly above makes sense of this nested query to turn it into "texascounties_percentHSgrad", creating an array to list each county with this normalized data for each county of Texas. Normalization of data is important as it allows for data within different formats and files to be organized in a way where they can be manipulated to tell a story together. In this workbook alone we have normalized data- combining spatial data of Texas and texas county education data from a csv to help paint a picture for an important aspect of education in every state- its high school graduate numbers.