Find more posts tagged with
Sort by:
1 - 2 of
21
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 & 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&request=GetFeature&version=1.1.0&typeName=ogdwien:SPIELPLATZOGD&srsName=EPSG:4326&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; 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)); 	example.setValue(geoh, hash.encode(point)); } return(exampleSet);"/>
</operator>
<connect from_op="Read & 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>
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.