Skip to content

Instantly share code, notes, and snippets.

class _aabb:
def __init__(self, _from, _to):
self._from = tuple(map(min, zip(_from, _to)))
self._to = tuple(map(max, zip(_from, _to)))
def __iter__(self):
return iter((*self._from, *self._to))
@property
def width(self):

output.png

plot

df.head()

theta r
0 3.4483 1.17782
1 4.49367 0.770008
@tomowarkar
tomowarkar / main.py
Created September 4, 2022 16:38
石川県の色塗り
import fiona
import matplotlib.cm as cm
import pandas as pd
from matplotlib.colors import to_hex
from staticmap import Polygon, StaticMap
# src: https://nlftp.mlit.go.jp/ksj/gml/datalist/KsjTmplt-N03-v3_1.html
c = fiona.open("N03-20220101_17_GML/N03-22_17_220101.shp", "r")
df = pd.DataFrame(c)
import pandas as pd
import matplotlib.pyplot as plt
from matplotlib.colors import Normalize, to_hex
import folium
from folium import FeatureGroup, LayerControl
from folium.plugins import Search
# python3 -m pip uninstall gistools -y

GISTOOLS

install

python3 -m pip uninstall gistools -y 
python3 -m pip install git+https://gist.github.com/tomowarkar/598768818ed7d2e6ca94f4011dc065a6

example

@tomowarkar
tomowarkar / distance.md
Last active July 24, 2022 01:27
緯度軽度でNearestNeighborsを使う

2地点間距離を求めたい

2地点間距離

import math
from sklearn.neighbors import DistanceMetric
@tomowarkar
tomowarkar / code.py
Last active July 21, 2022 16:49
MeshCode search
import pandas as pd
import numpy as np
from itertools import product
import folium
from folium import FeatureGroup, LayerControl
from folium.plugins import Search
@tomowarkar
tomowarkar / mesh_mario.py
Created July 8, 2022 13:52
地域メッシュコードでマリオが描きたかった
import itertools
from functools import lru_cache
from PIL import Image, ImageDraw
from staticmap import CircleMarker
from staticmap import StaticMap as _StaticMap
from staticmap.staticmap import _lat_to_y, _lon_to_x
class Mesh:
@dataclass
class Maze:
width = 12
height = 8
def maze_renderer(m: Maze, conf: GameConf):
px_size = min(conf.window_width//m.width, conf.window_height//m.height)
suf = pygame.Surface((px_size*m.width, px_size*m.height))
for x in range(0, px_size*m.width, px_size):
@tomowarkar
tomowarkar / smoke.py
Created December 31, 2021 11:35
pygame smoke effect
# ispired by: https://www.youtube.com/watch?v=n-tLlBNgS3g
import random
import sys
from contextlib import contextmanager
import pygame
Vec2 = pygame.math.Vector2
FPS = 60