Receive email notifications by changing your settings.
Click on your picture in the top right corner, go to Preferences and select your notification preferences.

Url Rain Area

Hi,

I would like to make a rain area with the API, but can't find the correct URL. Could you please help?

Thank you!

Tagged:

Comments

  • Hi Ward,

    Good question!

    API calls like this are pretty advanced, so I will need to get back to you on this after checking first on my end.

    Regards,

    Vincent

  • Hi Ward,

    We had a look at the API calls available to you and we suggest you try the following:

    1.     Add an area (https://engine.tygron.com/api/session/event/editorarea/add/?token= )

    2.     Set an attribute (RAIN_M) for that area (https://engine.tygron.com/api/session/event/editorarea/set_attribute/?token=)

    3.     Add an array of values for the attribute.

     

    See also: https://support.tygron.com/wiki/Rain_m_(Water_Overlay) 

    Please let us know if this works for you.

    Regards, Vincent

  • Hi Vincent,

    Thank you, but not sure if this works for me. Let me give you a bit more context. I have satelite-data (converted to a geojson) with the rainareas. There is just one value for each area. So, I have the sum of the rainfall for a day as an atribute in my geojson. I'd like to use this data.

    It is very similair to the pilot Rudolf made (5/6: Neerslag modelleren aan de hand van radar beelden., https://www.youtube.com/watch?v=78sooKxMw9I)

    So I think I should create area files in Tygron by uploading my file.

    (https://engine.tygron.com/api/session/event/editorarea/import/?token=)

    However, I do need some help with the different required paramters.0 .

    1. Collection of Area geometries:
    2. Area Names: That's up to me, ia, can't go wrong there.
    3. Attribute Names: RAIN_M
    4. Attribute Values:
    5. Buffer for Points and Lines to make Polygons (optional): Again, up to me. In my case the minimum of 0.5 m is fine.
    6. Source: And again, up to me, can't go wrong.

    So I think I need help with #1 and #4.

    I am familiar with the base64 encoding and my guess is that I have to use it for one of the parameters.

    And let say, this is the correct way forward. I now have different areas with an attribute RAIN_M. But what is next....

    1. Add Overaly
    2. Set result type: RAIN
    3. Set key:


    I dont know and I can really use some help

    Thank you, Ward

  • Hey Ward,

    I see some similarity to an earlier question also touching upon the subject of uploading your own geodata file:

    https://community.tygron.com/forum/discussion/comment/857#Comment_857

    An important preface is that although the IMPORT event in the API can be used if you want, and is used by the geo import wizard in the Tygron Platform client, it doesn't do any file handling in-and-of itself. It is up to the client (be it the Tygron Platform client application, or your own script) to unpack the file's data to the required parameters, which are JSON-structured gemoetry collections, and lists of names, attributenames, and attribute values.


    It is still highly recommended to split up the steps: create the desired areas, assign them their needed polygons, give them the names you want, and set the appropriate attributes.


    If you really want to use the import function and do this all in one call, the parameters for IMPORT are structured as follows:

    1: A geometry collection consisting of one or more multiploygons. Each multipolygon will become a single Area in Tygron. This collection is a list, so the geometries are in an order. Let's assume a list of 2, so that's a first geometry and a second geometry

    2: A list of names. Each name in the list will be matched to each geometry in order of appearance. So for a list of "[A, B]", the first geometry will be named A, and the second geometry will be named B.

    3: A list of attribute (names) to define for all areas. Let's say FOO, BAR, and BLUB.

    4: A list of lists of attribute values for all areas and their attributes. This is structured as a single list of values, each index in the list matching a specific area and attribute. For example, when importing 2 geometries and 3 attributes, you could provide the following input: "[ 1.0,2.0,3.0, 4.0, 5.0,[6.0, 7.0] ]".

    The result will be an area A with FOO=1, BAR=2, BLUB=3 as attributes, and an area B with FOO=4,BAR=5, and BLUB will be an array of values, specifically "6 7"



    After importing the areas via whichever route you prefer, you will have the areas in your project. Next, just like in the first step of the water overlay's wizard, you still need to set something to let the water overlay use those rain areas. Specifically, set the following Attribute of the Overlay:

    https://support.tygron.com/wiki/Limit_rain_(Water_Overlay)


    Remember the rule of thumb that each action in the Client has effectively an 1-on-1 endpoint in the API, and this works the other way around as well. For any use-case, it may be valuable to configure the setup you want to calculate via the client first, so that you are familiar with the required actions or the end-state of the data as you wish to have it configured in your project. If you inspect any kind of data in the API, then change any setting in your project, you can re-inspect the same data in the API and see the change effected by the user interface. You then also have a better idea of what data manipulation you need to perform via the API. This should help greatly with finding whatever options or configurations you wish to use.

  • Hi hi,

    I'm stuck. Somehow I can't add polygons to an area.

    I am using just the URL's (for instance add polygon (https://engine.tygron.com/api/session/event/editorarea/add_polygons/?token=) and there I use the following input:

    1. Areas: 591
    2. Multipolygon: { "type" : "MultiPolygon", "coordinates" : [ [ [ [ 774449.2851037377, 6836922.545985629, 0.0 ], [ 774693.3929340219, 6837142.987416703, 0.0 ], [ 774588.02193085, 6837338.720121531, 0.0 ], [ 774515.4206416948, 6837414.114532563, 0.0 ], [ 774452.0435411648, 6837438.91109955, 0.0 ], [ 774409.7360683712, 6837448.930265755, 0.0 ], [ 774229.2895115669, 6837473.957022387, 0.0 ], [ 773939.8495630688, 6837533.888073313, 0.0 ], [ 773780.1166012245, 6837587.386951828, 0.0 ], [ 773768.6092299331, 6837593.752664779, 0.0 ], [ 773803.5363719198, 6837552.299741282, 0.0 ], [ 773874.5175486252, 6837494.708549186, 0.0 ], [ 773980.4258673174, 6837436.363883547, 0.0 ], [ 774047.1493493085, 6837397.550350774, 0.0 ], [ 774076.7670300308, 6837366.548285694, 0.0 ], [ 774099.1970949351, 6837326.357881184, 0.0 ], [ 774107.8415054156, 6837279.42200802, 0.0 ], [ 774069.1907178791, 6837173.0242698705, 0.0 ], [ 774063.365172407, 6837129.698657703, 0.0 ], [ 774068.7889561225, 6837076.310505705, 0.0 ], [ 774095.4799820968, 6837022.302660505, 0.0 ], [ 774097.4446950777, 6837022.043220082, 0.0 ], [ 774221.8373209336, 6836949.94847658, 0.0 ], [ 774385.0130217336, 6836872.190846901, 0.0 ], [ 774386.2248397152, 6836858.984117107, 0.0 ], [ 774386.0027275245, 6836858.417928408, 0.0 ], [ 774449.2851037377, 6836922.545985629, 0.0 ] ] ] ] }

    The result is OK (204).

    I copied the coordinates of an existing area in my project.

    I have the same result when I use the somewhat more complicated url Import Area (https://engine.tygron.com/api/session/event/editorarea/import/?token=)

    Adding an attribute to the same area (in my case 591) does work.

    I tried both scripting it (Python) as well as just filling in the parameters on the url.

  • Hi Ward,

    We will have a look at your case and get back to you.

    Regards, Vincent

  • Hi @Ward van Laatum ,

    What you see is that the imported data with CRS in 3857 is not properly converted to the local coordinates in the Tygron Geodesign Platform. When you use the editor, the conversion takes place in the background. When scripting and using the API, the conversion needs to be done before the import. You can do so by reading the CRS envelope and the local envelope. Then you can map the real world coordinates to the local coordinate system in your script.

    Endpoint for extent in 3857 Pseudo-Mercator: https://engine.tygron.com/api/session/location/?f=JSON&token=

    Map size endpoint for extent local coordinates: https://engine.tygron.com/api/session/items/settings/MAP_SIZE_M/?f=JSON&token=

    Steps:

    1. Read extent in 3857
    2. Determine extent in LOCAL coordinates
    3. Map each coordinate in 3857 to coordinates in LOCAL

    Note: In the Tygron Platform LOCAL coordinates start at 0-0 in the top left corner of the map, NOT in the bottom left corner!

    Please let us know if this will work for you.

    Regards, Vincent

  • Hi Vincent,

    The numbers that give the map size are two numbers (https://engine.tygron.com/api/session/items/settings/MAP_SIZE_M/?f=JSON&token=). The first one is the with of the map, the second one the length of the map.

    The LOCAL coordinate of the top left corner is 0,0. And therefore the map size gives in fact the coordinates of the bottom right corner (negative width, negative length of the map). Did I understand that correct?

  • Hi @Ward van Laatum ,

    The LOCAL coordinates are positive values. For example, a 500m x500m area has at the right bottom the LOCAL coordinates X = 500 & Y = 500.

    You have to take this in consideration when converting the extent to LOCAL.

    Regards, Vincent

  • You can provide an input CRS when executing the event by adding a parameter to the query, for example adding &CRS=28992 to the url loads the polygons in the Amersfoort CRS. Note: by default 3857 is used.

    For some specific events like add_polygons (but not e.g. import) this did not work due to a bug in the array handling. Today this bug has been resolved on both LTS and Preview servers (LTS release: 2021.10.8). We have also added some additional feedback on the currently selected CRS in the event example/explanation page in the API.

Sign In or Register to comment.