Elephant GPS Collar Tracking
Elephant GPS Collar Tracking#
import pandas as pd #for handling csv and csv contents
from rdflib import Graph, Literal, RDF, URIRef, Namespace #basic RDF handling
from rdflib.namespace import FOAF , XSD, SSN, SOSA #most common namespaces
import urllib.parse #for parsing strings to URI's
import matplotlib.pyplot as plt
import plotly.graph_objects as go
import plotly.express as px
import stardog
import json
import io
import os
df = pd.read_csv('Jasmin.csv')
---------------------------------------------------------------------------
FileNotFoundError Traceback (most recent call last)
Input In [2], in <cell line: 1>()
----> 1 df = pd.read_csv('Jasmin.csv')
File C:\Python310\lib\site-packages\pandas\util\_decorators.py:311, in deprecate_nonkeyword_arguments.<locals>.decorate.<locals>.wrapper(*args, **kwargs)
305 if len(args) > num_allow_args:
306 warnings.warn(
307 msg.format(arguments=arguments),
308 FutureWarning,
309 stacklevel=stacklevel,
310 )
--> 311 return func(*args, **kwargs)
File C:\Python310\lib\site-packages\pandas\io\parsers\readers.py:680, in read_csv(filepath_or_buffer, sep, delimiter, header, names, index_col, usecols, squeeze, prefix, mangle_dupe_cols, dtype, engine, converters, true_values, false_values, skipinitialspace, skiprows, skipfooter, nrows, na_values, keep_default_na, na_filter, verbose, skip_blank_lines, parse_dates, infer_datetime_format, keep_date_col, date_parser, dayfirst, cache_dates, iterator, chunksize, compression, thousands, decimal, lineterminator, quotechar, quoting, doublequote, escapechar, comment, encoding, encoding_errors, dialect, error_bad_lines, warn_bad_lines, on_bad_lines, delim_whitespace, low_memory, memory_map, float_precision, storage_options)
665 kwds_defaults = _refine_defaults_read(
666 dialect,
667 delimiter,
(...)
676 defaults={"delimiter": ","},
677 )
678 kwds.update(kwds_defaults)
--> 680 return _read(filepath_or_buffer, kwds)
File C:\Python310\lib\site-packages\pandas\io\parsers\readers.py:575, in _read(filepath_or_buffer, kwds)
572 _validate_names(kwds.get("names", None))
574 # Create the parser.
--> 575 parser = TextFileReader(filepath_or_buffer, **kwds)
577 if chunksize or iterator:
578 return parser
File C:\Python310\lib\site-packages\pandas\io\parsers\readers.py:933, in TextFileReader.__init__(self, f, engine, **kwds)
930 self.options["has_index_names"] = kwds["has_index_names"]
932 self.handles: IOHandles | None = None
--> 933 self._engine = self._make_engine(f, self.engine)
File C:\Python310\lib\site-packages\pandas\io\parsers\readers.py:1217, in TextFileReader._make_engine(self, f, engine)
1213 mode = "rb"
1214 # error: No overload variant of "get_handle" matches argument types
1215 # "Union[str, PathLike[str], ReadCsvBuffer[bytes], ReadCsvBuffer[str]]"
1216 # , "str", "bool", "Any", "Any", "Any", "Any", "Any"
-> 1217 self.handles = get_handle( # type: ignore[call-overload]
1218 f,
1219 mode,
1220 encoding=self.options.get("encoding", None),
1221 compression=self.options.get("compression", None),
1222 memory_map=self.options.get("memory_map", False),
1223 is_text=is_text,
1224 errors=self.options.get("encoding_errors", "strict"),
1225 storage_options=self.options.get("storage_options", None),
1226 )
1227 assert self.handles is not None
1228 f = self.handles.handle
File C:\Python310\lib\site-packages\pandas\io\common.py:789, in get_handle(path_or_buf, mode, encoding, compression, memory_map, is_text, errors, storage_options)
784 elif isinstance(handle, str):
785 # Check whether the filename is to be opened in binary mode.
786 # Binary mode does not support 'encoding' and 'newline'.
787 if ioargs.encoding and "b" not in ioargs.mode:
788 # Encoding
--> 789 handle = open(
790 handle,
791 ioargs.mode,
792 encoding=ioargs.encoding,
793 errors=errors,
794 newline="",
795 )
796 else:
797 # Binary mode
798 handle = open(handle, ioargs.mode)
FileNotFoundError: [Errno 2] No such file or directory: 'Jasmin.csv'
df['Altitude']= pd.to_numeric(df['Altitude'],errors='coerce')
df['Altitude'].mean().round(6)
143.757143
df.head(10)
ID | LocalDate | LocalTime | GMTDate | GMTTime | lat | long | Temperature | Speed | Direction | Altitude | Cov | HDOP | Distance | Count | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 1SAT32 | 2011-10-26 | 07:40:35 AM | 2011-10-25 | 11:40:35 PM | 5.437206 | 118.111301 | 24.5 | 0.24 | 0 | NaN | 0 | 1.64 | 0 | 1 |
1 | 2SAT32 | 2011-10-26 | 03:41:35 PM | 2011-10-26 | 07:41:35 AM | 5.433402 | 118.108162 | 29.0 | 0.76 | 0 | NaN | 0 | 1.74 | 548 | 2 |
2 | 3SAT32 | 2011-10-26 | 11:40:35 PM | 2011-10-26 | 03:40:35 PM | 5.433734 | 118.108599 | 27.0 | 0.86 | 0 | NaN | 0 | 2.18 | 61 | 3 |
3 | 4SAT32 | 2011-10-27 | 11:40:34 PM | 2011-10-27 | 03:40:34 PM | 5.455738 | 118.183640 | 28.0 | 0.16 | 0 | NaN | 0 | 1.89 | 8669 | 4 |
4 | 5SAT32 | 2011-10-28 | 07:42:53 AM | 2011-10-27 | 11:42:53 PM | 5.456503 | 118.187684 | 27.5 | 1.46 | 0 | NaN | 1 | 2.50 | 456 | 5 |
5 | 6SAT32 | 2011-10-28 | 03:41:05 PM | 2011-10-28 | 07:41:05 AM | 5.483344 | 118.232541 | 33.5 | 0.06 | 0 | NaN | 5 | 1.45 | 5800 | 6 |
6 | 7SAT32 | 2011-10-28 | 03:41:05 PM | 2011-10-28 | 07:41:05 AM | 5.483344 | 118.232541 | 33.5 | 0.06 | 0 | NaN | 5 | 1.45 | 0 | 7 |
7 | 8SAT32 | 2011-10-28 | 03:41:05 PM | 2011-10-28 | 07:41:05 AM | 5.483344 | 118.232541 | 33.5 | 0.06 | 0 | NaN | 5 | 1.45 | 0 | 8 |
8 | 9SAT32 | 2011-10-28 | 07:40:34 PM | 2011-10-28 | 11:40:34 AM | 5.479701 | 118.243606 | 29.0 | 0.14 | 0 | NaN | 4 | 0.95 | 1291 | 9 |
9 | 10SAT32 | 2011-10-28 | 07:40:34 PM | 2011-10-28 | 11:40:34 AM | 5.479701 | 118.243606 | 29.0 | 0.14 | 0 | NaN | 5 | 0.95 | 0 | 10 |
df.describe()
lat | long | Temperature | Speed | Direction | Altitude | Cov | HDOP | Distance | Count | |
---|---|---|---|---|---|---|---|---|---|---|
count | 899.000000 | 899.000000 | 899.000000 | 899.000000 | 899.000000 | 7.000000 | 899.000000 | 899.000000 | 899.000000 | 899.000000 |
mean | 5.509015 | 118.237317 | 28.888765 | 0.587164 | 1.329255 | 143.757143 | 2.497219 | 2.550044 | 640.407119 | 450.000000 |
std | 0.073845 | 0.105518 | 4.016236 | 0.673300 | 17.429289 | 88.443143 | 2.170552 | 3.812480 | 917.534269 | 259.663243 |
min | 5.392483 | 117.981100 | -35.500000 | 0.000000 | 0.000000 | 101.500000 | 0.000000 | 0.710000 | 0.000000 | 1.000000 |
25% | 5.465016 | 118.199810 | 28.000000 | 0.180000 | 0.000000 | 103.050000 | 0.000000 | 1.295000 | 145.500000 | 225.500000 |
50% | 5.490733 | 118.248029 | 28.500000 | 0.370000 | 0.000000 | 114.900000 | 2.000000 | 1.830000 | 341.000000 | 450.000000 |
75% | 5.546202 | 118.311595 | 30.000000 | 0.735000 | 0.000000 | 120.200000 | 5.000000 | 2.715000 | 761.000000 | 674.500000 |
max | 5.706847 | 118.403456 | 37.500000 | 6.610000 | 343.000000 | 343.400000 | 5.000000 | 99.900000 | 9603.000000 | 899.000000 |
# 'Visualising Elephant Jasmin Movements'
# Creating and visualizing a scatter plot on Mapbox
fig = px.scatter_mapbox(df, lat='lat', lon='long',
animation_frame = 'GMTDate', animation_group = 'GMTTime',
color='Speed', size='Speed',
color_continuous_scale=px.colors.cyclical.IceFire,
size_max=50, zoom=1.75, hover_name='ID',
hover_data = ['GMTDate', 'GMTTime', 'lat','long'],
title = 'Visualising Elephant Jasmin Movements')
fig.update_layout(
height=800,
margin={'l': 0, 't': 0, 'b': 0, 'r': 0},
mapbox={
'center': {'lon': 118, 'lat': 5},
'accesstoken':"pk.eyJ1IjoibmFlaW1hIiwiYSI6ImNsNDRoa295ZDAzMmkza21tdnJrNWRqNmwifQ.-cUTmhr1Q03qUXJfQoIKGQ",
'style': 'satellite-streets',
#'style': "open-street-map",
#'style': 'outdoors',
'center': {'lon': 118, 'lat': 5},
'zoom': 8})
fig.show()