第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

如何將 spark 數(shù)據(jù)集轉(zhuǎn)換為 geomesa simplefeature 并將其保存到

如何將 spark 數(shù)據(jù)集轉(zhuǎn)換為 geomesa simplefeature 并將其保存到

RISEBY 2022-07-20 17:00:00
我有地理數(shù)據(jù)的 CSV 文件。我使用 apache spark 將這些文件導(dǎo)入數(shù)據(jù)集,然后我想使用 GeoMesa。所以我需要將數(shù)據(jù)集轉(zhuǎn)換為 simplefeature,并以 GeoMesa 格式將其保存到 Cassandra公共類主要{public static void main(String[] args) throws IOException {    Map<String, String> dsProperties = new HashMap<String, String>();    dsProperties.put("cassandra.keyspace", "t1");    dsProperties.put("cassandra.catalog", "testgeo");    dsProperties.put("cassandra.tableName", "testgeo");    dsProperties.put("cassandra.contact.point", "localhost:9042");    DataStore ds = DataStoreFinder.getDataStore(dsProperties);    SimpleFeatureType sft = SimpleFeatureTypes.createType("testgeo", "geoid:Integer,geopoint:Point:srid=4326");    ds.createSchema(sft);    SparkSession spark = SparkSession.builder().appName("my-app").master("local[*]")            .config("spark.serializer", "org.apache.spark.serializer.KryoSerializer")            .config("spark.kryo.registrator", "org.locationtech.geomesa.spark.GeoMesaSparkKryoRegistrator")            .getOrCreate();    org.apache.spark.sql.SQLTypes.init(spark.sqlContext());    StructType schema = new StructType()            .add(new StructField("id", DataTypes.IntegerType, true, Metadata.empty()))            .add(new StructField("dt", DataTypes.TimestampType, true, Metadata.empty()))            .add(new StructField("lat", DataTypes.DoubleType, true, Metadata.empty()))            .add(new StructField("lon", DataTypes.DoubleType, true, Metadata.empty()));    Dataset<Row> df = spark.read().format("geomesa").option("header", true).option("inferSchema", true)            .option("dateFormat", "yyyy-MM-dd HH:mm:ss").schema(schema).option("delimiter", ",")            .csv("C:\\Users\\h6\\Desktop\\dta.csv");    df.createOrReplaceTempView("testgeo");    df = spark.sql("SELECT id as geoid, st_makePoint(lat, lon) as geopoint FROM testgeo");    df.show();}}
查看完整描述

1 回答

?
泛舟湖上清波郎朗

TA貢獻(xiàn)1818條經(jīng)驗(yàn) 獲得超3個(gè)贊

Cassandra 目前沒(méi)有 SpatialRDDProvider,因此您需要使用通用的“GeoTools”:https ://www.geomesa.org/documentation/user/spark/providers.html#geotools-rdd-provider

簡(jiǎn)而言之,您需要添加"geotools" -> "true"到您的tableProperties地圖中。您還需要確保適當(dāng)?shù)?Cassandra 數(shù)據(jù)存儲(chǔ) JAR 位于 Spark 類路徑中。


查看完整回答
反對(duì) 回復(fù) 2022-07-20
  • 1 回答
  • 0 關(guān)注
  • 187 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)