Skip to content

Instantly share code, notes, and snippets.

@apfister
apfister / convert timestamp to string.py
Created March 29, 2023 23:35
convert a timestamp value to a string
from datetime import datetime
ts = 1546734359
n = datetime.fromtimestamp(ts)
date_formatted = n.strftime('%Y-%m-%d %H:%M:%S')
# print(date_formatted)
return date_formatted
@apfister
apfister / fs-multiple-layers-python-api
Last active October 6, 2022 21:01
Publish a Feature Service with multiple layers from a spatial data frame or multiple frames
# create an empty service
create_params = { ... }
created_item = gis.content.create_service(name=create_params['name'] , create_params=create_params)
# get a reference to the base feature service
ci_fl = FeatureLayer(created_item.url)
# create a feature collection from your dataframe
fc = final_df.spatial.to_feature_collection()
This file has been truncated, but you can view the full file.
[
{
indicator: "8.5.1",
year: "2019",
category: "Age",
subcategory: "25 years old and over",
name: "Alaska",
geoid: "0400000US02",
uuid: "65f89160-f03b-409b-9e44-36b8f07b6cbc",
parentgeoid: "0100000US",
// item id of the first layer you want to use
var itemId1 = '67959bfbb58e400d80a2dc1be3542338';
// item id of the second layer you want to use
var itemId2 = '22a65ba4870a41a69ed0d8d843480d3c';
var layerId = 0;
var portalUrl = 'https://www.arcgis.com';
var fieldList = ['time_period', 'obs_value'];
// here is my original data format
{
PERCENT_BELOW_POVERTY_LEVEL_AMERICAN_INDIAN_AND_ALASKA_NATIVE_ALONE_P_2015: 52.2
PERCENT_BELOW_POVERTY_LEVEL_AMERICAN_INDIAN_AND_ALASKA_NATIVE_ALONE_P_2016: 39.6
PERCENT_BELOW_POVERTY_LEVEL_AMERICAN_INDIAN_AND_ALASKA_NATIVE_ALONE_P_2017: 42.2
PERCENT_BELOW_POVERTY_LEVEL_AMERICAN_INDIAN_AND_ALASKA_NATIVE_ALONE_P_2018: 40.7
PERCENT_BELOW_POVERTY_LEVEL_AMERICAN_INDIAN_AND_ALASKA_NATIVE_ALONE_P_2019: 8.6
}
// can i transform it to something like this?
.container {
padding: 2%;
min-height: 400px;
text-align: left;
position: relative;
vertical-align: top;
/* add these below to get the cards top-aligned */
display: flex;
flex-wrap: wrap;
require(['dojo/topic'], function(topic) {
/*
* Custom Javascript to be executed while the application is initializing goes here
*/
// function to get the query params from the URL
var getQueryStringValue = function(key) {
return decodeURIComponent(window.location.search.replace(new RegExp('^(?:.*[&\\?]' + encodeURIComponent(key).replace(/[\.\+\*]/g, '\\$&') + '(?:\\=([^&]*))?)?.*$', 'i'), '$1'));
};
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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.