🎉Community Raffle - Win $25

An exclusive raffle opportunity for active members like you! Complete your profile, answer questions and get your first accepted badge to enter the raffle.
Join and Win

Geohash

User: "jeremy"
New Altair Community Member
Updated by Jocelyn

Anyone know of an extension for converting lat and long coordinates into Geohash codes and vice versa? Anyone out there using Geohash coding to work with spatial and temporal data in RapidMiner?

Find more posts tagged with

Sort by:
1 - 2 of 21
    User: "Thomas_Ott"
    New Altair Community Member

    I'm not familiar with geohashing but maybe @BalazsBarany might be able to help. There are no known extensions that do it automatically but it soulds like it's an calculation and you might be able to use a Generate Attributes operator to work on the Lat/Longs to create a new Geohash attribute.

    User: "BalazsBaranyRM"
    New Altair Community Member

    Hi,

     

    you can use the built-in scripting with the GeoScript library and Groovy scripts to convert objects to GeoHash.

     

    Refer to my blog posts for the basics.

     

    Here's an example script:

     

    //Imports
    import com.rapidminer.tools.Ontology;
    import geoscript.geom.*;
    import geoscript.index.GeoHash;

    ExampleSet exampleSet = input[0];
    Attributes attributes = exampleSet.getAttributes();

    playgroundGeom = attributes.get("SHAPE");

    Attribute geoh = AttributeFactory.createAttribute("GeoHash", Ontology.NOMINAL);
    exampleSet.getExampleTable().addAttribute(geoh);
    attributes.addRegular(geoh);

    hash = new GeoHash();

    for ( Example example : exampleSet ) {

    point = Geometry.fromString(example.getNominalValue(playgroundGeom));

    //Calculates GeoHash from Point object
    example.setValue(geoh, hash.encode(point));
    }

    return(exampleSet);

    Sample process (it downloads some open data and calculates the GeoHash values in a new attribute):

    <?xml version="1.0" encoding="UTF-8"?><process version="7.2.003">
    <context>
    <input/>
    <output/>
    <macros/>
    </context>
    <operator activated="true" class="process" compatibility="7.2.003" expanded="true" name="Process">
    <parameter key="random_seed" value="2001"/>
    <process expanded="true">
    <operator activated="true" class="subprocess" compatibility="7.2.003" expanded="true" height="82" name="Read &amp; transform playgrounds" width="90" x="112" y="34">
    <process expanded="true">
    <operator activated="true" class="open_file" compatibility="7.2.003" expanded="true" height="68" name="Open playgrounds" width="90" x="45" y="30">
    <parameter key="resource_type" value="URL"/>
    <parameter key="url" value="http://data.wien.gv.at/daten/geo?service=WFS&amp;request=GetFeature&amp;version=1.1.0&amp;typeName=ogdwien:SPIELPLATZOGD&amp;srsName=EPSG:4326&amp;outputFormat=csv"/>
    </operator>
    <operator activated="true" class="read_csv" compatibility="7.2.003" expanded="true" height="68" name="Read playgrounds" width="90" x="179" y="30">
    <parameter key="csv_file" value="/home/barany/Downloads/ogd/spielplätze.csv"/>
    <parameter key="column_separators" value=","/>
    <parameter key="first_row_as_names" value="false"/>
    <list key="annotations">
    <parameter key="0" value="Name"/>
    </list>
    <parameter key="encoding" value="UTF-8"/>
    <list key="data_set_meta_data_information">
    <parameter key="0" value="FID.true.polynominal.attribute"/>
    <parameter key="1" value="OBJECTID.true.integer.attribute"/>
    <parameter key="2" value="SHAPE.true.polynominal.attribute"/>
    <parameter key="3" value="FEATURES.true.polynominal.attribute"/>
    <parameter key="4" value="OPENING_HOURS.true.polynominal.attribute"/>
    <parameter key="5" value="PLACE.true.polynominal.attribute"/>
    <parameter key="6" value="DISTRICT.true.integer.attribute"/>
    <parameter key="7" value="DRINKING_OPPORTUNITY.true.polynominal.attribute"/>
    <parameter key="8" value="URL.true.polynominal.attribute"/>
    <parameter key="9" value="SE_ANNO_CAD_DATA.false.attribute_value.attribute"/>
    </list>
    </operator>
    <connect from_op="Open playgrounds" from_port="file" to_op="Read playgrounds" to_port="file"/>
    <connect from_op="Read playgrounds" from_port="output" to_port="out 1"/>
    <portSpacing port="source_in 1" spacing="0"/>
    <portSpacing port="sink_out 1" spacing="0"/>
    <portSpacing port="sink_out 2" spacing="0"/>
    </process>
    </operator>
    <operator activated="true" class="execute_script" compatibility="7.2.003" expanded="true" height="82" name="Calculate GeoHash" width="90" x="380" y="34">
    <parameter key="script" value="import com.rapidminer.tools.Ontology;&#10;import geoscript.geom.*;&#10;import geoscript.index.GeoHash;&#10;&#10;ExampleSet exampleSet = input[0];&#10;&#10;Attributes attributes = exampleSet.getAttributes();&#10;&#10;playgroundGeom = attributes.get(&quot;SHAPE&quot;);&#10;&#10;Attribute geoh = AttributeFactory.createAttribute(&quot;GeoHash&quot;, Ontology.NOMINAL);&#10;exampleSet.getExampleTable().addAttribute(geoh);&#10;attributes.addRegular(geoh);&#10;&#10;hash = new GeoHash();&#10;&#10;for ( Example example : exampleSet ) {&#10;&#10;&#9;point = Geometry.fromString(example.getNominalValue(playgroundGeom));&#10;&#10;&#9;example.setValue(geoh, hash.encode(point));&#10;}&#10;&#10;return(exampleSet);"/>
    </operator>
    <connect from_op="Read &amp; transform playgrounds" from_port="out 1" to_op="Calculate GeoHash" to_port="input 1"/>
    <connect from_op="Calculate GeoHash" from_port="output 1" to_port="result 1"/>
    <portSpacing port="source_input 1" spacing="0"/>
    <portSpacing port="sink_result 1" spacing="0"/>
    <portSpacing port="sink_result 2" spacing="180"/>
    </process>
    </operator>
    </process>