Skip to content

Instantly share code, notes, and snippets.

View RalucaNicola's full-sized avatar
🌍

Raluca Nicola RalucaNicola

🌍
View GitHub Profile
@RalucaNicola
RalucaNicola / index.html
Last active November 22, 2019 21:44
Prototype for elections map
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<style>
body {
font-family: Arial, Helvetica, sans-serif;
color: #444;
}
esriConfig.portalUrl = "http://jsapi.maps.arcgis.com/";
const scene = new WebScene({
portalItem: {
id: "2e38f798f3124f2dae84217839cc43dc"
}
});
const start = new Date(1900, 0, 1);
const end = new Date(2020, 0, 1);
const timeSlider = new TimeSlider({
container: "timeContainer",
mode: "cumulative-from-start",
fullTimeExtent: {
start: start,
end: end
},
const sketchLayer = new GraphicsLayer({
elevationInfo: {
mode: "on-the-ground"
}
});
webscene.add(sketchLayer);
const sketchViewModel = new SketchViewModel({
layer: sketchLayer,
view: view
sketchViewModel.on("create", function (event) {
if (event.state === "complete") {
const geometry = event.graphic.geometry;
buildingLayerView.filter = {
geometry: geometry,
spatialRelationship: "contains"
};
}
});
@RalucaNicola
RalucaNicola / set-camera.js
Created July 16, 2020 16:20
How to set a camera in ArcGIS API for JavaScript
const view = new SceneView({
container: "viewDiv",
map: map,
camera: {
heading: 90, // face due east
tilt: 45, // looking from a bird's eye view
position: {
latitude: 38,
longitude: -122,
z: 20000
(function() {
const view = require("esri/views/View").views.getItemAt(0);
const p = view.camera.position;
if (p.spatialReference.isWebMercator || p.spatialReference.isWGS84) {
console.log(`
{
position: [
${p.longitude.toFixed(8)},
${p.latitude.toFixed(8)},
function rotate() {
if (!view.interacting) {
const camera = view.camera.clone();
camera.position.longitude -= 0.2;
view.goTo(camera, { animate: false });
requestAnimationFrame(rotate);
}
}
view.when(function () {
function rotate() {
if (!view.interacting) {
view.goTo({
heading: view.camera.heading + 0.1,
center: view.center
}, {animate: false});
requestAnimationFrame(rotate);
}
}
@RalucaNicola
RalucaNicola / main.py
Created April 19, 2022 19:49
Orbital computations
import pandas as pd
from skyfield.api import load
from datetime import timedelta
from math import isnan, pi, sqrt, atan2, sin, cos
from geojson import FeatureCollection, Feature, LineString, dump
from arcgis.gis import GIS
#constants
ts = load.timescale()
now = ts.now()