Incorrect image size when generating raster png images from vector data - gis

I am writing a python API (WMS format) to fetch the gridded weather data(rainfall) and convert it into png images. I am using GDAL for this and involves below steps:
Fetching data from database using the BBOX from WMS
Rasterizing the data using gdal.Rasterize and converting the data into tiff files
Then applying style to the tiff using gdal.DEMProcessing and converting the tiff into png and returning the PNG images as output from the API.
Consuming this WMS API from openlayers to overlay the data on map.
Problem:
The problem I am facing is I am unable to get proper image size of the generated images because of which the data is shown as below in the image. Need help to know what is the correct set of options to be used in rasterize or demprocessing to get correct output. Sample code:
options = gdal.RasterizeOptions(
format='GTiff', attribute='value', noData=NoData_value,
width=w, height=h,
outputType=gdalconst.GDT_Float32,
outputBounds=[x_min,y_min,x_max,y_max],
outputSRS=crs)

Related

get layer date of dot max file via forge viewer

I am currently tring to retrive layer data from forge viewer.
Have tried get it with viewer.impl.getLayerRoots() function but not work. The data that I got is sth like
this.
The original data is a .max file and layer info is this.
Comparing to what I got totally not match so I am wondering what is the solution
unfortunately the 3ds Max (*.max) translator does not extract layer information from the max scene file. This is a known limitation.

How to convert a json file to binary image for semantic segmentation

I have some images and labeled them using labelimg tool of python. I have got individual JSON files for all the images. Now, I need how to convert them into binary mask images. Can anybody help me with that?
TIA

What code can be used to load json format dataset for training U-Net?

In my dataset folder, I have images in jpg format and segmentation(masked images) in json format. I want to load this dataset accordingly to train using basic U-Net architecture. In most of the code U-Net is trained on masked images which are either in png or jpg format. For each image there is annotation in the format of json file. What code can I use to load these masked images(which are in json format) for training purpose?

How is it possible to reduce the size of Html file generated from Folium map in Python?

I'm using folium.GeoJson to plot polygons on a map. I have one dataset with different fields/attributes; I'm using the same data for each folium.GeoJson layer but with various fields to display different attributes and add them in layer control. I guess this makes the final Html file big in size.
One solution I found to reduce the Html file is to minify it, but the slimmer package isn't available in anaconda.
Do you have any suggestions for this case?
You can reduce the size of the HTML file dramatically by using mapshaper to reduce the size of the geojson file.
Drop your file or search and import. I check the box "detect line intersections" and upload:
Choose your method of simplifying the coordinates (I use Douglas-Peucker method, and prevent shape removal):
Then set the simplification (you can play with the settings to get the desired result, I found 3% worked well)
Then export the file (it exports as a .json file so remember to change to .geojson:
This reduced the file from 17.6MB to 614KB and the outputted HTML file from 222MB to 7.58MB
Found a way: to simplify spatial data that significantly reduces data size.
In my case, I was using shapefile as the spatial data, particularly polygons, that is, the collection of points (vertices) and highly affected the data size. I just used the simplification tool that removes extraneous vertices but preserves essential shape. I used the Simplify Polygon tool in ArcMap, but the same is possible in python with the geopandas.GeoSeries.simplify function and in R with the 'sf' library.

Convert autodesk .dwg and .dwf files to three.js json format

I want to render 3D graphics files of autodesk (.dwg and .dwf) using three.js but three.js requires 3D data to be in json format. So, I need to convert these files to three.js readable json format. I tried searching on the internet but couldn't find any solution. Can anyone tell me a good converter for these files?
Thanks in advance.
In fact Autodesk already have a converter & wegbl viewer. Go to http://developer.autodesk.com and get a key for View & Data API. There is a server side REST API that allow you to upload a CAD file and convert to a JSON stream. You can hook to it and get the output. Or, even easier, just use the JavaScript client side API to embed the viewer on your website/app
Update
The API was renamed to Model Derivative + Viewer, the first translates the source file (e.g. DWG, RVT and many others) to a web-friendly format that can be viewed on the second, which is based on Three.js (and can be customized).