Skip to content

Instantly share code, notes, and snippets.

View Zia-'s full-sized avatar
๐Ÿ™
I might be slow in response.

Mohammed Zia Zia-

๐Ÿ™
I might be slow in response.
View GitHub Profile
import math
from xml.dom import minidom
def coord(way_id):
abs_file_path = "/Users/zia/Documents/Test/osm_road_length_data/itu_maslak.osm";
xmldoc = minidom.parse(abs_file_path)
way = xmldoc.getElementsByTagName("way")
def node_coord(node_id):
node = xmldoc.getElementsByTagName("node")
from lxml import etree as et
from bz2file import BZ2File
from lxml.etree import tostring
path = "<path-to-osm.bz2-dir>/planet.osm.bz2"
path_nodes = "<path-to-osm.bz2-dir>/planet_nodes.osm"
str = '';
with BZ2File(path) as xml_file:
with open(path_nodes, 'w') as f:
@Zia-
Zia- / select_osm_ways_given_wayId.py
Last active April 21, 2016 12:49
You are given a list of osm ways' ID and you want to collect only them, along with corresponding nodes, to generate new osm file. Run this python. Will generate two files, final_osmfile.osm is the one you want at the end. You can generate selected_ways.txt by simply clicking the required ways in JOSM and pressing ctrl+c and ctrl+v.
from xml.dom import minidom
from osgeo import ogr
import os, re
proj_dir = os.getcwd()
rel_file_path = "initial_osmfile.osm";
abs_file_path = os.path.join(proj_dir, rel_file_path)
xmldoc = minidom.parse(abs_file_path)
node = xmldoc.getElementsByTagName("node")
import csv
from xml.dom import minidom
from osgeo import ogr
import os
from lxml.etree import tostring
# OSM data of Dar Es Salam can be downloaded from http://overpass.osm.rambler.ru/cgi/xapi_meta?*[bbox=39.0640,-7.1170,39.5269,-6.5767]
path_org = "<path to osm file>/planet.osm"
path_final = "<path to osm file>/planet_nodes.osm"
xmldoc = minidom.parse(path_org)
import csv
from xml.dom import minidom
from osgeo import ogr
import os, sys
abs_file_path = "<path_to_planet_osm_file>/planet.osm";
xmldoc = minidom.parse(abs_file_path)
json_list = list()
<?xml version="1.0" encoding="UTF-8"?>
<osm version="0.6" generator="CGImap 0.0.2">
<bounds minlat="54.0889580" minlon="12.2487570" maxlat="54.0913900" maxlon="12.2524800"/>
<node id="298884269" lat="54.0901746" lon="12.2482632" user="SvenHRO" uid="46882" visible="true" version="1" changeset="676636" timestamp="2008-09-21T21:37:45Z"/>
<node id="261728686" lat="54.0906309" lon="12.2441924" user="PikoWinter" uid="36744" visible="true" version="1" changeset="323878" timestamp="2008-05-03T13:39:23Z"/>
<node id="1831881213" version="1" changeset="12370172" lat="54.0900666" lon="12.2539381" user="lafkor" uid="75625" visible="true" timestamp="2012-07-20T09:43:19Z">
<tag k="name" v="Neu Broderstorf"/>
<tag k="traffic_sign" v="city_limit"/>
</node>
<node id="298884272" lat="54.0901447" lon="12.2516513" user="SvenHRO" uid="46882" visible="true" version="1" changeset="676636" timestamp="2008-09-21T21:37:45Z"/>
1. # Open cron command
sudo crontab -e
2. # Paste the following line at the very end to execute above script after every 5 min.
# More details about this at http://www.cyberciti.biz/faq/how-do-i-add-jobs-to-cron-under-linux-or-unix-oses/
*/5 * * * * /usr/bin/python2.7 /var/www/html/maps/firemap/realdata-geojson/viirs/pullViirsData.py
3. # That's it. It will even run on system reboot.
from ftplib import FTP
import datetime, os, h5py, json
import matplotlib.pyplot as plt
import numpy as np
ftpUrl = 'ftp url'
user = 'username'
passwd = 'password'
basePath = 'seviri lsa path in 194 server'
baseFileName = 'name of seviri list product'
import os, time, csv, json
modisc6GlobalUrl = "modis c6 global csv url"
basePath = 'modis c6 basepath to 194 server'
baseFileName = 'modis c6 data base filename'
def createElemGeojson(latitude,longitude,brightness,scan,track,acq_date,acq_time,satellite,confidence,version,bright_t31,frp,daynight):
propValue = {}
propValue['BRIGHTNESS'] = float(brightness)
propValue['SCAN'] = float(scan)