I have some files that contains trajectories data.
Some of the data is running some of it is cycling and some of it is walking.
I classified all of them and I want to load them to pandas to be able to classified new trajectories.
I have data that looks similar to that: GPS Trajectories
I can not find the right way to save the data in pandas. I can convert it to any format in csv file but what is the best way to load it to pandas?
Related
How can I extract CHIRPS data value in a file (CSV, xlsx, or txt) along with their coordinates using python code?
However, many cloud base processing platforms like "Climate engine" provides the facility to extract values (daily, monthly, or yearly rainfall)in a CSV or Excel file but the problem is that the data do not have coordinates (LAT and Long) for the specified values.
Thus, we can not visualize and conduct any location-based analyzes in any GIS software.
I tried to extract rainfall data from the CHIRPS dataset using code in jupyter notebook, but I could not succeed to extract the values along with their coordinates in the same file.
Trying to extract zonal information within a shapefile layer that contains district regions, for a monthly time series of raster data stored in a netcdf.
I've so far only been able to extract the average across all time periods for each shapefile (see below). But really I want the monthly average within each region.
The ultimate aim is to have this in a pandas geodataframe which I can then merge with some attribute data for each region. I'm not very used to working with netcdfs so any suggestions would be helpful! The time dimension within the netcdf is 'yyyy-mm-dd' format.
#import netcdf data
with rio.open('/MSLA_all_test.nc') as msla_nc:
msla_nc_data = msla_nc.read(1,masked=True)
msla_nc_meta = msla_nc.profile
#import polygons
region_polys = gpd.read_file('/GADM2_coast_regions.shp')
#Extract pixel values for each polygon : zonal stats
region_value=rs.zonal_stats(region_polys, msla_nc_data, nodata=-999, affine=msla_nc_meta['transform'], geojson_out=True, copy_properties=True, stats="mean")
You can perform time aggregation and resampling using xarray. then apply your code.
Using matplotlib.pyplot, I plotted multiple wave functions w.r.t time series, showing the waves in multiple vertical axes, and output the graph in jpg using savefig. I want to know the easiest way in which I can output all wave functions into a single output data file maybe in CSV or DAT in rows and columns.
How you plot the wave functions? Do you compute all the points?
If so, you can just write those points to csv.
You may refer to https://docs.python.org/2/library/csv.html
If you plotted the data using numpy array, you can use numpy.savetxt.
I have a question related to plots created by matplotlib. I have a GUI (in python) which creates plots from *.mat files, it saves the plots as a *.JPG file. A sample plot Looks as follows:
Now as you can see there are two data series present in the plot, and now i want to save the plot like an Excel plot where i can interact with the plot and also obtain the Location of the *.mat file from which it was created.
Can this be done using Python? I need ideas from you guys
Thanks
There are of course a lot of different options to save a file containing additional information. To list a few:
Using the EXIF tags of a jpg image to store the filenames. This might require a library like piexif.
Saving a dictionary like {"files" : ["filename1", "filename2"], "image" : <imagedata>} to a file, where <imagedata> could be the raw image or a numpy array of the image data.
Pickling a dictionary like {"files" : ["filename1", "filename2"], "image" : <figure>}, where figure is the matplotlib figure object.
At the end it might be much easier to just create a lookup table with image filenames and raw data filenames to see which image belongs to which data.
I have a huge data set of time series data. In order to visualise the clustering in python, I want to plot time series graphs along with the dendrogram as shown below.
I tried to do it by using subgrid2plot() function in python by creating two subplots side by side. I filled first one with series graphs and second one with dendrograms. But once number of time series increased, it became blur.
Can someone suggest a nice way to plot this type of dendrogram? I have around 50,000 time series to cluster and visualise.
Convert data into JSON with json module of python and then use D3.js for graph ploting.
Check the Gallery from here where you can find dendrogram and time series graph