This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Example of loading data from gpkg in zipped folder on Zenodo into R | |
# Data from the repository 'The State of the Urban Forest in New York City - Supplemental Datasets' | |
# at https://zenodo.org/record/5210261 | |
# Load sf package | |
library(sf) | |
# URL to Files on Zenodo | |
vurl <- "/vsizip//vsicurl/https://zenodo.org/record/5210261/files/canopy_streettree_summaries.zip/canopystreettree_supp.gpkg" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
############################################################ | |
#' Compile layers from different gdb files with same, specified prefix, and desired coordinate system | |
#' | |
#' Compiles layers with standard prefix from multiple gdb files (specified by user) into single sf object. | |
#' This was originally developed to get respective layers from separate geodatabases that resulted from running the ACPF toolbox | |
#' into single layers (e.g., all stream reach datasets into one layer, rather than spread across many gdb files) but may have broader applicability. | |
#' (ACPF stands for Agricultural Conservaton Planning Framework; see https://acpf4watersheds.org/toolbox/) | |
#' | |
#' The handling of different projections is currently fairly crude - it just automatically reprojects files to the desired projection | |
#' (even if already in that projection), though that step is generally fairly quick. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(plotly) | |
# Create some fake data - say ownership and land use data with acreage | |
df <- data.frame(ownership=c(rep("private", 3), rep("public",3),rep("mixed", 3)), | |
landuse=c(rep(c("residential", "recreation", "commercial"),3)), | |
acres=c(108,143,102, 300,320,500, 37,58,90)) | |
# Just try some quick pie charts of acreage by landuse and ownership | |
plot_ly(data=df, labels= ~landuse, values= ~acres, type='pie') | |
plot_ly(data=df, labels= ~ownership, values= ~acres, type='pie') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
license: mit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Based on helpful example here: http://felixfan.github.io/download-files/ | |
# Regular NY Download page here: http://gis.ny.gov/gateway/mg/2018/new_york_city/18ic_c_new_york_city_l06_4bd.htm | |
url = "ftp://ftp.gis.ny.gov/ortho/nysdop9/new_york_city/spcs/tiles/" | |
filenames = getURL(url, ftp.use.epsv = FALSE, dirlistonly = TRUE) | |
filenames <- strsplit(filenames, "\r\n") | |
filenames = unlist(filenames) | |
filenames | |
for (filename in filenames) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Related to GIS-StackExchange thread here: https://gis.stackexchange.com/questions/294482/error-quantifying-land-cover-classes-by-polygon-in-postgis?noredirect=1#comment473338_294482 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Import community district boundaries | |
#relies on sf package | |
#ggplot2 plotting should also work, but needs dev version to deal with sf objects | |
cds <- sf::st_read("https://data.cityofnewyork.us/resource/jp9i-3b7y.GeoJSON") | |
#import community profile data - note, you can adjust this line to select specific variables [all are imported by default as written] | |
cdprofiles <- read.csv("https://planninglabs.carto.com/api/v2/sql?format=csv&q=SELECT%20cartodb_id,the_geom,the_geom_webmercator,shared_puma,future_fp_mhhi,current_fp_mhhi,cd_tot_resunits,future_fp_resunits,future_fp_bldg,current_fp_resunits,cd_tot_bldgs,current_fp_bldg,moe_under18_rate_nyc,moe_under18_rate_boro,total_lot_area,lot_area_other_no_data,lot_area_parking,lot_area_open_space,lot_area_public_facility_institution,lot_area_transportation_utility,lot_area_industrial_manufacturing,lot_area_commercial_office,lot_area_mixed_use,lot_area_res_multifamily_elevator,lot_area_res_multifamily_walkup,lot_area_res_1_2_family_bldg,lots_total,lots_other_no_data,lots_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
############# | |
#Windows | |
############# | |
devtools::install_github("tarakc02/rmapzen", ref = "devel") | |
library(rmapzen) | |
options(RMAPZEN_SEARCH_HOST = "http://geosearch.planninglabs.nyc") | |
Sys.setenv("MAPZEN_KEY" = NA) | |
mz_search("1220 Fifth Ave, New York, NY") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
####This code allows pulling of daily TopoWx data from an OpenDap server, coarsely selecting specific days | |
####Opendap Access form at: https://cida.usgs.gov/thredds/dodsC/topowx.html | |
####for ncdf4 to pull from OpenDap, cannot be run on windows unless specifically compiled for such; | |
####see notes in this thread: https://stat.ethz.ch/pipermail/r-help/2015-July/430161.html | |
#Load necessary packages | |
library(raster) | |
library(ncdf4) | |
#Set call to dataset via OpenDap |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pgtable | |
usnps_facilities_parks | |
usdot_facilities_airports | |
dcas_facilities_colp;dot_facilities_parkingfacilities | |
dcas_facilities_colp;omb_facilities_libraryvisits | |
bic_facilities_tradewaste | |
dfta_facilities_contracts;hhs_facilities_proposals | |
acs_facilities_daycareheadstart;doe_facilities_universalprek;dohmh_facilities_daycare | |
doe_facilities_schoolsbluebook;hhs_facilities_proposals | |
nycdoc_facilities_corrections |
NewerOlder