Git Product home page Git Product logo

robwiederstein / ky_hist_markers Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 503 KB

Kentucky, like many states, maintains a historical marker database(KHMD). Scraping the database yielded 2226 total markers which were plotted to the center of the county located.

License: MIT License

R 0.55% HTML 0.24% JavaScript 99.22%
r leaflet leaflet-markercluster geojson rvest stringr mapping gis kentucky data-visua

ky_hist_markers's Introduction

Kentucky's Historical Markers


map of kentucky See article.

About the Project

Kentucky maintains a historical marker database(KHMD). This project is in two discrete parts: the building of a dataframe for the map markers and the display of the markers on a leaflet map.

The KHMD fields are not assigned separate html containers so the effort transformed from web scraping (rvest) to a regex (stringr) exercise. Or, in other words, it was a jumbled mess. However, the information is both extensive and informative. The primary constraint for the mapping of Kentucky’s historic markers was the lack of coordinates.

Scraping the database yielded 2226 total markers. The markers are numbered between 1 and 2,610. There are 412 that are not included in the database for whatever reason, including poor execution on my part. The database did have the county where the markers are located so the center of each county was computed and the markers were assigned there.

For most counties that worked pretty well. For example, the center of Jefferson County is Louisville and locating the markers there worked well. However, they were stacked on top of each other. Jefferson County has 228 markers.

With 228 markers assigned the same coordinates, the "pop-up" contents were not easily viewed. A minimal amout of random noise was introduced ("jitter") so the pop-up contents could be displayed. This ended up with markers placed on the top of strip malls and car dealerships. The map tiles were changed to Stamen so that building outlines were excluded.

Built With

Prerequisites

The header code must reference jquery, leaflet and leaflet market-cluster. Leaflet, mentioned above, has excellent documentation. Crucial for the markers to cluster on the Stamen map are the following lines of code added to the header of the webpage:

<!--stylesheets load first-->
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.6.0/leaflet.css" />
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/leaflet.markercluster/1.4.1/MarkerCluster.css" />
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/leaflet.markercluster/1.4.1/MarkerCluster.Default.css" />
<!--scripts load next-->
<script type='text/javascript' src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js'></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.6.0/leaflet.js"></script>
<script type='text/javascript' src='https://cdnjs.cloudflare.com/ajax/libs/leaflet.markercluster/1.4.1/leaflet.markercluster.js'></script>
<script type='text/javascript' src="https://cdnjs.cloudflare.com/ajax/libs/leaflet-providers/1.9.1/leaflet-providers.min.js"></script>

Dependencies

Kentucky counties were added as a layer to the map from the Kentucky Open GIS portal. An API for the full geojson feature collection is available here.

Installation


#install.packages("devtools")
devtools::install_github("RobWiederstein/my_functions")

#customize
git init
git clone https://github.com/RobWiederstein/my_functions.git

License

Distributed under the MIT License. See LICENSE for more information.

Contact

Rob Wiederstein @RobWiederstein - [email protected]

Project Link: https://github.com/RobWiederstein/covid-19-ky

Acknowledgements

ky_hist_markers's People

Contributors

robwiederstein avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.