1

I'm trying to develop gis based web application. I'm using leaflet for frontend and django for backend. My requirement is to plot raster data in leaflet. I'm using rasterio for reading raster file. And here is my View to read raster file upload by the user

class UploadRasterView(View):
    def post(self, request):
        context = dict()
        raster = RasterFileUploadForm(request.POST, request.FILES)
        folder_name = 'raster_data'
        if raster.is_valid:
            file_name = ''
            for _file in self.request.FILES.getlist('file'):
                handle_uploaded_file(_file, folder_name)
                if _file.name.split('.')[-1] == 'tif':
                    file_name = _file.name
            file_location = settings.MEDIA_ROOT + '/' + folder_name + '/' + file_name
            data = rasterio.open(file_location)
        print(type(data))
        return JsonResponse(context)

Up to here everythings is working fine but i didn't know to serialize this data, os data i can plot raster data in leaflet.

1

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.