How to make the Geoserver SLD with vector layer(linestring geometry) if rasterize gray color lines to RGB color line using RasterSymbolizer Colormap? - geoserver

I am a starter with the Geoserver.
I created lineString vector layer with lineSymbolizer SLD style.
And the vector layer is connected by postgis and that layer only have linestring geometry rowdata. other attributes values does not exist(only linstring coordinates)
grayscaled layer
<?xml version="1.0" encoding="UTF-8"?>
<StyledLayerDescriptor version="1.0.0"
xsi:schemaLocation="http://www.opengis.net/sld StyledLayerDescriptor.xsd"
xmlns="http://www.opengis.net/sld"
xmlns:ogc="http://www.opengis.net/ogc"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<!-- a Named Layer is the basic building block of an SLD document -->
<NamedLayer>
<Name>line</Name>
<UserStyle>
<Title>Line</Title>
<Abstract>greyscaled line</Abstract>
<FeatureTypeStyle>
<Rule>
<Name>rule1</Name>
<Title>greyscaled Line</Title>
<Abstract></Abstract>
<LineSymbolizer>
<Stroke>
<CssParameter name="stroke">#000</CssParameter>
<CssParameter name="opacity">0.1</CssParameter>
</Stroke>
</LineSymbolizer>
</Rule>
</FeatureTypeStyle>
</UserStyle>
</NamedLayer>
</StyledLayerDescriptor>
and I want to convert or set this layer greyscaled color to RGB coloring by quantity.
the outputs should be like this image
RGB Colormap
Geoserver RasterSymbolizer
I tried make new SLD using 'RasterSymbolizer Colormap' from geoserver, but I failed..
Is it possible use rasterSymbolizer in linestring vector layer map?

Related

Polygon on Raster query in GeoServer

I need to perform a polygon on raster cookie-cut and pixel sum using GeoServer. The polygon (GeoJSON) and raster are both in WGS84 (4326). The raster is a very large GeoTIFF population raster published with GeoServer. I have two questions:
How to do the entire operation in GeoServer?
Alternatively, how to query the raw pixel values from the rectangular extent of the polygon (minx, miny, maxx, maxy), and I can do the pixel in/out sum analysis myself.
I have tried WMS queries and WCS queries but cannot find a way to request the raw pixel values rather than a PNG rendered result. I have also tried some WPS sample queries, with no success. I'm not seeing much from Google on polygon-on-raster statistics. Is this entire query possible in GeoServer? Or is at least fetching a rectangular area of raw pixels from the GeoTIFF from GeoServer possible?
Thanks!!
To fetch a rectangle of pixels as a GeoTiff you would need to use a WCS request. The easiest way to define one of those is using the WCS Request generator - for example:
<?xml version="1.0" encoding="UTF-8"?><GetCoverage version="1.0.0" service="WCS" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.opengis.net/wcs" xmlns:ows="http://www.opengis.net/ows/1.1" xmlns:gml="http://www.opengis.net/gml" xmlns:ogc="http://www.opengis.net/ogc" xsi:schemaLocation="http://www.opengis.net/wcs http://schemas.opengis.net/wcs/1.0.0/getCoverage.xsd">
<sourceCoverage>nurc:Pk50095</sourceCoverage>
<domainSubset>
<spatialSubset>
<gml:Envelope srsName="EPSG:32633">
<gml:pos>347649.93086859107 5176214.082539256</gml:pos>
<gml:pos>370725.976428591 5196961.352859256</gml:pos>
</gml:Envelope>
<gml:Grid dimension="2">
<gml:limits>
<gml:GridEnvelope>
<gml:low>0 0</gml:low>
<gml:high>545 490</gml:high>
</gml:GridEnvelope>
</gml:limits>
<gml:axisName>E</gml:axisName>
<gml:axisName>N</gml:axisName>
</gml:Grid>
</spatialSubset>
</domainSubset>
<output>
<crs>EPSG:32633</crs>
<format>GeoTIFF</format>
</output>
</GetCoverage>
To extract values of a raster bounded by a polygon you can use a WPS request to crop to a polygon and then sum the pixels yourself:
<?xml version="1.0" encoding="UTF-8"?><wps:Execute version="1.0.0" service="WPS" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.opengis.net/wps/1.0.0" xmlns:wfs="http://www.opengis.net/wfs" xmlns:wps="http://www.opengis.net/wps/1.0.0" xmlns:ows="http://www.opengis.net/ows/1.1" xmlns:gml="http://www.opengis.net/gml" xmlns:ogc="http://www.opengis.net/ogc" xmlns:wcs="http://www.opengis.net/wcs/1.1.1" xmlns:xlink="http://www.w3.org/1999/xlink" xsi:schemaLocation="http://www.opengis.net/wps/1.0.0 http://schemas.opengis.net/wps/1.0.0/wpsAll.xsd">
<ows:Identifier>ras:CropCoverage</ows:Identifier>
<wps:DataInputs>
<wps:Input>
<ows:Identifier>coverage</ows:Identifier>
<wps:Reference mimeType="image/tiff" xlink:href="http://geoserver/wcs" method="POST">
<wps:Body>
<wcs:GetCoverage service="WCS" version="1.1.1">
<ows:Identifier>nurc:Pk50095</ows:Identifier>
<wcs:DomainSubset>
<ows:BoundingBox crs="http://www.opengis.net/gml/srs/epsg.xml#32633">
<ows:LowerCorner>347649.93086859107 5176214.082539256</ows:LowerCorner>
<ows:UpperCorner>370725.976428591 5196961.352859256</ows:UpperCorner>
</ows:BoundingBox>
</wcs:DomainSubset>
<wcs:Output format="image/tiff"/>
</wcs:GetCoverage>
</wps:Body>
</wps:Reference>
</wps:Input>
<wps:Input>
<ows:Identifier>cropShape</ows:Identifier>
<wps:Data>
<wps:ComplexData mimeType="application/wkt"><![CDATA[POLYGON((x1 y1, x2 y2,......))]]></wps:ComplexData>
</wps:Data>
</wps:Input>
</wps:DataInputs>
<wps:ResponseForm>
<wps:RawDataOutput mimeType="image/tiff">
<ows:Identifier>result</ows:Identifier>
</wps:RawDataOutput>
</wps:ResponseForm>
</wps:Execute>
Or you could write your own custom process to carry out the whole process in one go.

How to implement rendering transformations on Geoserver using NDVI index?

I want to implement a rendering transformation using the NDVI index on grayscale tiff. I am following this link:-
https://docs.geoserver.org/stable/en/user/styling/sld/extensions/rendering-transform.html
What type of data will work for it?
I tried the sld provided in the Geoserver manual, but that doesn't seem to work on my data, but on applying that style, it does not work
<NamedLayer>
<Name>cite:NDVI</Name>
<UserStyle>
<Title>NDVI</Title>
<FeatureTypeStyle>
<Transformation>
<ogc:Function name="ras:Jiffle">
<ogc:Function name="parameter">
<ogc:Literal>GRAY_INDEX</ogc:Literal>
</ogc:Function>
</ogc:Function>
</Transformation>
<Rule>
<RasterSymbolizer>
<Opacity>1.0</Opacity>
<ColorMap>
<ColorMapEntry color="#0000ff" quantity="-0.17"/>
<ColorMapEntry color="#548022" quantity="0.07"/>
<ColorMapEntry color="#f6f7f5" quantity="0.4"/>
</ColorMap>
</RasterSymbolizer>
</Rule>
</FeatureTypeStyle>
</UserStyle>
</NamedLayer>
</StyledLayerDescriptor>
I want my grayscale tiff to be transformed to NDVI band color mapping.
The page you link to shows how to calculate NDVI from a multiband Sentinel image by combining bands 3 and 7, using this formula.
nir = src[7];
vir = src[3];
dest = (nir - vir) / (nir + vir);
Your grayscale image only has one band so it is impossible to calculate NDVI from it.

How to get width/height of displayed image in javafx imageView?

I need to get width/height of displayed image in imegView and compare it to orginal image size which is in imageView.getImage().getWidth()/getHeight() and listen changes if user resize it form application GUI.
I get this size from imageView.fitWidthProperty() and similar for height, but I get size of imageView not image within it:
I get size of blue which is imageView but I need size of displayed image (green). How can I get it as property to listen when user resize window app (green also change size but it seems to have max and min size so it stop resize with imageView when it is max or min).
I use this property to compute % of size of orginal image in bottom right below blue rectangle.
Is it possible?
E: Below is fxml of this tab:
<BorderPane fx:id="root" fx:controller="..."
xmlns:fx="..." xmlns="..." stylesheets="#...css">
<center>
<StackPane>
<ImageView fx:id="..."/>
<fx:include source="...fxml" fx:id="..."/>
</StackPane>
</center>
<bottom>
<VBox fx:id="..." minHeight="110" styleClass="small-padding" spacing="5">
<HBox alignment="CENTER_RIGHT" spacing="5">
<fx:include source="...fxml" resources="..."
fx:id="..."/>
</HBox>
<TextArea fx:id="..." promptText="%..." styleClass="-fx-description-text-area"/>
</VBox>
</bottom>
When the ImageView is set to preserve the aspect ratio, one has to calculate the real dimensions by hand. At least I've not found another way.
double aspectRatio = image.getWidth() / image.getHeight();
double realWidth = Math.min(imageView.getFitWidth(), imageView.getFitHeight() * aspectRatio);
double realHeight = Math.min(imageView.getFitHeight(), imageView.getFitWidth() / aspectRatio);
To explain this a bit: getFitHeight/Width is your blue rectangle. When preserving the aspect ratio of the source image, at least one side of the blue rectangle must have the same length as the corresponding side of the green rectangle. Also, the green rectangle will always be inside of the blue one, hence the call to Math.min().
~>1)
The fact that the Image is not resizing to cover all the ImageView has to do with preserveRatio method.If you want to be covered setPreserveRatio(false);
with a combination of setSmooth( true );
~>2)
The green border is the size of the original image.
~>3)
Before adding the Image to the ImageView you can do:
Image image = new Image("FILE:...");
image.getWidth( );
image.getHeight( );
And that is the original size of the image.
As for the size of the image when it is displayed inside the ImageView:
imageView.getFitWidth();
imageView.getFitHeight();
For the size of ImageView inside the Scene (the blue border in your question):
imageView.getWidth();
imageView.getHeight();
ImageView class has properties for the above.
I am not aware of any property that you could use directly to get at the numbers you want but you might propose this as an improvement for a future version of JavaFX.
What you can do now is write some code which tracks all proerties of the ImageView which have an influence on the size of the displayed image and then compute the displayed size yourself. This does not sound too complicated to me.

Nested SVG viewBox and preserveAspectRatio to align <image>

I am constructing an svg using D3.js. Inside it I am using <image> to place two types of images img1 and img2 where both have same width W but img1 is shorter than img2 i.e. H1<H2.
They should be placed within the outer svg in a rectangle with dimensions WxH2 at position (x,y) and the shorter one (img1) should be aligned vertically at the bottom of this rectangle like this:
This sounds like a job for viewBox & preserveAspectRatio so I tried creating a nested <svg> element with dimensions WxH2 (the larger of the 2 heights) at position (x,y) and depending on the image dynamically added each time, the layout (here shown with both images) would be:
Sample code with W=35, H1=19, H2=88, x=100, y=200:
```
<svg...> <!--outer SVG-->
<svg width="35" height="88" x="100" y="200" viewBox="0 0 35 88" preserveAspectRatio="xMidYMax meet"> <!-- nested SVG-->
<image xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="img1_OR_img2" width="35" height="CORRESPONDING_img_HEIGHT"></image>
</svg> <!-- end of nested SVG-->
</svg> <!-- end of outer SVG-->
```
The problem is that the height of the nested svg is ignored and it's the height of the <image> that defines the height of the rectangle. So no matter what vertical alignment I ask for through preserveAspectRatio in the nested svg, in the case of the shorter image img1 it will not make a difference since the rectangle is already the height of the img1. If I have <image> always have the larger height H2, then the smaller image img1 appears vertically aligned in the middle.
Should I be using a whole different substructure instead of a nested svg or am I misusing the viewBox/preserveAspectRatio combo?
Note: regarding the topic viewBox & preserveAspectRatio, I used this article which is the best I've found online so far (kudos to Sara for an amazing article).
Your problem is that you are changing the heights. In both cases you should be using 88 for "CORRESPONDING_img_HEIGHT". You need to use the same viewport for both images and let SVG position the image within the viewport according to the preserveAspectRatio setting.
In fact, you don't need to be using nested SVGs. The <image> element also has a preserveAspectRatio attribute.
<svg xmlns:xlink="http://www.w3.org/1999/xlink">
<image x="100" y="200" width="35" height="88" xlink:href="img1" preserveAspectRatio="xMidYMax meet"/>
<image x="100" y="200" width="35" height="88" xlink:href="img2" preserveAspectRatio="xMidYMax meet"/>
</svg>

Can friction be added to a joint in a PyBrain ODE simulation?

This is my first time asking a question so I'll try my best to include all the necessary information.
I am currently working on a machine learning project using PyBrain. My aim is for a driven pendulum to learn when force should be applied to maximise the amplitude of oscillation.
To do this, I have modelled the system in ODE (Open Dynamics Engine) using the xodetools.py script that is included with PyBrain. While the model works and is simulated, I cannot figure out how to add friction to the pendulum hinge joint.
Some of the example models included with Pybrain (e.g. johnnie_pgpe) redefine a paramater called FricMu in their Task class. I have included this in my code, but no matter what value I set FricMu equal to the system is unchanged (note: if I make it a string the simulation still runs so I presume this parameter is actually doing nothing).
A quick look at the ODE documentation (http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions#Contact) suggests to me that I need to be using a contact joint. This type of joint is not supported by the script so I think would require me to write direct to the XML file.
Can someone with an understanding of either PyBrain or ODE give me some advice on how to increase the damping of my system. Thank you.
Below is the XML code for the pendulum that is imported by PyBrain
<?xml version="1.0" encoding="UTF-8"?>
<xode version="1.0r23" name="pend"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://tanksoftware.com/xode/1.0r23/xode.xsd">
<world>
<space>
<body name="arm">
<transform>
<position y="0" x="0" z="0"/>
</transform>
<mass>
<mass_shape density="125.0">
<box sizex="0.2" sizez="0.2" sizey="0.2"/>
</mass_shape>
</mass>
<geom>
<box sizex="0.2" sizez="0.2" sizey="0.2"/>
</geom>
</body>
<body name="swing">
<transform>
<position y="0" x="0" z="2.2"/>
<rotation>
<euler y="0" x="0" aformat="degrees" z="0"/>
</rotation>
</transform>
<mass>
<mass_shape density="6.36619772588">
<cylinder length="5" radius="0.05"/>
</mass_shape>
</mass>
<geom>
<cylinder length="5" radius="0.05"/>
</geom>
</body>
<joint name="arm_swing">
<link1 body="arm"/>
<link2 body="swing"/>
<hinge>
<axis y="0" x="1" z="0"/>
<anchor y="0" x="0" z="0" absolute="true"/>
</hinge>
</joint>
<joint name="fixedPoint">
<link1 body="arm"/>
<link2 body="swing"/>
<fixed>
</fixed>
</joint>
<geom name="floor">
<plane a="0" c="0" b="1" d="-44.0"/>
</geom>
</space>
</world>
</xode>
<!--odeenvironment parameters
<passpairs>
('arm', 'swing')
<affixToEnvironment>
fixedPoint
<end>
-->

Resources