Use Python to:
- send a plain text email
- send an email with attachment
- receive and filter emails according to some criteria
| #' Project an sf/sfc object to a generic projected coordinate system | |
| #' @param x an sf or sfc object | |
| #' @param proj a character vector. The projection to use. One of "laea", "aeqd", | |
| #' "utm", "pconic", or "eqdc". | |
| #' @param ellps a character vector. The ellipsoid to use. Select from | |
| #' `sf_proj_info(type = "ellps")`. | |
| #' @param opts a character vector. Additional proj options to pass to the | |
| #' proj string. see details for more information. | |
| #' @return an sf or sfc object | |
| #' @details For further info about the available "generic" projects see: |
| from functools import partial | |
| from textwrap import fill | |
| from scipy.stats import norm, uniform, skewnorm, gaussian_kde, triang | |
| from numpy import ( | |
| array, linspace, quantile, histogram, atleast_2d, mean, std, add | |
| ) | |
| from numpy.lib.stride_tricks import sliding_window_view | |
| from matplotlib.pyplot import subplots, show, rc |
| library(tidyverse) | |
| library(sf) | |
| library(sfnetworks) | |
| library(cluster) | |
| library(crsuggest) | |
| library(tidygraph) | |
| library(ggspatial) | |
| # library(gganimate) | |
| crsuggest::suggest_crs(roxel) | |
| net <- roxel %>% |
| # Download earth data first | |
| # https://www.naturalearthdata.com/http//www.naturalearthdata.com/download/110m/physical/ne_110m_land.zip | |
| library(sf) | |
| library(lwgeom) | |
| library(dplyr) | |
| library(ggplot2) | |
| library(mapview) | |
| # Read the data |
| library(tidyverse) | |
| library(sf) | |
| library(tigris) | |
| # start by picking a state from https://github.com/Microsoft/USBuildingFootprints | |
| # WARNING: these files can be pretty big. using arizona for its copious subdivisions and reasoanable 83MB. | |
| url_footprint <- "https://usbuildingdata.blob.core.windows.net/usbuildings-v1-1/Arizona.zip" | |
| download.file(url_footprint, "Arizona.zip") | |
| unzip("Arizona.zip") |
| # started with `foghorn`, but that comes with dependencies and | |
| # slows down R startup. `browseURL` just barely slows startup, | |
| # even if actual page is slow to load. | |
| check_cran_old <- function(email) { | |
| utils::browseURL( | |
| sprintf( | |
| "https://cran.r-project.org/web/checks/check_results_%s.html", | |
| gsub("[^A-Za-z0-9_:.-]", "_", sub("@", "_at_", email)) | |
| ) ) } |
| library("sf") | |
| library("dplyr") | |
| library("hexbin") | |
| # Linux libertine fint "sf", converted to path with Inkscape, | |
| # added points between existing points 2 times, then turned all segments into straight lines. | |
| # Saved as SVG with absolute coordinates (Preferences > SVG Output > Path Data). | |
| # Loaded coords from SVG source code, remove letters from start and end, and replace " " with "," | |
| coords_f <- c(218.1169,163.46992,215.56952,177.96334,213.51976,189.84421,211.82546,200.33884,210.34442,210.67351,208.24728,226.35176,205.51032,243.54066,201.92029,259.27223,197.26391,270.57846,195.45112,272.90665,193.28288,274.70167,190.97247,275.85687,188.73314,276.26564,187.03291,276.03164,185.79476,275.38887,184.84097,274.42619,183.99382,273.23248,182.45947,271.13533,180.24976,269.10927,177.54243,267.58084,174.51519,266.97658,171.25987,267.58973,169.08867,269.18036,167.87718,271.37526,167.501,273.8012,168.44294,277.0032,171.48203,279.79643,176.93817,281.77214,185.13126,282.52154,191.01986,281.80176,196.83737,279.60686,202.29944, |
Use Python to:
| library(cartography) | |
| library(sp) | |
| library(sf) | |
| # Load data | |
| data(nuts2006) | |
| # Save image | |
| sizes <- getFigDim(x = nuts0.spdf, width = 700, mar = c(0,0,0,0), res = 100) | |
| png('./img/map8.png', width = sizes[1], height = sizes[2], res = 100) |
| require(MASS) | |
| require(ggplot2) | |
| require(scales) | |
| require(gridExtra) | |
| pca <- prcomp(iris[,-5], | |
| center = TRUE, | |
| scale. = TRUE) | |
| prop.pca = pca$sdev^2/sum(pca$sdev^2) |