Skip to content

Commit

Permalink
ch 2 update
Browse files Browse the repository at this point in the history
  • Loading branch information
vzrg-tamu committed Jan 29, 2024
1 parent 805e1f7 commit e3fcdb0
Show file tree
Hide file tree
Showing 192 changed files with 19,523 additions and 21,208 deletions.
2 changes: 2 additions & 0 deletions SampleData-master/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto
1 change: 1 addition & 0 deletions SampleData-master/CMIP_land/CMIP_land.cpg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
UTF-8
Binary file added SampleData-master/CMIP_land/CMIP_land.dbf
Binary file not shown.
1 change: 1 addition & 0 deletions SampleData-master/CMIP_land/CMIP_land.prj
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]]
Binary file added SampleData-master/CMIP_land/CMIP_land.sbn
Binary file not shown.
Binary file added SampleData-master/CMIP_land/CMIP_land.sbx
Binary file not shown.
Binary file added SampleData-master/CMIP_land/CMIP_land.shp
Binary file not shown.
2 changes: 2 additions & 0 deletions SampleData-master/CMIP_land/CMIP_land.shp.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<metadata xml:lang="en"><Esri><CreaDate>20200813</CreaDate><CreaTime>23083700</CreaTime><ArcGISFormat>1.0</ArcGISFormat><SyncOnce>TRUE</SyncOnce><DataProperties><lineage><Process ToolSource="c:\program files (x86)\arcgis\desktop10.4\ArcToolbox\Toolboxes\Data Management Tools.tbx\CalculateField" Date="20200717" Time="180529">CalculateField CMIP6_land2 V4 !FID! PYTHON_9.3 #</Process><Process ToolSource="c:\program files (x86)\arcgis\desktop10.4\ArcToolbox\Toolboxes\Data Management Tools.tbx\CalculateField" Date="20200717" Time="180540">CalculateField CMIP6_land2 V4 !FID!+1 PYTHON_9.3 #</Process></lineage></DataProperties></Esri></metadata>
Binary file added SampleData-master/CMIP_land/CMIP_land.shx
Binary file not shown.
8,900 changes: 8,900 additions & 0 deletions SampleData-master/Largescale_geospatial_analysis_2022.html

Large diffs are not rendered by default.

9,213 changes: 9,213 additions & 0 deletions SampleData-master/Largescale_geospatial_analysis_2023.html

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions SampleData-master/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# SampleData-master
Sample dataset for large-scale data visualization workshop.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
1 change: 1 addition & 0 deletions SampleData-master/USA_states/cb_2018_us_state_5m.cpg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
UTF-8
Binary file not shown.
1 change: 1 addition & 0 deletions SampleData-master/USA_states/cb_2018_us_state_5m.prj
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
GEOGCS["GCS_North_American_1983",DATUM["D_North_American_1983",SPHEROID["GRS_1980",6378137,298.257222101]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]]
Binary file not shown.
310 changes: 310 additions & 0 deletions SampleData-master/USA_states/cb_2018_us_state_5m.shp.ea.iso.xml

Large diffs are not rendered by default.

531 changes: 531 additions & 0 deletions SampleData-master/USA_states/cb_2018_us_state_5m.shp.iso.xml

Large diffs are not rendered by default.

Binary file added SampleData-master/USA_states/cb_2018_us_state_5m.shx
Binary file not shown.
47 changes: 47 additions & 0 deletions SampleData-master/functions/mat2ras.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
mat2ras=function(mat, Longitude, Latitude, plot_ind){
# Converts a matrix to raster using Lat-long vectors and 2-d matrix of the dataset.

#Import libraries
require(reshape2)
require(maps)

row.names(mat)=Longitude #Assign rownames as Longitude
colnames(mat)=Latitude #Assign colnames as Latitudes
xyz=melt(mat) # Create an X-Y-Z dataframe
ncol=length(Longitude)
nrow= length(Latitude)

colnames(xyz)= c("x", "y", "z")

# Create a sample raster
dat = raster(
xmn = 1, xmx = ncol,
ymn = 1, ymx = nrow,
nrows = nrow,
ncols = ncol,
vals = xyz$z)

library(maps)
# specify CRS to be used
crs.latlon = CRS("+proj=longlat +datum=WGS84")
nrow = dim(dat)[1]
ncol = dim(dat)[2]

# get extent of the domain
ext = extent(xyz[, c('x', 'y')])

# create a raster for extent with nrow and ncol
rast = raster(
ext, nrow = nrow, ncol = ncol,
crs = crs.latlon)

# rasterize the data values
rast = rasterize(
xyz[, c('x', 'y')], rast,
xyz[, 'z'], fun=mean)

if (plot_ind==TRUE){
plot(rast)
}
return(rast)
}
105 changes: 105 additions & 0 deletions SampleData-master/functions/robin_ras.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
robin_ras=function(ras, map_col,name,brk,lim,na.rm=T){
#############################################
# ======================================================================================
# Create a simple world map in Robinson projection with labeled graticules using ggplot
# ======================================================================================
#Source code edited from:
#https://seethedatablog.wordpress.com/2016/12/23/r-simple-world-map-robinson-ggplot/

# Set a working directory with setwd() or work with an RStudio project
# __________ Set libraries
library(rgdal) # for spTransform() & project()
library(ggplot2) # for ggplot()

# __________ Load ready to use data from GitHub
load(url("https://github.com/valentinitnelav/RandomScripts/blob/master/NaturalEarth.RData?raw=true"))
# This will load 6 objects:
# xbl.X & lbl.Y are two data.frames that contain labels for graticule lines
# They can be created with the code at this link:
# https://gist.github.com/valentinitnelav/8992f09b4c7e206d39d00e813d2bddb1
# NE_box is a SpatialPolygonsDataFrame object and represents a bounding box for Earth
# NE_countries is a SpatialPolygonsDataFrame object representing countries
# NE_graticules is a SpatialLinesDataFrame object that represents 10 dg latitude lines and 20 dg longitude lines
# (for creating graticules check also the graticule package or gridlines fun. from sp package)
# (or check this gist: https://gist.github.com/valentinitnelav/a7871128d58097e9d227f7a04e00134f)
# NE_places - SpatialPointsDataFrame with city and town points
# NOTE: data downloaded from http://www.naturalearthdata.com/
# here is a sample script how to download, unzip and read such shapefiles:
# https://gist.github.com/valentinitnelav/a415f3fbfd90f72ea06b5411fb16df16

# __________ Project from long-lat (unprojected data) to Robinson projection
# spTransform() is used for shapefiles and project() in the case of data frames
# for more PROJ.4 strings check the followings
# http://proj4.org/projections/index.html
# https://epsg.io/

PROJ <- "+proj=robin +lon_0=0 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs"
# or use the short form "+proj=robin"
NE_countries_rob <- spTransform(NE_countries, CRSobj = PROJ)
NE_graticules_rob <- spTransform(NE_graticules, CRSobj = PROJ)
NE_box_rob <- spTransform(NE_box, CRSobj = PROJ)

# project long-lat coordinates for graticule label data frames
# (two extra columns with projected XY are created)
prj.coord <- rgdal::project(cbind(lbl.Y$lon, lbl.Y$lat), proj=PROJ)
lbl.Y.prj <- cbind(prj.coord, lbl.Y)
names(lbl.Y.prj)[1:2] <- c("X.prj","Y.prj")

prj.coord <- rgdal::project(cbind(lbl.X$lon, lbl.X$lat), proj=PROJ)
lbl.X.prj <- cbind(prj.coord, lbl.X)
names(lbl.X.prj)[1:2] <- c("X.prj","Y.prj")
pr <- projectRaster(ras, crs=PROJ, method='bilinear',res=36000)

# IMPORT SHAPEFILE
cropped <- crop(x = pr, y = extent(NE_countries_rob))
masked <- mask(x = cropped, mask = NE_countries_rob)
#plot(masked)

test_spdf <- as(masked, "SpatialPixelsDataFrame")
test_df <- as.data.frame(test_spdf)
colnames(test_df) <- c("value", "x", "y")

# __________ Plot layers
plt=ggplot() +
# add Natural Earth countries projected to Robinson, give black border and fill with gray
geom_polygon(data=NE_countries_rob, aes(long,lat, group=group),
colour="black", fill="gray80", size = 0.25) +
# Note: "Regions defined for each Polygons" warning has to do with fortify transformation. Might get deprecated in future!
# alternatively, use use map_data(NE_countries) to transform to data frame and then use project() to change to desired projection.
# add Natural Earth box projected to Robinson
geom_polygon(data=NE_box_rob, aes(x=long, y=lat), colour="black", fill="transparent", size = 0.25) +
# add graticules projected to Robinson
geom_path(data=NE_graticules_rob, aes(long, lat, group=group), linetype="dotted", color="grey50", size = 0.25) +
# add graticule labels - latitude and longitude
geom_text(data = lbl.Y.prj[c(TRUE, FALSE),], aes(x = X.prj, y = Y.prj, label = lbl), color="grey50", size=2.5) +
geom_text(data = lbl.X.prj[c(TRUE, FALSE),], aes(x = X.prj, y = Y.prj, label = lbl), color="grey50", size=2.5) +
# the default, ratio = 1 in coord_fixed ensures that one unit on the x-axis is the same length as one unit on the y-axis
coord_fixed(ratio = 1) +
geom_tile(data=test_df, aes(x=x, y=y, fill=value),alpha=1)+
scale_fill_gradientn(colors=
rev(map_col),
name = " ",
na.value = "transparent",
#labels=c("Minimum",0.5,"Maximum"),
breaks=brk,
limits=lim)+
geom_polygon(data=NE_countries_rob, aes(long,lat, group=group),
colour="black", fill="transparent", size = 0.25) +
# remove the background and default gridlines
theme_void()+
theme(plot.title = element_text(hjust = 0.5,size =12, face = "bold"),
legend.position="bottom",
legend.key.width=unit(1.8, "cm"),
legend.key.height=unit(0.4, "cm"),
legend.text=element_text(size=16))+
ggtitle(name)
plt

# REFERENCES:
# This link was useful for graticule idea
# http://stackoverflow.com/questions/38532070/how-to-add-lines-of-longitude-and-latitude-on-a-map-using-ggplot2
# Working with shapefiles, projections and world maps in ggplot
# http://rpsychologist.com/working-with-shapefiles-projections-and-world-maps-in-ggplot
return(plt)
}

Binary file added SampleData-master/images/Basic_operators.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added SampleData-master/images/CC_license.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added SampleData-master/images/LSUlogo.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added SampleData-master/images/Layerwiseoperation.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added SampleData-master/images/SpatialDataIntro.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added SampleData-master/images/Stack2022.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added SampleData-master/images/TAMU_Box-Stack.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added SampleData-master/images/cellwiseoperation.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added SampleData-master/images/cover_v1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added SampleData-master/images/cover_v2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added SampleData-master/images/cover_v3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added SampleData-master/images/git_repo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added SampleData-master/images/list_visual.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added SampleData-master/images/projection_families.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added SampleData-master/images/recap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added SampleData-master/images/stack2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added SampleData-master/images/stack3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added SampleData-master/location_points.xlsx
Binary file not shown.
Loading

0 comments on commit e3fcdb0

Please sign in to comment.