필터 지우기
필터 지우기

Export matlab variable to be imported in QGis

조회 수: 8 (최근 30일)
Ricardo Duarte
Ricardo Duarte 2021년 9월 14일
답변: Pratyush 2024년 5월 29일
Dear all,
I need to export a 1000x1000 matrix containing sound pressure level of a specific region to be later imported at QGis.
I tried to do that using netCDF files, which is ok, however the coordinate system is not the same than in QGis (it is used the WGS84 coordinate system) and when I import the file there it is not in the correct location.
So, my question is, how can I export my variable maintaing the correct coordinate system/or change the coordinate system in matlab to correspond to the same coordinate system in QGIs.
Thank you in advance.

답변 (1개)

Pratyush
Pratyush 2024년 5월 29일
Hi Ricardo,
To export a 1000x1000 matrix (e.g., sound pressure level data) from MATLAB to a netCDF file compatible with QGIS's WGS84 coordinate system, follow these summarized steps:
1. Ensure your data, including latitude (`lat`) and longitude (`lon`), is ready and in WGS84 format.
2.Use 'nccreate' in MATLAB to generate the file and define dimensions for your data and coordinates.
nccreate('soundPressureData.nc', 'soundPressureLevel', 'Dimensions', {'lat', 1000, 'lon', 1000});
3. Use 'ncwrite' to add your matrix and coordinate data to the file.
4. Add attributes to your netCDF file to specify that your data uses the WGS84 system, using 'ncwriteatt' to set attributes like 'standard_name' and 'units' for latitude and longitude.
ncwriteatt('soundPressureData.nc', '/', 'Conventions', 'CF-1.6');
ncwriteatt('soundPressureData.nc', 'lat', 'standard_name', 'latitude');
ncwriteatt('soundPressureData.nc', 'lon', 'standard_name', 'longitude');
5. If QGIS does not recognize the CRS, you may need to manually set the layer's CRS to WGS84 (EPSG:4326) within QGIS using the "Define Projection" tool.
6. Load your netCDF file into QGIS. If the coordinate system is not automatically recognized, manually adjust it to WGS84.
This process ensures your MATLAB-exported netCDF file aligns correctly with QGIS's expected coordinate system, facilitating accurate geographical data representation.

카테고리

Help CenterFile Exchange에서 NetCDF에 대해 자세히 알아보기

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by