-
Notifications
You must be signed in to change notification settings - Fork 230
Closed
Description
Description of the problem
Using a Spanish government gravity dataset converted to epsg:4326. Run blockmedian and surface seems to work fine. If I put a proj string in it seems to write that projection to the netcdf file.
However, -JEPSG:4326 (or -Jepsg:4326 or 4326) do
es not.
I made a script version and put a debug print in the utils library generating the run arguments and that gives this:
RUNARGS -I65.15s -R-9.34335092522/3.46340435922/35.8532670285/43.8612236053
RUNARGS -GD:\Spain\GMTtext15.nc -I65.15s -J4326 -R-9.34335092522/3.46340435922/35.8532670285/43.8612236053 -Vc
Full code that generated the error
#!/usr/bin/env python
# coding: utf-8
# In[1]:
import pygmt
import pandas as pd
import geopandas as gpd
import numpy as np
#import rasterio
#import pyvista as pv
from mpl_toolkits.mplot3d import Axes3D # noqa: F401 unused import
import matplotlib.pyplot as plt
from matplotlib import cm
from matplotlib.ticker import LinearLocator, FormatStrFormatter
from matplotlib.patches import Rectangle
import verde as vd
#import cartopy.crs as ccrs
import dask
import pyproj
import pooch
import xarray as xr
import os
spain = gpd.read_file(r'D:\Spain\Gravimetria.shp')
# In[60]:
spain.head()
# In[3]:
Z = spain['VALU_BOU26'].values
lat = spain.geometry.y.values
lon = spain.geometry.x.values
# In[4]:
xmin = spain.total_bounds[0]
xmax = spain.total_bounds[2]
ymin = spain.total_bounds[1]
ymax = spain.total_bounds[3]
region = [xmin, xmax, ymin, ymax]
# In[5]:
datatable = pd.DataFrame()
datatable['longitude'] = lon.tolist()
datatable['latitude'] = lat.tolist()
datatable['bouguer_anomaly'] = Z.tolist()
# In[61]:
region2=[-9.31, 3.430053434000058, 35.92, 43.77780739100007]
region3="-9.34335092522/3.46340435922/35.8532670285/43.8612236053"
datatable_blockmedian = pygmt.blockmedian(table=datatable, spacing="65.15s", region=region3) #e is metres
#grid_s = pygmt.surface(datatable_blockmedian['longitude'],datatable_blockmedian['latitude'],datatable_blockmedian['bouguer_anomaly'],spacing="65.15s",region=region3,J="epsg:4326",V="c",outfile=r'D:\Spain\GMTtext15.nc')
grid_s = pygmt.surface(datatable_blockmedian['longitude'],datatable_blockmedian['latitude'],datatable_blockmedian['bouguer_anomaly'],spacing="65.15s",region=region3,J="4326",V="c",outfile=r'D:\Spain\GMTtext15.nc')
#+proj=longlat+ellps=WGS84 +datum=WGS84 +no_defs +towgs84=0,0,0
# In[62]:
get_ipython().system('gdalinfo "D:\\Spain\\GMTText15.nc"')
# In[ ]:
Full error message
From gdalinfo
Driver: netCDF/Network Common Data Format
Warning 1: Recode from UTF-8 to CP_ACP failed with the error: "Invalid argument".
Warning 1: dimension #1 (x) is not a Longitude/X dimension.
Warning 1: dimension #0 (y) is not a Latitude/Y dimension.
C:\Users\rscott\AppData\Local\Continuum\anaconda3\envs\pygmt\lib\threading.py:874: ResourceWarning: unclosed file <_io.BufferedWriter name=4>
del self._target, self._args, self._kwargs
ResourceWarning: Enable tracemalloc to get the object allocation traceback
C:\Users\rscott\AppData\Local\Continuum\anaconda3\envs\pygmt\lib\threading.py:874: ResourceWarning: unclosed file <_io.BufferedReader name=5>
del self._target, self._args, self._kwargs
ResourceWarning: Enable tracemalloc to get the object allocation traceback
C:\Users\rscott\AppData\Local\Continuum\anaconda3\envs\pygmt\lib\threading.py:874: ResourceWarning: unclosed file <_io.BufferedReader name=6>
del self._target, self._args, self._kwargs
ResourceWarning: Enable tracemalloc to get the object allocation traceback
Files: D:\Spain\GMTText15.nc
Size is 709, 443
Origin = (-9.352395243923700,43.870282379708144)
Pixel Size = (0.018088637407401,-0.018117548816290)
Metadata:
NC_GLOBAL#Conventions=CF-1.7
NC_GLOBAL#GMT_version=6.1.1 [64-bit]
NC_GLOBAL#history=surface @GMTAPI@-S-I-D-V-T-N-000000 -GD:\Spain\GMTtext15.nc -I65.15s -J+4326 -R-9.34335092522/3.46340435922/35.8532670285/43.8612236053 -Vc
NC_GLOBAL#title=Data gridded with continuous surface splines in tension
x#actual_range={-9.343350925219999,3.46340435922}
x#long_name=x
y#actual_range={35.8532670285,43.8612236053}
y#long_name=y
z#actual_range={-143.2124328613281,312.9815673828125}
z#long_name=z
z#_FillValue=-nan(ind)
Corner Coordinates:
Upper Left ( -9.3523952, 43.8702824)
Lower Left ( -9.3523952, 35.8442083)
Upper Right ( 3.4724487, 43.8702824)
Lower Right ( 3.4724487, 35.8442083)
Center ( -2.9399733, 39.8572453)
Band 1 Block=709x1 Type=Float32, ColorInterp=Undefined
NoData Value=nan
Metadata:
actual_range={-143.2124328613281,312.9815673828125}
long_name=z
NETCDF_VARNAME=z
_FillValue=-nan(ind)
In [ ]:
System information
Please paste the output of python -c "import pygmt; pygmt.show_versions()"
:
PyGMT information:
version: v0.2.0
System information:
python: 3.8.6 | packaged by conda-forge | (default, Oct 7 2020, 18:22:52) [MSC v.1916 64 bit (AMD64)]
executable: C:\Users\rscott\AppData\Local\Continuum\anaconda3\envs\pygmt\python.exe
machine: Windows-10-10.0.18362-SP0
Dependency information:
numpy: 1.19.2
pandas: 1.1.3
xarray: 0.16.1
netCDF4: 1.5.3
packaging: 20.4
ghostscript: 9.53.3
gmt: 6.1.1
GMT library information:
binary dir: C:/Users/rscott/AppData/Local/Continuum/anaconda3/envs/pygmt
cores: 12
grid layout: rows
library path: C:/Users/rscott/AppData/Local/Continuum/anaconda3/envs/pygmt/Library/bin/gmt.dll
padding: 2
plugin dir: C:/Users/rscott/AppData/Local/Continuum/anaconda3/envs/pygmt/Library/bin/gmt_plugins
share dir: C:/Users/rscott/AppData/Local/Continuum/anaconda3/envs/pygmt/Library/share/gmt
version: 6.1.1
Metadata
Metadata
Assignees
Labels
No labels