Skip to content

Instantly share code, notes, and snippets.

@kataya
kataya / globalmaptiles.py
Created March 18, 2024 09:18 — forked from maptiler/globalmaptiles.py
globalmaptiles.py
#!/usr/bin/env python
###############################################################################
# $Id$
#
# Project: GDAL2Tiles, Google Summer of Code 2007 & 2008
# Global Map Tiles Classes
# Purpose: Convert a raster into TMS tiles, create KML SuperOverlay EPSG:4326,
# generate a simple HTML viewers based on Google Maps and OpenLayers
# Author: Klokan Petr Pridal, klokan at klokan dot cz
# Web: http://www.klokan.cz/projects/gdal2tiles/
@kataya
kataya / cal_modulus11.py
Created September 10, 2023 09:12
全国地方公共団体コードにおける「検査数字」の計算方法
#全国地方公共団体コードにおける「検査数字」について
#https://www.j-lis.go.jp/spd/code-address/cms_1750514.html#cd
#
#方式(モジュラス11):
#第1桁から第5桁までの数字に、それぞれ6.5.4.3.2を乗じて算出した積の和を求め、
#その和を11で除し、商と剰余(以下「余り数字」という。)を求めて、11と余り数字との差の下1桁の数字を検査数字とする。
#ただし、積の和が11より小なるときは、検査数字は、11から積の和を控除した数字とする。
#注)
#余り数字が「0」のとき検査数字は「1」。余り数字が「1」のとき検査数字は「0」。余り数字が「10」のとき検査数字は「1」。
#
@kataya
kataya / WebMercatorUtils.py
Last active September 10, 2023 09:15
経度緯度とWeb Mercator XY座標の変換を自前で変換
# https://wiki.openstreetmap.org/wiki/Mercator からPythonでの実装を持ってきてクラスにしたもの
import math
from typing import List
from typing import Tuple
class WebMercatorUtils():
R = 6378137.0
@staticmethod
def lnglat_to_xy(lon :float, lat :float) -> Tuple[float, float]:
"""longitude(経度), latitude(緯度) をもとに WebメルカトルのX, Y座標を計算して返す
class DegreeDecimalUtil():
# 十進度→度分秒へ変換
@staticmethod
def convert_to_decimal(dd :float, mm :float, ss :float):
dd_decimal = dd + mm/60.0 + ss/3600.0
return dd_decimal
# 十進度→度分秒へ変換
@staticmethod
def convert_to_ddmmss(dd_decimal :float):
# 度の整数値を取り出します
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta
name="viewport"
content="initial-scale=1, maximum-scale=1,user-scalable=no"
/>
<title>
PopupTemplate - use functions to set content | Sample | ArcGIS API for
@kataya
kataya / bulk_update_details.py
Created July 13, 2021 00:38 — forked from ecaldwell/bulk_update_details.py
Replace item details for content in ArcGIS Online and Portal for ArcGIS
#!/usr/bin/env python
# Sample Usage
# python bulk_update_details.py -u https://www.arcgis.com -o username -s password -p 'path/to/details.csv'
import argparse
import json
import csv
import requests
@kataya
kataya / ArcPyValidateDFColNames.py
Created April 19, 2021 20:50 — forked from d-wasserman/ArcPyValidateDFColNames.py
Returns pandas dataframe with all col names renamed to be valid ArcGIS table names.
import pandas as pd
import arcpy
def validate_df_names(dataframe,output_feature_class_workspace):
"""Returns pandas dataframe with all col names renamed to be valid arcgis table names."""
new_name_list=[]
old_names=dataframe.columns.names
for name in old_names:
new_name=arcpy.ValidateFieldName(name,output_feature_class_workspace)
new_name_list.append(new_name)
rename_dict={i:j for i,j in zip(old_names,new_name_list)}
@kataya
kataya / Write Geojson To Feature Class.py
Created April 19, 2021 20:47 — forked from d-wasserman/Write Geojson To Feature Class.py
This gist is intended to share a sample worker function to write Geojson to an ArcGIS Feature Class using Arcpy.
def write_geojson_to_records(geojson):
"""Will write geojson to a list of dictionaries with geometry keys holding coordinates and storing the properties
to dictionaries.
@param: geojson- geojson file to write to records."""
gjson_data = json.load(geojson, encoding='utf-8')
records = []
arcpy.AddMessage("Geojson being read by row...")
for feature in gjson_data["features"]:
try:
row = {}