Skip to content

Instantly share code, notes, and snippets.

View Rubix982's full-sized avatar
:octocat:
🇵🇰

Saif Ul Islam Rubix982

:octocat:
🇵🇰
View GitHub Profile
@Rubix982
Rubix982 / caching_algorithms.nginx.conf
Created June 18, 2023 10:40
Caching Algorithms, NGINX, with help from the NGINX Community, Medium, GPT, OReilly
# Base
server {
list 8080:
server_name localhost;
location / {
proxdy_pass $BACKEND_URL;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_cache_bypass $http_upgrade;
@Rubix982
Rubix982 / postgis_docker_compose.yml
Created September 9, 2022 19:27
Example of how to use the docker container for postgis by kartoza with docker compose, https://github.com/kartoza/docker-postgis.
version: "3.9"
services:
postgis:
image: "kartoza/postgis:14-3.3--v2022.08.30" # postgresql 14.0, postgis 3.3
environment:
- "POSTGRES_USER=fotoshi"
- "POSTGRES_PASS=chris"
- "POSTGRES_DBNAME=gis"
- "POSTGRES_INITDB_WALDIR=/opt/postgres/pg_wal"
@Rubix982
Rubix982 / Working With GIS & Mapillary - Getting Images.py
Created August 15, 2022 12:38
Fetching images from the server
import os
import requests
from PIL import Image
from urllib.request import urlopen
all_images = []
os.makedirs('img')
for iter in image_id_list:
import matplotlib
import numpy
import typing
matplotlib.pyplot.tick_params(
axis='x', # changes apply to the x-axis
which='both', # both major and minor ticks are affected
bottom=False, # ticks along the bottom edge are off
top=False, # ticks along the top edge are off
labelbottom=False
# Lets first save all of the data as a JSON
with open('image_id_list.json', 'w') as file_pointer:
json.dump(image_id_list, file_pointer, indent=4)
# For each collection item, lets remove the property data to get a smaller JSON version
for iter in image_id_list:
del iter['property_data']
# Lets save this version of the data as a JSON to recollect at any point in time
with open('image_id_list_without_property.json', 'w') as file_pointer:
@Rubix982
Rubix982 / Working With GIS & Mapillary - Property & Thumbnail.py
Created August 15, 2022 10:35
Getting the properties and separating out the thumbnails
import json
from mapillary.models.client import Client
from mapillary.config.api.entities import Entities
# Useful list of fields we can use
# For a complete list of possible values, please visit the below link
# https://mapillary.github.io/mapillary-python-sdk/docs/mapillary.config.api/mapillary.config.api.entities#static-get_imageimage_id-str-fields-list
fields_to_pass_for_the_image: list = ['thumb_2048_url', 'merge_cc', 'mesh',
'sfm_cluster', 'atomic_scale',
'camera_parameters', 'camera_type',
# import the geojson model from mapillary
from mapillary.models.geojson import GeoJSON
image_id_list: list = []
# Iterating over the rows of the df
for index, row in enumerate(safegraph_df.iterrows()):
# An empty dictionary that will hold our data as we go along
coordinates_to_image_id_dict: dict = {}
!pip install mapillary
data = mly.get_image_looking_at(
looker={
"lng": 21.3967128843,
"lat": 41.9946319051,
},
at={
"lng": 21.3967117108,
"lat": 41.9946228527,
},
radius=1000000,