There is a set of (lat, long) points which can be simply visualized by matplotlib.pyplot.scatter(list_of_longitudes, list_of_latitudes). But I want to plot these points on top of a road network which happens to be in a shapefile. How can I simply plot the two files together with Python in one single map/figure?
Especially looking for something like Shapely
Related
I have a fortran program that simulates some kind of radiation in the air and the signal obtained in each of the antennas at the ground. I am reading the output data with Python3, and one of the output .dat files holds information about the antennas, and it is organized in columns (Position along X-axis, Position along Y-axis, Signal detected, etc).
Supose that I have ~ 1000000 antennas and I have already storaged the position and signal of every one of them in the lists column_x ,column_y,signal and my objective is to reproduce a plot like the following:
How can I do that?
I tried to make a matrix with shape (len(column_x),len(column_y)), insert the values of the list signal in each place of the antenna and plot that matrix with plt.pcolor but I had a lot of issues. There must be an easiest way.
What you intend to do is exactly what matplotlib.pyplot.scatter can do:
import matplotlib.pyplot as plt
plt.scatter(column_x, column_y, c=signal)
I am trying to generate a contour graph in terms of three parameters (say x, y, z). These parameters come from a data table of more than 5000 values.I need the graphics to look like the figures shown below.
Contour plots are most easily made using matplotlib's contour.
There's also a corresponding contourf function that provides filled contours. Anyway, what you uploaded looks more like matplotlib's pcolor or pcolormesh, as they draw colored pixels instead of isovalue lines.
Here's a nice comparison of both if you need to choose.
Edit: For (x,y,z) points that are not distributed on a grid (i.e. come from random samples), a working solution seems to be a combination of binned_statistic_2d and then either plt.pcolor or plt.contour.
I have a standard shapefile which has a column called geometry. This column contains a shapely Polygon object which is essentially a list of paired latitudes and longitudes that trace an object (e.g. the border of a country). The shapes are very complex/detailed, meaning that they have many points and are thus hard to plot. Is there a way to intelligently sub-sample the points in each polygon (e.g. taking only 1% of the points) in python.
I use the word intelligently because I need to ensure a few things:
The first and last point in the polygon must be the same (so that the shape reconnects to itself
If I have two polygons that share a points (e.g. when two countries share a border), there should be minimal overlap between the boundaries after sub-sampling.
An example of a piece of software that does this is https://mapshaper.org/. I want to do the same thing as their "simplify" tool, but in python.
So I am a bit new to python and having a little trouble.
I am attempting to plot (project) a 3d data set onto an arbitrary plane. I can of course plot xy etc. but since my data has a particular orientation (all the points fall into an arbitrary orientated cylinder) I want project all the points onto a plane that slices that cylinder orthogonally and that plane would have a arbitrary orientation.
I am working with microseismic data if anyone is familiar with that and all the points are located around a wellbore with follows an arbitrary but fairly straight azimuth.
The data is in Cartesian coordinates.
I am trying to use the coastline data provided by Natural Earth (in the form of shape files) within basemap. I am getting weird horizontal lines as shown in the figures below. When the plot is centered on 180 degree longitude, the number of such lines increases.
Looking at the location of these lines (which is where continents wrap around), I reckon the source of the problem must be related to how the polygons are defined in the shape file and the wrapping of the polygon around a longitude, but I don't see how I can go about fixing it. I would expect a mapping library like basemap to be able to handle this transparently. Any solution would very be helpful.
I am using the "ne_110m_coastline" data from Natural Earth and I have not modified it in any way. Here's a sample code that replicates the problem:
Map = Basemap(projection='eck4',lon_0=0, resolution='c')
a = Map.readshapefile("ne_110m_coastline", "coast")