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?
Related
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?
I've got a processed image array from UAV and want to write it into a projected tiff. I am aware with the array to tiff writting process with python gdal, however not sure how to project it correctly.
I have got the central GPS, UAV height, pixel size of the image array, the array is northward. The orginal UAV image's metadata can not be recognized by gdal, so I have to extract them out and then rearrange them to project the array.
Many thanks!
This question is too vague. The process you need to look into is called "ortho-rectification". You should read about the process and then break it down into stages. Then, figure out the specific pieces you have and don't have.
Fundamentally, in order to create an ortho-image, you need a digital elevation model (DEM), intrinsic camera parameters, and extrinsic parameters (pose). You can find documentation on the algorithm online or in a standard Remote Sensing book.
Another option is if your camera provides Rational Polynomial Coefficients (RPCs), which I assume is no.
Generic Amazon Search of Remote Sensing Books
https://www.amazon.com/s/ref=nb_sb_noss_2?url=search-alias%3Daps&field-keywords=remote+sensing
How do I add circle-clipped image glyphs to my chart, without processing and uploading the images manually beforehand? I'm open to using other modules.
I want the end result to look something like this chart (from nytimes).
http://imgur.com/a/Nv6ta
My current understanding is that we can only load images directly from urls, which is not my desired outcome.
http://docs.bokeh.org/en/latest/docs/reference/models/glyphs/image_url.html
My current understanding is that we can only load images directly from urls
This is not correct, there is also ImageRGBA which allows for sending images as raw RGBA data, directly embedded in the Bokeh document. See, e.g., this gallery example:
http://docs.bokeh.org/en/latest/docs/gallery/image_rgba.html
So assuming that images is a Python list of 2D NumPy arrays of RGBA data for the (pre-cropped) images you want to display, then Bokeh could show them with:
p.image_rgba(image=images, x=....)
Of course, you have to convert the images to RGBA arrays yourself, and also crop them, so things may simply be easier or more ready made for this use-case with another tool.
I have a local directory full of geotiff files which make up a map of the UK.
I'm using mapnik to render different images at various locations in the UK.
I'm wondering what is the best way to approach this?
I can create a single RasterSymbolizer then loop through the tiff directory and add each tiff as a seperate layer, then use mapniks zoom_to_box to render at the correct location.
But would this cause the rendering time to be unnecessarily slow? I have no information on how the tiles fit together (other than the data in each individual tiff of course).
I imagine there may be a way to setup some kind of vector file defining the tiff layout so I can quickly query that to find out which tile I need to render for a given bounding box?
You can either generate a big tiff file from the original tiffs with gdal_merge.py (you can find it in the python-gdal package on Debian or Ubuntu) or create a virtual file that mixes them all with gdal_merge-vrt. This second option saves space but probably is slower.
While saving a multiple grid figure in png with 300 as dpi, I lose quality
However this error does not occur while saving the figure as a pdf.
Here is the small portion of the code that saves the image generated:
fig.savefig(filepath, format = 'pdf'
,bbox_inches='tight',dpi=300)
fig.savefig(filepath, format = 'png'
,bbox_inches='tight',dpi=300)
Is there a way to obtain a good resolution png of an image such as the above without having to resort to using pdf?
.pdf images are vector graphics, and thus preserve all information. In other words setting dpi=300 in the pdf creation doesn't do anything (unless you have set specific objects to be rasterized using rasterized = True).
.png images are raster graphics (e.g. check this out). Therefore you have to adjust the dpi to get the balance of filesize vs. quality that you want. In other words, the image is saving correctly, it's just lower quality than the 'perfect' pdf.
The choice of image output format depends on how you will use it. Vector graphics (.pdf, .svg) are great if you have simple plots that you want to scale (zoom) perfectly. However, if you are plotting many points (>10,000 or so), this can lead to very large filesizes. In this case it may be better to rasterize the figure because a person can't see that many data points anyway.
"Which raster format should you use?" .png and .jpg are the most common. The former has better compression for images with large patches of the same color, while the latter has better compression for high pixel variability (e.g. photographs). Check this out for more info.
Note that while .png is considered 'lossless', it is only so in the sense that it preserves the rasterized information. Information is still lost when saving/converting to rasterized format.