Hi! I have a geodataframe with a list points that contain x, y and z values. I’d like to convert these points to a raster and export as a .tif file.
After some googling, I found that geocube has a function make_geocube that can do this. However, It does not seem to have anything built in which allows me to interpolate the data to fill the NaN values. Does anyone perhaps know another library that can also do the interpolation?
Well, the raster (downloadable output of my app) is the input for Civil3D. I have never used Civil3D but I just talked to a colleague about it. It turns out that Civil3D also supports csv inputs, which is much easier to program. I think for now we’ll try that out and see if it works!
If you want the make a raster, geocube looks like the way to go. On the make_geocube function, there is a argument ‘fill’ to fill missing data instead of NaN. Which can be used like this:
The to_raster function only takes a direct Path, to use this in combination with a DownloadView, you can use something like a NamedTempFile. Let me know if you need help with that.
Furthermore:
GeoPandas offers a wide variety of export formats using the ‘to file’ function. For example shapefile (.shp), geojson (.geojson) or GeoPackage (.GPKG). Which are much more suitable to store Geo data. I would expect that Civil3D supports on 1 or multiple of these formats.
To download a such a file from a GeoDataFrame, use the following code (GeoJson example):
output_file = File()
with output_file.open_binary() as fp:
geo_data_frame.to_file('dataframe.geojson', driver='GeoJSON')