Comments (3)
Hi @lperozzi! This is an excellent question and outlines a common task when dealing with regional scale geo-datasets.
Necessary Imports
import numpy as np
import pyvista as pv
import PVGeo
pv.set_plot_theme('doc')
Load the data
Looks like you have some data files in the UBC formats - PVGeo has readers for these!
# load data files using PVGeo
gravi = PVGeo.ubc.GravObsReader().apply('gravi.txt')
psurf = PVGeo.ubc.TopoReader().apply('surf.txt')
# Filter points of topo to a surface
surf = psurf.delaunay_2d()
Reproduce the first figure:
gargs = dict(point_size=5.0, render_points_as_spheres=True,
cmap='bwr', clim=[-50,110], stitle='Residuals')
p = pv.Plotter()
p.add_mesh(gravi, **gargs)
p.add_mesh(surf)
p.camera_position = [2,5,0.5]
p.show()
The warp_by_scalar
filter
This probably isn't the filter of choice for this particular example. The warp_by_scalar
filter distorts the surface by the active scalar on the mesh by default - the current implementation above is warping the grav
mesh of scattered points by the 'Residuals'
array which likely has a different dimension that the spatial reference in the z-axis.
Directly editing the Z-coordinates
It may be best to directly edit the Z-coordinates of the meshes considering they share the same coordinate datum.
Note I use a factor of 10 instead of 3 to clearly demonstrate that the exaggeration is indeed occurring:
scale_factor = 10.0
# Apply a warp
warped_gravi = gravi.copy()
warped_gravi.points[:, -1] *= scale_factor
warped_surf = surf.copy()
warped_surf.points[:, -1] *= scale_factor
p = pv.Plotter(notebook=1)
p.add_mesh(warped_gravi,**gargs)
p.add_mesh(warped_surf)
p.camera_position = [2,1,0.2]
p.show()
Scaling the Plotting scene
This is a somewhat buggy feature we added that has some issues resulting from the VTK backend but it's possible to scale an entire rendering scene and not actually edit the spatial reference of the meshes. This is simply changing the visualization, not the meshes:
p = pv.Plotter()
p.add_mesh(gravi, **gargs)
p.add_mesh(surf)
p.set_scale(zscale=scale_factor)
p.camera_position = [2,1,0.2]
p.show()
from pyvista-support.
Hi @banesullivan , many thanks for the hints. Actually scale an entire rendering scene is exactly what I need!
from pyvista-support.
Just an FYI, there are issues when using the scaled render view:
from pyvista-support.
Related Issues (20)
- create uniform mesh HOT 3
- Change the orientation of a scalar bar's title
- Applying textures on models from .obj files HOT 6
- How to create an Unstructured grid from points and faces HOT 2
- Type of data, plotting with glyphs HOT 3
- Controlling the thickness and orientation of a slice in Pyvista HOT 3
- Controlling the image position in window, without any click
- Mask/Remove Voxels in Air (small intersection with surface) HOT 3
- custom slider parameters
- running pyvista on headless machine with Centos OS HOT 1
- Seismic Horizon with Pyvista HOT 8
- Algorithm in sample function?
- Automatically updates HOT 3
- Slow interaction HOT 1
- read from text HOT 4
- Uniform Grid thresholding question HOT 8
- Take data by an input x,y,x coordinate (csv file) from vtk data file HOT 4
- Program broke when creating a mesh using pv.PolyData() HOT 4
- ATTENTION: Please move questions to PyVista's Discussions HOT 1
- plotter.enable_terrain_style not working for me HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyvista-support.