How can I read a specific level in TIF image with pyvips? - tiff

I'm trying to read a specific level (level=3) using pyvips:
image = pyvips.Image.new_from_file(data/imagestif/SUH_BR_0002.tif,level=3)
But I get this error:
KeyError: 'level'
I don't why I can't specify the level with that argument, as the documentation says. I'm using 8.13 pyvips version.

The level= parameter is for the openslide loader, so you can only use it for formats like SVS.
The TIFF loader doesn't know about pyramids, since TIFF images are organized in terms of pages and subifds. You probably want:
level = pyvips.Image.new_from_file("thing.tif", page=3)
But it depends on your file. Different applications will have encoded a pyramid into your tiff in different ways.

Related

Missing object properties in design metadata SQLite file

My model in Autodesk construction cloud contains several properties which I need to track. I have downloaded the sqlite file using fetch derivative download URL without any errors.
However when comparing export with what I see in ACC, or the Fetch all properties call, some properties are entirely missing. For instance, the fetch all properties call returns the 20 expected property values whereas only 3 of these values exist in the SQLite download. Any explanation why the SQLite file may be incomplete? There doesn't seem to any size restriction or filter in the call returning SQLite which may explain partial results.
It is expected that the design metadata returned via sqlite and via JSON may not be the same. For example, the metadata captured in the sqlite database use "instancing" where multiple design elements may inherit certain properties from another element (and the resolution of the inherited properties is left to whomever is reading this file). The JSON format on the other hand does not support any kind of inheritance, so properties are duplicated for each individual design element.

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.

How to use AWS S3 raster file in Mapbox gl js?

Mapping a Cloud Optimized Geotiff raster layer in Mapbox GL JS
I think I use a raster source, the source data need to be tiled. the URL would be like .../{z}/{x}/{y}.tif.
But I don't know how to make above URL. how to make url??
I'm not exactly sure what you're asking. If you're asking "how do I turn this GeoTIFF into a tiled raster source", two options are:
Upload it to Mapbox. (In theory this works, although it has not always been successful for me.)
Use GDAL to convert it to mbtiles, then host the .mbtiles file somewhere (either on Mapbox, CloudTiler, or your own hosting.)
In the latter case, that would look like:
gdal_translate myfile.tif mytiles.mbtiles
Mapbox SDK wants to fetch tiles by Z/X/Y. However, you can probably register a NSURLProtocol subclass where you can take the Z/X/Y URL and create the proper COG request, transform the image and return the correct content.
I have used this to register mbtiles:// as a URL scheme and my NSURLProtocol subclass transform the Z/X/Y URL to a SQLite select statement.
You can read more on this subject over at https://github.com/mapbox/mapbox-gl-native/issues/12026

Printing Locally Stored Photos in Adobe Flex/Air

In my Adobe Flex/Air application I have an ArrayCollection storing a list of details (including the file path) for locally stored photographs.
What would be the best way to print all these photos from within the application?
The solution consists of two steps:
Load images. It can be done by using Loader. It can load images by local path or URL.
Print images. Flex have appropriate class for printing - FlexPrintJob. It can print any UIComponent (Bitmap too).
I did not write all the code, but there are examples in the documentation and there is not any magic =). But if you have question feel free to ask.

JSON format for Three.JS

I have a problem with JSON format.
I am going to generate a 2D building plan in JSON format automatically. Then this JSON file is loaded to Three.JS for visualization.
Currently, I can easily create various geometry type in JSON format based on:
https://github.com/mrdoob/three.js/wiki/JSON-Model-format-3.1
However, I need to know more about this data format.
Firstly, how can I add text to the model?
Secondly, I could not find line as a geometry in this format. Is there?
Thirdly, is there any document that I can refer to it for more explanation regarding this
format?
Lastly, how can I add additional information about geometries
inside the JSON format? for example when I create a polygon in JSON
format, I want to add additional information regarding that polygon
such as area, owner,...
Either through a texture, or by creating THREE.TextGeometry and merging that with the other geometry
AFAIK, no. You might be able to emulate lines by loading a separate object that you render as wireframe.
I've used the source code: Loader, JSONLoader
I don't think that's possible while maintaining compatibility, i.e. you would need to patch Three.js loader.
One option for achieving what you want could be to add custom entries to the JSON, e.g. "lines": [], "customFaceProperties": [] and then parse them yourself once the stock Loader has parsed everything it understands.
Also, since it seems you might be creating something that has different things in it, you might want to take a peek at the scene loading capabilities: example, SceneLoader.js