Skip to content

Instantly share code, notes, and snippets.

View toebR's full-sized avatar
🏠
Working from home

Tobias Stalder toebR

🏠
Working from home
View GitHub Profile
@toebR
toebR / ZoomToTargetBKMK.py
Created November 15, 2023 09:13
Zoom to Bookmark in an AGP Project
import arcpy
def ZoomToTargetBKMK(BookmarkNr):
aprx = arcpy.mp.ArcGISProject(r"CURRENT")
MapView = aprx.activeView
Map = MapView.map
TargetBkmk = Map.listBookmarks()[BookmarkNr]
print("Target bookmark: {}".format(TargetBkmk.name))
MapView.zoomToBookmark(TargetBkmk)
@toebR
toebR / LibAndInitInst.R
Created November 9, 2023 15:11
check libPath and add pkg to baseEnv
.libPaths
packages <- c("tidyverse",
"sf",
)
package.check <- lapply(
packages,
FUN = function(x) {
@toebR
toebR / DisVis.py
Created September 6, 2023 07:43
python code (console) to disable vibility of all layers in the current ArcGisPro Project
import arcpy
aprx = arcpy.mp.ArcGISProject("Current")
m = aprx.listMaps("Map")[0]
layers = m.listLayers()
for layer in layers:
layer.visible = False
# Rayshader basic workflow
# By Tobias Stalder
# October 2022
# Creative Commons licence (Free to use - Reference Author in Code by Publication)
# libraries ---------------------------------------------------------------
memory.limit(size=4000000000) #set memory limit
@toebR
toebR / pd_gdb.py
Created October 24, 2022 10:48
data wrangling basics in python pandas
import geopandas as gpd
import pandas as pd
import numpy as np
from matplotlib import pyplot as plt
#set pandas options so that all column names are diplayed when printes
pd.set_option('display.max_columns', None)
pd.set_option('display.max_rows', None)
######load gdb with arcpy and convert to pd dataframe#########
@toebR
toebR / Arcpy_in_Rmarkdown.Rmd
Last active August 10, 2022 13:35
Work with arcpy in Rmarkdown using reticulate
# work with arcpy in Rmarkdown or Rscript using reticulate
#set up python version in R
```{r}
library(reticulate)
use_python("C:/Python27/ArcGIS10.7/python.exe", required = TRUE)
```
#check Sysinfo
```{python engine.path="C:/Python27/ArcGIS10.7/python.exe"}
#a snippet for quick plots of LIDAR data in ggplot2
#Tobias Stalder
#June 2021
#load libraries
library(tidyverse)
library(rlas)
library(gg3D)
#load data
@toebR
toebR / eco_river_palette.md
Last active August 20, 2020 14:37
6 color green-turquoise palette for discrete variables

#By Tobias Stalder #August 2020

library(scales)

eco_river_pal <- c("#d0ece7", "#a9dfbf", "#73c6b6", "#27ae60", "#117a65",