Closed rossoe closed 4 years ago
You can export your mesh as shapefile point cloud and then use a GIS software to perform an interpolation and produce a raster. I think it's better to rely on existing tools rather than reinventing the wheel, interpolation is the usual way to convert from vector to raster.
Hi domlysz,
Fair point. Just tring to test shapefie export now:
First one was a large asc - 135mb
Importing D:\Arma\QGIS\IOW\16_07_19\LymeRegis\final.asc...
{'cellsize': '0.500000000000',
'ncols': '2560',
'nodata_value': '0',
'nrows': '2560',
'xllcorner': '503793.813098000013',
'yllcorner': '5618527.760893000290'}
None
Exception ignored in: <function Writer.__del__ at 0x0000019137F01EA0>
Traceback (most recent call last):
File "C:\Users\rosso\AppData\Roaming\Blender Foundation\Blender\2.80\scripts\addons\BlenderGIS-Blender28\core\lib\shapefile.py", line 1104, in __del__
self.close()
File "C:\Users\rosso\AppData\Roaming\Blender Foundation\Blender\2.80\scripts\addons\BlenderGIS-Blender28\core\lib\shapefile.py", line 1125, in close
self.__shapefileHeader(self.shp, headerType='shp')
File "C:\Users\rosso\AppData\Roaming\Blender Foundation\Blender\2.80\scripts\addons\BlenderGIS-Blender28\core\lib\shapefile.py", line 1299, in __shapefileHeader
f.write(pack("<4d", zbox[0], zbox[1], mbox[0], mbox[1]))
TypeError: 'NoneType' object is not subscriptable
Traceback (most recent call last):
File "C:\Users\rosso\AppData\Roaming\Blender Foundation\Blender\2.80\scripts\addons\BlenderGIS-Blender28\operators\io_export_shp.py", line 173, in execute
bm.from_object(obj, context.depsgraph, deform=True) #'deform' allows to consider modifier deformation
AttributeError: 'Context' object has no attribute 'depsgraph'
location: <unknown location>:-1
location: <unknown location>:-1
Thought it might be related to large size so tried with smaller asc - 5.89mb
Importing D:\Arma\QGIS\NZ\Picton\14_07_19\Grid\DEM\extract2_1_1.asc...
{'cellsize': '8.000000000000',
'ncols': '641',
'nodata_value': '0',
'nrows': '641',
'xllcorner': '753661.964245000039',
'yllcorner': '5436200.444488000125'}
None
Exception ignored in: <function Writer.__del__ at 0x0000019137F01EA0>
Traceback (most recent call last):
File "C:\Users\rosso\AppData\Roaming\Blender Foundation\Blender\2.80\scripts\addons\BlenderGIS-Blender28\core\lib\shapefile.py", line 1104, in __del__
self.close()
File "C:\Users\rosso\AppData\Roaming\Blender Foundation\Blender\2.80\scripts\addons\BlenderGIS-Blender28\core\lib\shapefile.py", line 1125, in close
self.__shapefileHeader(self.shp, headerType='shp')
File "C:\Users\rosso\AppData\Roaming\Blender Foundation\Blender\2.80\scripts\addons\BlenderGIS-Blender28\core\lib\shapefile.py", line 1299, in __shapefileHeader
f.write(pack("<4d", zbox[0], zbox[1], mbox[0], mbox[1]))
TypeError: 'NoneType' object is not subscriptable
Traceback (most recent call last):
File "C:\Users\rosso\AppData\Roaming\Blender Foundation\Blender\2.80\scripts\addons\BlenderGIS-Blender28\operators\io_export_shp.py", line 173, in execute
bm.from_object(obj, context.depsgraph, deform=True) #'deform' allows to consider modifier deformation
AttributeError: 'Context' object has no attribute 'depsgraph'
location: <unknown location>:-1
location: <unknown location>:-1
Hi,
It must be fixed now
Evening,
Tested after removing BlenderGIS and reinstalling latest deployment.
GDAL and numpy at version:
GDAL‑2.4.1‑cp37‑cp37m‑win_amd64.whl numpy-1.16.5+mkl-cp37-cp37m-win_amd64.whl
INFO:BlenderGIS-master.operators.io_import_asc:186:Importing D:\Arma\QGIS\NZ\Picton\14_07_19\Grid\DEM\extract2_1_1.asc...
Traceback (most recent call last):
File "C:\Users\rosso\AppData\Roaming\Blender Foundation\Blender\2.80\scripts\addons\BlenderGIS-master\operators\io_export_shp.py", line 179, in execute
bm.from_object(obj, context.evaluated_depsgraph_get(), deform=True) #'deform' allows to consider modifier deformation
ValueError: from_object(...): currently only mesh objects are supported
location: <unknown location>:-1
location: <unknown location>:-1
Copy of asc used to test - https://1drv.ms/u/s!AjCedBZJ5Eh4kBMafn9QZO4xAMOA?e=XF10bS
you must correctly setup operator's options
By default the operator will export all objects of the default collection but I forgot to check in the code if the the targeted objects are indeed mesh
Oh course I always neglect those parameters in the corner! Handy feature & works a treat thanks domlysz: From: Exported to shapefile then GlobalMapper 'Create Elevation Grid from 3D vector' :
Slight confusion in that the shapefile exports from BlenderGIS with a .prj (EPSG:4326)
When I project shapefile to match source asc (EPSG:32759)
It sits with it's top right corner at the center of the original asc -
Is there a way to maintain projection through export?
Seems the origin of object is misplaced with the asc importer. I will fix that, meanwhile geotiff work correctly
Thanks domlysz
To clarify I'm opening shapefile in QGIS and reprojecting to appropriate CRS for it's location (NZ in this instance)
Converting to raster is not the easiest process within QGIS! - for those stumbling upon this trying to do the same see process here: https://gis.stackexchange.com/questions/338813/qgis-rasterize-vector-to-raster-failing-to-create-viable-raster
Still an odd anomaly re lines running through output raster, seems to be something to do with the output extent I'm picking on the Rasterize process.
hi,
shp exporter must be fixed now
Also, you don't need to reproject anything, your original asc is in 32759 so you must indicate this projection when importing in BlenderGIS so that the scene projection will be correctly setup and exporting to shp will create a correct prj file.
be careful, seems you completly messup projection here because as I can see in your screenshoot of Qgis rasterize toolbox the extent coordinates are in 32759 but the specified projection is 4326, but 4326 mean coordinates in degrees and these values are between -180 and 180° for longitude and -90 and 90° for latitude so you haven't specify the good projection here.
Thanks good spot - I'll correct that and try test again
I wondered if it was possible to add an export heightmap option so you can save out an asc or tif?