Skip to content

Instantly share code, notes, and snippets.

View ragnarheidar's full-sized avatar

Ragnar Thrastarson ragnarheidar

View GitHub Profile
@ragnarheidar
ragnarheidar / PlotWeatherStations.py
Last active October 1, 2017 08:36
Leaflet map created with folium and GeoJSON
"""
And example of a python code that uses the folium library to create a lightweight
leaflet web map. The example uses a GeoJSON file that is added to the map.
Folium documentation:
http://python-visualization.github.io/folium/docs-master/
How to add popups and cluster markers:
https://ocefpaf.github.io/python4oceanographers/blog/2015/12/14/geopandas_folium/
Leaflet maps from leaflet-providers:
https://leaflet-extras.github.io/leaflet-providers/preview/
@ragnarheidar
ragnarheidar / GetBottleTimeAndCoordinates.py
Created August 17, 2017 12:33
Python code to parse a KML file XML notation) and write data to a CSV table
import xml.etree.ElementTree as ET
from datetime import datetime
StartTime = datetime.now()
Tree = ET.parse('Bottles.kml')
root = Tree.getroot()
OutFileName = "Bottles.csv"
f = open(OutFileName, "w")
f.write('bottle_id, time, lat, lon' + '\n')
@ragnarheidar
ragnarheidar / Ask128.mp3
Last active June 15, 2017 21:08
Learn how to pronounce Icelandic Volcanos
@ragnarheidar
ragnarheidar / README.md
Last active October 6, 2016 14:00
Earthquake map for Iceland
@ragnarheidar
ragnarheidar / index.html
Last active October 6, 2016 14:03
A simple Leaflet map created with Python using the folium library
<!DOCTYPE html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.3/leaflet.js"></script>
@ragnarheidar
ragnarheidar / ChangeCSVdelimiter.py
Last active July 8, 2021 17:59
A python script that reads a CSV file and writes it out with a different delimiter.
# -*- coding: utf-8 -*-
import csv
from tempfile import NamedTemporaryFile
import shutil
readfile = "SOME\\PATH\\input.csv"
writefile = "SOME\\PATH\\output.csv"
tempfile = NamedTemporaryFile(delete=False)
with open(readfile, 'rb') as csvfilein, tempfile:
@ragnarheidar
ragnarheidar / FilenameAsAttribute.py
Last active February 10, 2016 09:07
A script that uses the arcpy site-package to read the filename of a feature class, create a field called Name and writes the filename as an attribute in the newly created field.
"""
A script that uses the arcpy site-package to read the filename
of a feature class, create a field called Name and wirites the
filename as an attribute in the newly create filed.
"""
import arcpy
from arcpy import env
arcpy.env.workspace = "SOME/PATH"
@ragnarheidar
ragnarheidar / PolygonToSAMOS_ArcGIS.py
Last active February 10, 2016 08:49
A python script tool that uses the ArcPy site-package to convert a polygon feature class to a specific text based output. Output includes parameters, number of vertices in each feature and X and Y coordinates of each vertex for each feature. The output is specific for the avalanche simulation software SAMOS.
# -*- coding: utf-8 -*-
""""
Tool Name: Starting Zones to SAMOS
Source Name: StartingZonesToSamos.py
Version: ArcGIS 10.3.1
Author: Icelandic Meteorology Office/Ragnar H. Thrastarson
Created: 2015-07-20
Description: A python script tool that uses the ArcPy site-package
to convert a polygon feature class to a specific text based
output. Output includes parameters, number of vertices in each
@ragnarheidar
ragnarheidar / PolygonToSAMOS_QGIS.py
Last active February 10, 2016 08:40
Python script that uses the shapefile library to read a polygon shapefile. Output includes parameters, number of vertices in each feature and X and Y coordinates of each vertex for each feature. The output is specific for the avalanche simulation software SAMOS. This script can be used in QGIS as a tool in the Processing toolbox.
""""
Python script tha uses the shapefile library to read
a polygon shapefile. Output includes parameters, number
of vertices in each feature and X and Y coordinates of
each vertex for each feature. The output is specific
for the avalanche simulation software SAMOS.
This script can be used in QGIS as a tool in the Processing toolbox
Author: Icelandic Meteorology Office/Ragnar H. Thrastarson 2015
"""
@ragnarheidar
ragnarheidar / gep662project.py
Last active August 29, 2015 14:21
GEP 662 Final project - Python on a Bike
"""
-------------------------------------------------------------------
LEHMAN COLLEGE
Geographic Information Science Program
Course: GEP 662 Introduction to Programming for GISc
Semester: Spring 2014
Instructor: Prof. Jennifer Brisbane
Student: Ragnar Heidar Thrastarson