Python - georeference png image to geojson of polygons - python

I have a folder of multiple png images of the same map. The map is on country level and consists of administrative polygons. I have the geojson for this and I want to georeference programmatically, with Python, all of these images to the geojson and then get the color value for each polygon.
An example of the images is this:
and the geojson for this map is available here. I have read about overlay with rasterio but it seems too complicated to rasterize my polygons and back and forth. I also read about georeferencing the polygon corners but this still is about png over tiff file.
Any ideas on how to approach this?

Related

Is there a way to extract data from a picture in JPG/PNG? (i.e world map with climate info)

I have a picture in JPG which shows the world and projections of a climate variable by 2050. I need to extract the data (as if the picture was a .tif image) underpinning the view.
I tried to convert the picture from JPG to tiff format and then used the raster function in R to visualize the result, however the chart is not reproduced correctly 100%. The second step I attempted was to then convert raster values back into the original color scale of he legend to obtain real values.
Has anyone a better idea? Thanks!

How to render an stl and save it as a png?

I am trying to render an stl and save it as a png so it is a preview of the stl.
I have a project that needs to take layer images(png) and save it as 3d(stl). I converted every layer image(approximately 300-400 image) to a numpy array. Then from those numpy arrays I made vertices and faces. My stl files are faces(triangles) aligned on top of each other. So there is no actual body in the final image just faces aligned together.(Layers have no z value)
Here is a single layer from one of my models:
And here is the final model:
And now I am trying to generate an image like the 2nd picture above. So there will be a preview of the stl model. And I am trying to figure a way out to save the preview as a png file. But I couldn't figure out the plot libraries' camera movements.
I tried matplotlib but i suppose there is no camera adjustment setting so it generates a png on a side that I do not want. That's why I want a way to control the camera. There is blender's Python API but it seems pretty confusing.
Any ideas on how to do that in Python?

3D visualization of .dicom files with ipyvolume

i'm trying to visualize a set of .dicom files using pydicom and ipyvolume.
I used pydicom to read files and then sorted them by their location and turned the slices into a 3D array. I could draw a 3D model of the data using ipyvolume.pylab.plot_isosurface() although I'm not sure if this is the right way of visualizing medical images (it's all solid pixels with the same opacity and color). I've also tried ipyvolume.pylab.volshow() but that did not work.
Is there a right way to visualize medical images with ipyvolume? or this is just not the right library for that?
DICOM file does not have 'voxel' data so you can't simply plot a dicom in 3D view. You should estimate voxel data using slices of a dicom series. after that, using a 3D modeling algorithm such as Marching Cubes you can extract final 3D model. Take a look at CTU.
I haven't used ipyvolume, but looking at the documentation it ought to be able to visualize DICOM image sets.
If you want to try another package, I use SimpleITK to load DICOM images and itkwidgets do volume visualization in a Jupyter notebook.
Here's a simple notebook that load a DICOM series and displays it:
import SimpleITK as sitk
import itkwidgets
# Get the DICOM file names in the current directory
names = sitk.ImageSeriesReader.GetGDCMSeriesFileNames('.')
# Read the DICOM series
reader = sitk.ImageSeriesReader()
reader.SetFileNames(names)
img = reader.Execute()
itkwidgets.view(img)
If the directory has more than one DICOM series in it, GetGDCMSeriesFileNames has a seriesID parameter you can give it to specify which series to load.

Manipulating rasters with QGIS that are stored in PostGIS

I am using a QGIS plugin of a friend written in Python, which reclassifies the pixels of a raster by setting points, these points span a polygon and all the pixels within the polygon will be converted or reclassified. So far, it works more or less fine if I use a normal raster image from my hard disk in the format of .img or .tiff. By reclassifying the pixels, all the changes will be automatically saved in the image on the disk.
In a next step, I want to store all my raster images in a PostGIS database and manipulate them with that tool. Unfortunately, the tool cannot convert the pixels of the image if I load them into QGIS from the database.
The tool does not produce any error message. It starts loading and then nothing happens.
So the question is: Do I need to adapt the saving method of the plugin or is it generally impossible to manipulate raster images in QGIS which are stored in a database, or do I need special rights to access the raster images raster data type?

Python: Add/edit annotations in images

There is an image and a multiset of pixel coordinates. Each set corresponds to a polygon.
The problem at hand is to overlay all the polygons onto the image, adjust their shapes/sizes to cover specific areas in the image and then save the resulting view of the image.
Suggestions on how to get started on this would be highly appreciated!
I realize I was talking about image annotation. I found 'sloth'. I am giving it a try.
https://cvhci.anthropomatik.kit.edu/~baeuml/projects/a-universal-labeling-tool-for-computer-vision-sloth/

Categories

Resources