Plotting netCDF data with folium - python - python

I have a netCDF file which contains only x_orig and y_orig in LCC format(i.e. no latitudes, longitudes for each data value). I was able to correctly convert it to (lat, long) pair to plot them over Google Maps - where the projection I used is wgs84 (outProj = Proj(init='epsg:4326')).
Next I wrote functions to find out every lat and long for the grid. But even, that seems to a bit skewed.
The idea is:
I could produce the correct concentration plot using Basemap's contourf where the image created is in LCC projection. I save this image on my device.
And then use folium's feature of ImageOverlay; where I mention the boundaries i.e.(max_lat, max_lon, min_lat, min_lon). But the image is incorrectly aligned. Is this because folium uses epsg:3857?
How do I overcome this challenge?
(i.e. producing an interactive map which correctly displays my data in LCC projection)

Related

Slice plot in vtk

I have a polydata file containing 3D coordinates of the mesh (as vtkPoints) and temperature at each point as an attribute. I want to plot the temperature as a slice plot (at three elevations) over the geometry. I managed to get the data slices at different elevation using vtkClipPolyData function. However, I am unable to find a good example showing how to interpolate the value at each of these points and plot the data. Really appreciate if someone can help me on this.
I tried to render the clipped data directly by increasing the point size from actor property,
actor.GetProperty().SetPointSize(5)
however, this gives a pixelated plot. See plot here

how can you set the geographical projection with datashader?

I plotted a geographic map with datashader. Everything works fine, however the geographic projection seems to be incorrect. The lengths and aspect ratios do not match, probably because no geographical projection is set?
My Code looks like this:
agg = ds.Canvas().points(df, 'lon',"lat")
karte=ds.tf.set_background(ds.tf.shade(agg, cmap=cc.fire,how="log"), "black")
utils.export_image(img=karte,filename='output', fmt=".png", background=None)
That's a nice-looking amoeba! :-)
Datashader is a general-purpose tool, not tied to geographical data in any way. In particular, if you want the data to be projected into some other coordinate system, you need to project it before calling Datashader; all Datashader does is render what it is given.
Datashader does include one utility function for the special case of projecting lon/lat data into Web Mercator (datashader.utils.lnglat_to_meters), for convenience with plotting libraries that use Web Mercator mapping tiles, but if you are visualizing the data on its own (not overlaid on a map) you shouldn't even need that utility; bare lon/lat values should be ok.
If you want some specific aspect ratio, you can determine it with parameters to the Canvas constructor. Specifically, set set the plot_height and plot_width to whatever image size you want, then set x_range and y_range to the ranges of data space you want in that image size (e.g. longitude and latitude ranges like xrange=(270, 290), yrange=(30,40)).
Or you can use the high-level interfaces at hvplot.holoviz.org or holoviews.org to overlay onto a map, which will force a geographic aspect ratio.

Overlay a figure on top of Openstreet map using Bokeh?

How do I overlay a figure over a map(not google maps but OpenStreet maps) using Bokeh?
Figure 1: Austin city watershed to be plotted over map
currently my code generates figure 1 which is poor and needs to be overlaid over a map to make better sense.
Pandas DataFrame which is converted into figure shown in figure 1
Convert the shapefile coordinates of lat and long to web mercator coordinates and use any available WMTS tile source to overlay the data on the map. Also provide the x and y range of the city you are interested in mercator coordinates.

Change the canvas's shape when using Lambert Conformal Projection

With the supporting of matplotlib basemap, I can draw my netCDF files in different kind of projection type.
We always see the figure is in rectangular showing like this:
But I also see some figures showing like:
For now, I have some weather simulation data and I want to represent it on the map with Lambert projection.
The temperature of on time slice shows like:
So, here is my question:
How to generate the figure which the borders of the canvas fit the lcc projection like the previous one using Basemap?

Basemap horizontal lines with Natural Earth shape files

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")

Categories

Resources